Skip to content

Commit e5f252c

Browse files
committed
Safer publishing mechanism, refs #8
1 parent bcebc92 commit e5f252c

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

  • {{cookiecutter.hyphenated}}/.github/workflows

{{cookiecutter.hyphenated}}/.github/workflows/publish.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ jobs:
2727
- name: Run tests
2828
run: |
2929
python -m pytest
30-
deploy:
30+
build:
3131
runs-on: ubuntu-latest
3232
needs: [test]
33-
environment: release
34-
permissions:
35-
id-token: write
3633
steps:
3734
- uses: actions/checkout@v4
3835
- name: Set up Python
@@ -47,6 +44,25 @@ jobs:
4744
- name: Build
4845
run: |
4946
python -m build
50-
- name: Publish
47+
- name: Store the distribution packages
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: python-packages
51+
path: dist/
52+
publish:
53+
name: Publish to PyPI
54+
runs-on: ubuntu-latest
55+
if: startsWith(github.ref, 'refs/tags/')
56+
needs: [build]
57+
environment: release
58+
permissions:
59+
id-token: write
60+
steps:
61+
- name: Download distribution packages
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: python-packages
65+
path: dist/
66+
- name: Publish to PyPI
5167
uses: pypa/gh-action-pypi-publish@release/v1
5268
{% endraw %}

0 commit comments

Comments
 (0)