Skip to content

Commit 932b840

Browse files
Merge pull request #243 from kevinbackhouse/split-testpypi-workflow
Split workflow to reduce the available permissions during the build step
2 parents 9c8bbd9 + 718bd9f commit 932b840

1 file changed

Lines changed: 37 additions & 17 deletions

File tree

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

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@ name: Publish Pre-Release to TestPyPI
33
on: workflow_dispatch
44

55
jobs:
6-
publish:
7-
name: Build
6+
build:
7+
name: Build distribution
88
runs-on: ubuntu-latest
9-
10-
# This environment is required as an input to pypa/gh-action-pypi-publish
11-
environment:
12-
name: testpypi
13-
url: https://test.pypi.org/p/seclab-taskflow-agent
9+
outputs:
10+
release_name: ${{ steps.create_version_number.outputs.RELEASE_NAME }}
1411

1512
env:
1613
GITHUB_REPO: ${{ github.repository }}
1714

1815
permissions:
19-
contents: write
20-
id-token: write # For trusted publishing
21-
attestations: write # For artifact attestation
16+
contents: read
2217

2318
steps:
2419
- name: Checkout repository
@@ -29,7 +24,7 @@ jobs:
2924
- name: Set up Python
3025
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
3126
with:
32-
python-version: "3.13"
27+
python-version: "3.14"
3328

3429
- name: Install Hatch
3530
run: pip install --upgrade hatch
@@ -52,17 +47,42 @@ jobs:
5247
- name: Build the wheel
5348
run: python3 -m hatch build
5449

55-
- name: Attest build provenance
56-
uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
57-
with:
58-
subject-path: ./dist/*
59-
6050
- name: Upload artifacts
6151
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
6252
with:
6353
name: python-package-distributions
6454
path: ./dist/
6555

56+
publish:
57+
name: Publish to TestPyPI
58+
needs: build
59+
runs-on: ubuntu-latest
60+
61+
# This environment is required as an input to pypa/gh-action-pypi-publish
62+
environment:
63+
name: testpypi
64+
url: https://test.pypi.org/p/seclab-taskflow-agent
65+
66+
env:
67+
GITHUB_REPO: ${{ github.repository }}
68+
69+
permissions:
70+
contents: write
71+
id-token: write # For trusted publishing
72+
attestations: write # For artifact attestation
73+
74+
steps:
75+
- name: Download distribution artifacts
76+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
77+
with:
78+
name: python-package-distributions
79+
path: ./dist/
80+
81+
- name: Attest build provenance
82+
uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
83+
with:
84+
subject-path: ./dist/*
85+
6686
- name: Publish to TestPyPI
6787
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
6888
with:
@@ -72,5 +92,5 @@ jobs:
7292
- name: Create GitHub Release
7393
env:
7494
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
RELEASE_NAME: ${{ steps.create_version_number.outputs.RELEASE_NAME }}
95+
RELEASE_NAME: ${{ needs.build.outputs.release_name }}
7696
run: gh release create $RELEASE_NAME dist/* --repo $GITHUB_REPO --prerelease --generate-notes

0 commit comments

Comments
 (0)