Skip to content

Commit 78cc7f4

Browse files
authored
Update release GH action to be more secure
1 parent 520e7fa commit 78cc7f4

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
name: Upload Python Package
22

33
on:
4+
workflow_dispatch:
45
release:
56
types: [created]
67

78
jobs:
89
deploy:
910
runs-on: ubuntu-latest
11+
environment: release
12+
permissions:
13+
# IMPORTANT: this permission is mandatory for trusted publishing
14+
id-token: write
1015
steps:
1116
- uses: actions/checkout@v4
1217
with:
@@ -19,6 +24,7 @@ jobs:
1924
run: |
2025
python -m pip install --upgrade pip
2126
pip install setuptools wheel twine
27+
2228
- name: Make sure unit tests succeed
2329
run: |
2430
git config --global user.name "Github Action"
@@ -27,15 +33,17 @@ jobs:
2733
pip install mkdocs-material
2834
pip install .
2935
pytest
30-
- name: Build and publish
31-
env:
32-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
33-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
36+
37+
38+
- name: Build
3439
run: |
3540
python setup.py sdist bdist_wheel
36-
twine upload dist/*
41+
42+
# See https://docs.pypi.org/trusted-publishers/using-a-publisher/
43+
- name: Publish package distributions to PyPI
44+
uses: pypa/gh-action-pypi-publish@release/v1
3745

3846
- name: Deploy mkdocs site
3947
run: |
4048
pip install mkdocs-git-authors-plugin
41-
mkdocs gh-deploy --force
49+
mkdocs gh-deploy --force

0 commit comments

Comments
 (0)