Skip to content

Commit 5012a3b

Browse files
committed
maint: Use trusted publishing for pushinng to PyPI
1 parent 6edeb7b commit 5012a3b

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

.github/workflows/release.yml

+40-19
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ on:
77
- master
88

99
jobs:
10-
release:
11-
name: Release
10+
tag-and-build:
11+
name: Tag and build
1212
runs-on: ubuntu-latest
1313
permissions: write-all
1414

15+
outputs:
16+
tag: ${{ steps.tag-step.outputs.tag }}
17+
1518
steps:
1619
- name: Check out the repository
1720
uses: actions/[email protected]
@@ -48,29 +51,47 @@ jobs:
4851
version=$(hatch version) &&
4952
hatch version $version$(date +%s)
5053
54+
- name: Publish the release notes
55+
uses: release-drafter/[email protected]
56+
with:
57+
publish: ${{ steps.check-version.outputs.tag != '' }}
58+
tag: ${{ steps.check-version.outputs.tag }}
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
5162
- name: Build package
5263
run: |
5364
hatch build
5465
55-
- name: Publish package on PyPI
56-
if: steps.check-version.outputs.tag
57-
uses: pypa/[email protected]
66+
- name: Store tag
67+
id: tag-step
68+
run: echo "tag=${{ steps.check-version.outputs.tag }}" >> "$GITHUB_OUTPUT"
69+
70+
- name: Upload release artifacts
71+
uses: actions/upload-artifact@v4
5872
with:
59-
user: __token__
60-
password: ${{ secrets.PYPI_TOKEN }}
73+
name: release-artifacts
74+
path: dist/
75+
76+
pypi-publish:
77+
name: Publish to PyPI
78+
needs: [tag-and-build]
79+
environment:
80+
name: release
81+
url: https://pypi.org/p/protosym
82+
permissions:
83+
id-token: write
84+
runs-on: ubuntu-latest
85+
86+
steps:
87+
- run: echo "Tag = ${{ needs.tag-and-build.outputs.tag }}"
88+
89+
- name: Publish package on PyPI
90+
if: needs.tag-and-build.outputs.tag
91+
uses: pypa/gh-action-pypi-publish@release/v1
6192

6293
- name: Publish package on TestPyPI
63-
if: "! steps.check-version.outputs.tag"
64-
uses: pypa/gh-action-pypi-publish@v1.8.12
94+
if: "! needs.tag-and-build.outputs.tag"
95+
uses: pypa/gh-action-pypi-publish@release/v1
6596
with:
66-
user: __token__
67-
password: ${{ secrets.TEST_PYPI_TOKEN }}
6897
repository_url: https://test.pypi.org/legacy/
69-
70-
- name: Publish the release notes
71-
uses: release-drafter/[email protected]
72-
with:
73-
publish: ${{ steps.check-version.outputs.tag != '' }}
74-
tag: ${{ steps.check-version.outputs.tag }}
75-
env:
76-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)