Skip to content

Commit 9dfe3e9

Browse files
committed
Only use 'environment: publish' on the 'publish' job
1 parent e2bc332 commit 9dfe3e9

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

.github/workflows/publish.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ jobs:
1515
Build:
1616
name: "Build"
1717
runs-on: "ubuntu-latest"
18-
environment:
19-
name: "publish"
2018
outputs:
2119
hashes: ${{ steps.hash.outputs.hashes }}
22-
pypi-token: ${{ steps.pypi-token.outputs.pypi-token }}
2320

2421
steps:
2522
- name: "Checkout repository"
@@ -55,16 +52,6 @@ jobs:
5552
if-no-files-found: error
5653
retention-days: 5
5754

58-
# We forward here rather than add the 'publish' job
59-
# to the 'publish' GitHub Environment to avoid needing
60-
# to approve the execution twice. Since this job is
61-
# depended on by the 'publish' job we get the same
62-
# security gating.
63-
- name: "Forward 'PYPI_TOKEN' to publish job"
64-
id: "pypi-token"
65-
run: |
66-
echo "pypi-token=${{ secrets.PYPI_TOKEN }}" >> $GITHUB_OUTPUT
67-
6855
Provenance:
6956
needs: ["Build"]
7057
uses: "slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0"
@@ -83,6 +70,11 @@ jobs:
8370
if: startsWith(github.ref, 'refs/tags/')
8471
needs: ["Build", "Provenance"]
8572
runs-on: "ubuntu-latest"
73+
# This environment gives access to 'secrets.PYPI_TOKEN'
74+
# and must be approved by environment reviewers before running.
75+
environment:
76+
name: "publish"
77+
8678
permissions:
8779
# contents: write is only needed to upload the
8880
# dists to the GitHub release.
@@ -107,4 +99,4 @@ jobs:
10799
uses: "pypa/gh-action-pypi-publish@c7f29f7adef1a245bd91520e94867e5c6eedddcc"
108100
with:
109101
user: __token__
110-
password: "${{ needs.Build.outputs.pypi-token }}"
102+
password: "${{ secrets.PYPI_TOKEN }}"

0 commit comments

Comments
 (0)