Skip to content

Commit 9189c4d

Browse files
authored
Merge pull request #818 from minrk/tp
update release workflow for tighter permissions
2 parents bd61bd3 + ca267f7 commit 9189c4d

1 file changed

Lines changed: 43 additions & 20 deletions

File tree

.github/workflows/release.yaml

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,44 @@
44
name: Release
55

66
# Always tests wheel building, but only publish to PyPI on pushed tags.
7+
78
on:
89
pull_request:
910
paths-ignore:
1011
- "docs/**"
11-
- ".github/workflows/*.yaml"
12+
- "**.md"
13+
- ".github/workflows/*"
1214
- "!.github/workflows/release.yaml"
1315
push:
1416
paths-ignore:
1517
- "docs/**"
16-
- ".github/workflows/*.yaml"
18+
- "**.md"
19+
- "**.rst"
20+
- ".github/workflows/*"
1721
- "!.github/workflows/release.yaml"
1822
branches-ignore:
1923
- "dependabot/**"
2024
- "pre-commit-ci-update-config"
21-
tags: ["**"]
25+
tags:
26+
- "**"
2227
workflow_dispatch:
2328

29+
permissions:
30+
contents: read
31+
2432
jobs:
2533
build-release:
26-
runs-on: ubuntu-22.04
27-
permissions:
28-
# id-token=write is required for pypa/gh-action-pypi-publish, and the PyPI
29-
# project needs to be configured to trust this workflow.
30-
#
31-
# ref: https://github.com/jupyterhub/team-compass/issues/648
32-
#
33-
id-token: write
34-
34+
runs-on: ubuntu-24.04
3535
steps:
36-
- uses: actions/checkout@v6
37-
- uses: actions/setup-python@v6
36+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
37+
with:
38+
persist-credentials: false
39+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
3840
with:
39-
python-version: "3.11"
41+
python-version: "3.13"
4042

41-
- name: install build package
43+
- name: install build requirements
4244
run: |
43-
pip install --upgrade pip
4445
pip install build
4546
pip freeze
4647
@@ -49,6 +50,28 @@ jobs:
4950
python -m build --sdist --wheel .
5051
ls -l dist
5152
52-
- name: publish to pypi
53-
uses: pypa/gh-action-pypi-publish@release/v1
54-
if: startsWith(github.ref, 'refs/tags/')
53+
- name: upload dists
54+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
55+
with:
56+
name: ${{ github.event.repository.name }}-dist
57+
path: dist/
58+
59+
pypi-publish:
60+
runs-on: ubuntu-24.04
61+
if: startsWith(github.ref, 'refs/tags/')
62+
environment:
63+
name: release
64+
needs:
65+
- build-release
66+
permissions:
67+
id-token: write
68+
69+
steps:
70+
- name: Get release artifacts
71+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
72+
with:
73+
name: ${{ github.event.repository.name }}-dist
74+
path: dist/
75+
76+
- name: Publish to PyPI
77+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1

0 commit comments

Comments
 (0)