Skip to content

Commit e01eec5

Browse files
authored
ci: use github token with release-please (#41)
* ci: run release-please from the deployment workflow with GITHUB_TOKEN Drop MY_RELEASE_PLEASE_TOKEN, a long-lived token readable from any branch that could push tags and therefore publish to PyPI. release-please now runs as the first job of deployment.yml with the job token, and the build/publish jobs run when it reports release_created, building the new tag (hatch-vcs unchanged). This is the layout diracx-web already uses: a single workflow, because nothing done with GITHUB_TOKEN (including the release tag) starts another workflow. The workflow now only runs on pushes to the default branch, so the pypi environment must allow that branch instead of v* tags. Assisted-by: Claude:claude-opus-5-5 * ci: serialize release runs and allow re-publishing a tag - concurrency group so two quick merges cannot race to create the same release (queued runs are kept, one may wait on pypi approval) - workflow_dispatch with a tag input to rebuild and publish an existing release when the publish failed after the release was created - drop the explicit token input (it is the action's default) - install only build and readme_renderer; python -m build gets hatchling and hatch-vcs from build-system.requires in its isolated env - rename the workflow to "Release"; it now runs on every push to main Assisted-by: Claude:claude-opus-5-5 * ci: trim release workflow comments Assisted-by: Claude:claude-opus-5-5
1 parent 7c7a05e commit e01eec5

2 files changed

Lines changed: 45 additions & 31 deletions

File tree

‎.github/workflows/deployment.yml‎

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,64 @@
1-
name: Publish Python 🐍 distribution 📦 to PyPI
1+
name: Release
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# Re-publish an existing tag after a failed publish. Run from main (pypi env).
8+
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: Existing release tag to publish (e.g. v0.1.0)
12+
required: true
13+
14+
# Don't cancel: a queued run may be waiting on pypi approval.
15+
concurrency:
16+
group: release
17+
cancel-in-progress: false
418

519
permissions:
620
contents: read
721

822
jobs:
23+
# Tags created with GITHUB_TOKEN trigger no workflows, so publish happens here.
24+
release-please:
25+
if: github.event_name == 'push'
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: write
29+
issues: write
30+
pull-requests: write
31+
outputs:
32+
release_created: ${{ steps.release.outputs.release_created }}
33+
tag_name: ${{ steps.release.outputs.tag_name }}
34+
steps:
35+
- uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
36+
id: release
37+
with:
38+
release-type: simple
39+
940
build:
1041
name: Build distribution 📦
42+
needs: release-please
1143
runs-on: ubuntu-latest
12-
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
44+
if: >-
45+
!cancelled() && (
46+
needs.release-please.outputs.release_created == 'true' ||
47+
github.event_name == 'workflow_dispatch'
48+
)
1349
steps:
1450
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1551
with:
52+
# hatch-vcs needs the tag to compute the version.
53+
ref: ${{ inputs.tag || needs.release-please.outputs.tag_name }}
1654
persist-credentials: false
1755
- name: Set up Python
1856
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
1957
with:
2058
python-version: "3.15"
2159
- name: Installing dependencies
2260
run: |
23-
python -m pip install \
24-
build \
25-
python-dateutil \
26-
pytz \
27-
readme_renderer[md] \
28-
requests \
29-
setuptools_scm
61+
python -m pip install build "readme_renderer[md]"
3062
- name: Validate README for PyPI
3163
run: |
3264
python -m readme_renderer README.md -o /tmp/README.html
@@ -41,12 +73,14 @@ jobs:
4173
publish:
4274
name: Publish distribution 📦 to PyPI
4375
needs: build
76+
# A skipped release-please upstream would otherwise skip this job too.
77+
if: ${{ !cancelled() && needs.build.result == 'success' }}
4478
runs-on: ubuntu-latest
4579
environment:
4680
name: pypi
4781
url: https://pypi.org/p/intercede
4882
permissions:
49-
id-token: write # IMPORTANT: mandatory for trusted publishing
83+
id-token: write # trusted publishing
5084
steps:
5185
- name: Download the distribution packages
5286
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2

‎.github/workflows/release-please.yml‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)