Skip to content

Commit 501d01b

Browse files
authored
Merge pull request #239 from ppfeufer/pypi-trusted-publishing
2 parents 3b367c2 + 6866323 commit 501d01b

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Release to PyPI using Trusted Publishing
2+
# This workflow is triggered when a release is published on GitHub.
3+
#
4+
# https://docs.pypi.org/trusted-publishers/
5+
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
6+
# https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/
7+
# https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments
8+
19
name: Release
210

311
on:
@@ -10,6 +18,11 @@ jobs:
1018
# Release
1119
name: Release
1220
runs-on: ubuntu-latest
21+
environment:
22+
name: pypi-release
23+
permissions:
24+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
25+
contents: write
1326

1427
steps:
1528
# Checkout the repository
@@ -27,17 +40,12 @@ jobs:
2740
run: |
2841
python -m pip install --upgrade pip
2942
python -m pip install --upgrade build
30-
python -m pip install --upgrade setuptools wheel twine
31-
32-
# Package and Upload to PyPI
33-
- name: Package and Upload to PyPI
34-
env:
35-
STACKMANAGER_VERSION: ${{ github.event.release.tag_name }}
36-
TWINE_USERNAME: __token__
37-
TWINE_PASSWORD: ${{ secrets.PYPI_APIKEY }}
43+
python -m pip install --upgrade setuptools wheel
44+
45+
# Build Package
46+
- name: Package
3847
run: |
3948
python -m build
40-
python -m twine upload dist/*
4149
4250
# Add Assets to Release on GitHub
4351
- name: Add Assets to Release on GitHub
@@ -47,3 +55,7 @@ jobs:
4755
# The name of the file(s) to upload
4856
files: |
4957
dist/*
58+
59+
# Publish to PyPI using Trusted Publishing
60+
- name: Upload to PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)