Skip to content

Commit

Permalink
build(release): publish to PyPI (& testPyPI), using trusted publisher
Browse files Browse the repository at this point in the history
Having specified a "trusted publisher" (the repository and GHA workflow), no tokens and secrets are necessary.

BREAKING: Bump to v1.0.0
  • Loading branch information
JorisVincent committed May 22, 2023
1 parent db12dda commit 51b0d0e
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/release.yml
Expand Up @@ -7,6 +7,9 @@ on:
jobs:
test_publish:
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing to PyPI
id-token: write

steps:
- name: Fetch wheel(s) from release
Expand All @@ -26,8 +29,6 @@ jobs:
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Test install from TestPyPI
Expand All @@ -37,3 +38,33 @@ jobs:
--extra-index-url https://pypi.org/simple \
stimupy
publish:
needs: test_publish
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing to PyPI
id-token: write

steps:
- name: Fetch wheel(s) from release
uses: dsaltares/fetch-gh-release-asset@1.1.0
with:
regex: true
file: 'stimupy-.[0-9]*\.[0-9]*\.[0-9]*-py3-none-any\.whl'
target: 'dist/'

- name: Fetch sdist(s) from release
uses: dsaltares/fetch-gh-release-asset@1.1.0
with:
regex: true
file: 'stimupy-.[0-9]*\.[0-9]*\.[0-9]*\.tar.gz'
target: 'dist/'

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Test install from PyPI
run: |
pip install \
--index-url https://pypi.org/simple/ \
stimupy

0 comments on commit 51b0d0e

Please sign in to comment.