Skip to content

Commit e609567

Browse files
net0wellclaude
andcommitted
ci: release por tag no nuget.org, GHCR, GitHub Release e PyPI (spec 009)
- release.yml (tag vX.Y.Z), AC-5: - roda o CI completo no commit da tag e só então publica; - os 7 pacotes vão para o nuget.org por trusted publishing (OIDC; D-170) no environment `release`, que pede aprovação, depois de conferir que todos têm a versão da tag; - as imagens psr-worker e psr-dashboard vão para o GHCR em amd64 e arm64, com SBOM e proveniência, nas tags X.Y.Z, X.Y e latest (pré-versões só com X.Y.Z); - o GitHub Release usa a seção da versão no CHANGELOG e anexa os pacotes. - release-python.yml (tag python/vX.Y.Z), AC-6: CI completo, confere a versão em `_version.py`, gera sdist e wheel e publica no PyPI por OIDC (environment `pypi`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e3176b5 commit e609567

2 files changed

Lines changed: 211 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release (psrunner)
2+
3+
# A tag python/vX.Y.Z publishes the psrunner SDK to PyPI with trusted publishing (OIDC, no stored token; spec 009,
4+
# AC-6). The SDK has its own version, compatible with protocol 1 while it is 1.x; the CI must be green on the commit.
5+
on:
6+
push:
7+
tags: ['python/v*']
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
ci:
14+
name: CI
15+
uses: ./.github/workflows/ci.yml
16+
17+
publish:
18+
name: PyPI
19+
needs: ci
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: pypi
23+
url: https://pypi.org/project/psrunner/
24+
permissions:
25+
id-token: write
26+
defaults:
27+
run:
28+
working-directory: python/psrunner
29+
steps:
30+
- uses: actions/checkout@v7
31+
32+
- uses: astral-sh/setup-uv@v10.3.0
33+
34+
- name: Check the version
35+
run: |
36+
expected="${GITHUB_REF_NAME#python/v}"
37+
actual=$(uv run --no-project python -c "exec(open('src/psrunner/_version.py').read()); print(__version__)")
38+
test "$actual" = "$expected" || { echo "src/psrunner/_version.py has $actual, the tag says $expected"; exit 1; }
39+
40+
- name: Build
41+
run: uv build --out-dir dist
42+
43+
- uses: pypa/gh-action-pypi-publish@release/v1
44+
with:
45+
packages-dir: python/psrunner/dist

‎.github/workflows/release.yml‎

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Release
2+
3+
# A tag vX.Y.Z publishes the 7 NuGet packages, the two container images and the GitHub Release (spec 009, AC-5).
4+
# Nothing is published unless the CI is green on the tagged commit, and the `release` environment asks a maintainer
5+
# to approve the publication.
6+
on:
7+
push:
8+
tags: ['v*']
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: release-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
env:
18+
DOTNET_NOLOGO: true
19+
DOTNET_CLI_TELEMETRY_OPTOUT: true
20+
21+
jobs:
22+
ci:
23+
name: CI
24+
uses: ./.github/workflows/ci.yml
25+
26+
packages:
27+
name: NuGet packages
28+
needs: ci
29+
runs-on: ubuntu-latest
30+
environment: release
31+
permissions:
32+
contents: read
33+
id-token: write # NuGet trusted publishing (D-170)
34+
steps:
35+
- uses: actions/checkout@v7
36+
with:
37+
fetch-depth: 0
38+
39+
- uses: actions/setup-dotnet@v6
40+
with:
41+
global-json-file: global.json
42+
43+
# Packing in Release embeds the Vue panel in PythonScriptRunner.Dashboard (D-155).
44+
- uses: actions/setup-node@v7
45+
with:
46+
node-version-file: panel/.nvmrc
47+
cache: npm
48+
cache-dependency-path: panel/package-lock.json
49+
50+
- name: Pack
51+
run: dotnet pack PythonScriptRunner.slnx --configuration Release --output artifacts/packages
52+
53+
- name: Check the version
54+
run: |
55+
expected="${GITHUB_REF_NAME#v}"
56+
for package in artifacts/packages/*.nupkg; do
57+
case "$package" in
58+
*".$expected.nupkg") ;;
59+
*) echo "$package does not have version $expected"; exit 1 ;;
60+
esac
61+
done
62+
test "$(ls artifacts/packages/*.nupkg | wc -l)" -eq 7
63+
64+
- name: Log in to NuGet
65+
id: nuget
66+
uses: NuGet/login@v1
67+
with:
68+
user: ${{ vars.NUGET_USER }}
69+
70+
# The symbol packages (.snupkg) next to each .nupkg are pushed with it.
71+
- name: Push
72+
run: >-
73+
dotnet nuget push "artifacts/packages/*.nupkg"
74+
--api-key "${{ steps.nuget.outputs.NUGET_API_KEY }}"
75+
--source https://api.nuget.org/v3/index.json
76+
--skip-duplicate
77+
78+
- uses: actions/upload-artifact@v7
79+
with:
80+
name: packages
81+
path: artifacts/packages/
82+
83+
images:
84+
name: Container images (${{ matrix.image }})
85+
needs: ci
86+
runs-on: ubuntu-latest
87+
environment: release
88+
permissions:
89+
contents: read
90+
packages: write
91+
strategy:
92+
matrix:
93+
include:
94+
- image: psr-worker
95+
dockerfile: hosts/PythonScriptRunner.WorkerHost/Dockerfile
96+
- image: psr-dashboard
97+
dockerfile: hosts/PythonScriptRunner.DashboardHost/Dockerfile
98+
steps:
99+
- uses: actions/checkout@v7
100+
101+
# The build stages compile on the runner's platform; only the final stage runs for arm64 (emulated).
102+
- uses: docker/setup-qemu-action@v4
103+
104+
- uses: docker/setup-buildx-action@v4
105+
106+
- uses: docker/login-action@v4
107+
with:
108+
registry: ghcr.io
109+
username: ${{ github.actor }}
110+
password: ${{ secrets.GITHUB_TOKEN }}
111+
112+
- id: meta
113+
uses: docker/metadata-action@v6
114+
with:
115+
images: ghcr.io/scriptrunnerkit/${{ matrix.image }}
116+
tags: |
117+
type=semver,pattern={{version}}
118+
type=semver,pattern={{major}}.{{minor}},enable=${{ !contains(github.ref_name, '-') }}
119+
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
120+
121+
- uses: docker/build-push-action@v7
122+
with:
123+
context: .
124+
file: ${{ matrix.dockerfile }}
125+
platforms: linux/amd64,linux/arm64
126+
push: true
127+
tags: ${{ steps.meta.outputs.tags }}
128+
labels: ${{ steps.meta.outputs.labels }}
129+
build-args: VERSION=${{ steps.meta.outputs.version }}
130+
sbom: true
131+
provenance: mode=max
132+
cache-from: type=gha,scope=release-${{ matrix.image }}
133+
cache-to: type=gha,scope=release-${{ matrix.image }},mode=max
134+
135+
github-release:
136+
name: GitHub Release
137+
needs: [packages, images]
138+
runs-on: ubuntu-latest
139+
permissions:
140+
contents: write
141+
steps:
142+
- uses: actions/checkout@v7
143+
144+
- uses: actions/download-artifact@v8
145+
with:
146+
name: packages
147+
path: artifacts/packages
148+
149+
# The notes are the CHANGELOG section of the version, which also carries the compatibility matrix (D-178).
150+
- name: Release notes
151+
run: |
152+
version="${GITHUB_REF_NAME#v}"
153+
awk -v v="$version" '
154+
index($0, "## [" v "]") == 1 { found = 1; next }
155+
found && index($0, "## [") == 1 { exit }
156+
found { print }
157+
' CHANGELOG.md > notes.md
158+
test -s notes.md || { echo "CHANGELOG.md has no section for $version"; exit 1; }
159+
160+
- name: Create the release
161+
env:
162+
GH_TOKEN: ${{ github.token }}
163+
run: |
164+
prerelease=$([[ "$GITHUB_REF_NAME" == *-* ]] && echo --prerelease || true)
165+
gh release create "$GITHUB_REF_NAME" artifacts/packages/*.nupkg \
166+
--title "PythonScriptRunner ${GITHUB_REF_NAME#v}" --notes-file notes.md --verify-tag $prerelease

0 commit comments

Comments
 (0)