-
Notifications
You must be signed in to change notification settings - Fork 38
100 lines (86 loc) · 3.51 KB
/
Copy pathrelease.yml
File metadata and controls
100 lines (86 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Release
# When a v* tag is pushed:
# 1. build the sdist + wheel, sign each artifact with Sigstore (keyless — using
# the workflow's OIDC identity, no long-lived key), and publish a GitHub
# Release with the artifacts and their .sigstore bundles attached;
# 2. publish the same sdist + wheel to PyPI via Trusted Publishing (OIDC — no
# API token to store or leak), so `pip install coderag` just works.
# Signed release artifacts are what OpenSSF Scorecard's Signed-Releases check
# verifies; the bundles let anyone run `sigstore verify` to confirm provenance.
on:
push:
tags: ["v*"]
workflow_dispatch:
# Least privilege at the top level; each job escalates to exactly what it needs.
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
name: Build, sign & publish (GitHub)
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write # create the GitHub Release and upload assets
id-token: write # OIDC identity for keyless Sigstore signing
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: "3.12"
- name: Build sdist + wheel
run: uv build
- name: Validate package metadata (twine check)
run: uvx twine check dist/*
# Keyless Sigstore signing: one .sigstore bundle per artifact, authenticated
# by the workflow's OIDC identity (no secret key to manage or leak).
- name: Sign artifacts with Sigstore
run: |
uv pip install --system sigstore
for artifact in dist/*.tar.gz dist/*.whl; do
python -m sigstore sign --bundle "${artifact}.sigstore" "${artifact}"
done
- name: Publish GitHub Release with signed artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" \
dist/*.tar.gz dist/*.whl dist/*.sigstore \
--title "${GITHUB_REF_NAME}" \
--generate-notes \
--verify-tag
pypi-publish:
name: Publish to PyPI (Trusted Publishing)
needs: release
runs-on: ubuntu-latest
timeout-minutes: 15
# The `pypi` environment is where the Trusted Publisher is configured on PyPI
# (and where you can add a manual approval gate if you want one).
environment:
name: pypi
url: https://pypi.org/p/coderag
permissions:
id-token: write # OIDC identity for PyPI Trusted Publishing (no token/secret)
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: "3.12"
# Rebuild from the same tagged source the GitHub Release was cut from, so the
# uploaded sdist/wheel match the signed artifacts above.
- name: Build sdist + wheel
run: uv build
- name: Validate package metadata (twine check)
run: uvx twine check dist/*
# Trusted Publishing: PyPI mints a short-lived token from the workflow's OIDC
# identity — nothing to store in repo secrets.
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0