Skip to content

Commit 470ef89

Browse files
Merge pull request #246 from kevinbackhouse/split-pypi-workflow
Split workflow to reduce the available permissions during the build step
2 parents 24ae593 + ff6fe81 commit 470ef89

1 file changed

Lines changed: 33 additions & 17 deletions

File tree

.github/workflows/publish-to-pypi.yaml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,13 @@ on:
66
- v[0-9]+.[0-9]+.[0-9]+
77

88
jobs:
9-
publish:
10-
name: Build
9+
build:
10+
name: Build distribution
1111
runs-on: ubuntu-latest
1212

13-
# This environment is required as an input to pypa/gh-action-pypi-publish
14-
environment:
15-
name: pypi
16-
url: https://pypi.org/p/seclab-taskflow-agent
17-
18-
env:
19-
GITHUB_REPO: ${{ github.repository }}
2013

2114
permissions:
22-
contents: write
23-
id-token: write # For trusted publishing
24-
attestations: write # For artifact attestation
15+
contents: read
2516

2617
steps:
2718
- name: Checkout repository
@@ -40,17 +31,42 @@ jobs:
4031
- name: Build the wheel
4132
run: python3 -m hatch build
4233

43-
- name: Attest build provenance
44-
uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
45-
with:
46-
subject-path: ./dist/*
47-
4834
- name: Upload artifacts
4935
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
5036
with:
5137
name: python-package-distributions
5238
path: ./dist/
5339

40+
publish:
41+
name: Publish to PyPI
42+
needs: build
43+
runs-on: ubuntu-latest
44+
45+
# This environment is required as an input to pypa/gh-action-pypi-publish
46+
environment:
47+
name: pypi
48+
url: https://pypi.org/p/seclab-taskflow-agent
49+
50+
env:
51+
GITHUB_REPO: ${{ github.repository }}
52+
53+
permissions:
54+
contents: write
55+
id-token: write # For trusted publishing
56+
attestations: write # For artifact attestation
57+
58+
steps:
59+
- name: Download distribution artifacts
60+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
61+
with:
62+
name: python-package-distributions
63+
path: ./dist/
64+
65+
- name: Attest build provenance
66+
uses: actions/attest@v4.1.0 # immutable release
67+
with:
68+
subject-path: ./dist/*
69+
5470
- name: Publish to PyPI
5571
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
5672
with:

0 commit comments

Comments
 (0)