Skip to content

Commit c43f08c

Browse files
Split workflow to reduce the available permissions during the build step
1 parent 910b424 commit c43f08c

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

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

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,15 @@ 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-
1813
env:
1914
GITHUB_REPO: ${{ github.repository }}
2015

2116
permissions:
22-
contents: write
23-
id-token: write # For trusted publishing
24-
attestations: write # For artifact attestation
17+
contents: read
2518

2619
steps:
2720
- name: Checkout repository
@@ -40,17 +33,42 @@ jobs:
4033
- name: Build the wheel
4134
run: python3 -m hatch build
4235

43-
- name: Attest build provenance
44-
uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
45-
with:
46-
subject-path: ./dist/*
47-
4836
- name: Upload artifacts
4937
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
5038
with:
5139
name: python-package-distributions
5240
path: ./dist/
5341

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

0 commit comments

Comments
 (0)