Skip to content

Commit 7fe3da7

Browse files
committed
ci: run the release through the shared python-release reusable
Replaces four hand-rolled jobs (10 step-level third-party actions) with one caller job and zero stray uses. Build, twine check, GitHub Release and the PyPI upload all move into netresearch/.github, so the pinned action versions stay maintained centrally. Nothing working is lost, because the publish path never worked: the repo has no Actions secrets at all, so PYPI_API_TOKEN and TEST_PYPI_API_TOKEN resolved to empty in every run, and there are no tags, no releases, and no cli-audit package registered on PyPI. Rather than carry a job that is guaranteed to fail, publishing is switched off and the two prerequisites are documented in the workflow: a PyPI Trusted Publisher for this repo, and the GitHub Environment it names (only `copilot` exists today). Flipping publish-pypi to true is then the whole change — the reusable uploads via OIDC, so no token is needed at all. Two behaviours the reusable could not express until now were added to it first (netresearch/.github#292), so they survive the migration: - release-files: attaches the sdist and wheel, as softprops/action-gh-release did via `files: dist/*`. - prerelease: auto — reproduces the previous contains(alpha|beta|rc) expression and additionally covers the PEP 440 spellings it missed. At 2.0.0-alpha.6 this is the normal case here. Dropped deliberately as local quirks: the CHANGELOG-derived release body (replaced by --generate-notes) and the separate TestPyPI dispatch path. Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
1 parent 6007d08 commit 7fe3da7

1 file changed

Lines changed: 39 additions & 116 deletions

File tree

.github/workflows/release.yml

Lines changed: 39 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -6,121 +6,44 @@ on:
66
- 'v*.*.*'
77
workflow_dispatch:
88

9-
permissions:
10-
contents: write
11-
9+
permissions: {}
10+
11+
# Thin caller: build, dist check, GitHub Release and PyPI upload all live in
12+
# the shared reusable, so every pinned action version is maintained centrally
13+
# in netresearch/.github. This workflow has zero step-level `uses:`.
14+
#
15+
# PyPI publishing is OFF, and that records a fact rather than making a policy
16+
# choice: the token-based publish jobs this replaces could never have run.
17+
# The repo has no Actions secrets at all, so PYPI_API_TOKEN and
18+
# TEST_PYPI_API_TOKEN resolved to empty; there are no tags, no releases, and
19+
# cli-audit is not registered on PyPI.
20+
#
21+
# Turning publishing on needs two things that cannot be done from a workflow
22+
# file:
23+
# 1. a PyPI Trusted Publisher configured for
24+
# netresearch/coding_agent_cli_toolset, pointing at this workflow and at
25+
# the environment named by the reusable's `pypi-environment` input,
26+
# 2. that GitHub Environment (only `copilot` exists today).
27+
# Then set publish-pypi: true. No token is required — the reusable uploads
28+
# via OIDC Trusted Publishing.
1229
jobs:
13-
build:
14-
name: Build Distribution
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
20-
21-
- name: Set up Python
22-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
23-
with:
24-
python-version: '3.14'
25-
26-
- name: Install build tools
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install build twine
30-
31-
- name: Build package
32-
run: |
33-
python -m build
34-
35-
- name: Check package
36-
run: |
37-
twine check dist/*
38-
39-
- name: Upload artifacts
40-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
41-
with:
42-
name: distributions
43-
path: dist/
44-
4530
release:
46-
name: Create GitHub Release
47-
runs-on: ubuntu-latest
48-
needs: [build]
49-
50-
steps:
51-
- name: Checkout code
52-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
53-
54-
- name: Download artifacts
55-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
56-
with:
57-
name: distributions
58-
path: dist/
59-
60-
- name: Extract version
61-
id: version
62-
run: |
63-
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
64-
65-
- name: Generate changelog
66-
id: changelog
67-
run: |
68-
# Extract changes for this version from CHANGELOG if it exists
69-
if [ -f CHANGELOG.md ]; then
70-
echo "CHANGES<<EOF" >> $GITHUB_OUTPUT
71-
sed -n "/^## \[${VERSION}\]/,/^## \[/p" CHANGELOG.md | sed '$d' >> $GITHUB_OUTPUT || echo "See CHANGELOG.md for details" >> $GITHUB_OUTPUT
72-
echo "EOF" >> $GITHUB_OUTPUT
73-
else
74-
echo "CHANGES=Release ${VERSION}" >> $GITHUB_OUTPUT
75-
fi
76-
env:
77-
VERSION: ${{ steps.version.outputs.VERSION }}
78-
79-
- name: Create Release
80-
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
81-
with:
82-
files: dist/*
83-
body: ${{ steps.changelog.outputs.CHANGES }}
84-
draft: false
85-
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
86-
env:
87-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88-
89-
publish-pypi:
90-
name: Publish to PyPI
91-
runs-on: ubuntu-latest
92-
needs: [build, release]
93-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
94-
95-
steps:
96-
- name: Download artifacts
97-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
98-
with:
99-
name: distributions
100-
path: dist/
101-
102-
- name: Publish to PyPI
103-
uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1
104-
with:
105-
password: ${{ secrets.PYPI_API_TOKEN }}
106-
skip-existing: true
107-
108-
publish-test-pypi:
109-
name: Publish to Test PyPI
110-
runs-on: ubuntu-latest
111-
needs: [build]
112-
if: github.event_name == 'workflow_dispatch'
113-
114-
steps:
115-
- name: Download artifacts
116-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
117-
with:
118-
name: distributions
119-
path: dist/
120-
121-
- name: Publish to Test PyPI
122-
uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1
123-
with:
124-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
125-
repository-url: https://test.pypi.org/legacy/
126-
skip-existing: true
31+
uses: netresearch/.github/.github/workflows/python-release.yml@main
32+
permissions:
33+
contents: write
34+
id-token: write
35+
with:
36+
python-version: '3.14'
37+
package-manager: pip
38+
install-cmd: python -m pip install --upgrade pip build twine
39+
build-cmd: python -m build
40+
check-cmd: python -m twine check dist/*
41+
# Attach the sdist and wheel to the Release, as the previous
42+
# softprops/action-gh-release step did via `files: dist/*`.
43+
release-files: dist/*
44+
# Reproduces the previous prerelease expression and also covers the
45+
# PEP 440 spellings it missed. The project is on 2.0.0-alpha.6, so
46+
# prerelease tags are the normal case here, not the exception.
47+
prerelease: auto
48+
publish-pypi: false
49+
publish-testpypi: false

0 commit comments

Comments
 (0)