Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Trusted Publisher deployment to PyPI #67

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.11"

- name: Install requirements
run: python -m pip install -r env/requirements-build.txt
Expand All @@ -69,7 +69,7 @@ jobs:
- name: Upload archives as artifacts
# Only if not a pull request
if: success() && github.event_name != 'pull_request'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: pypi-${{ github.sha }}
path: dist
Expand All @@ -79,6 +79,10 @@ jobs:
needs: build
# Only publish from the origin repository, not forks
if: github.repository_owner == 'fatiando' && github.event_name != 'pull_request'
environment: pypi
permissions:
# This permission allows trusted publishing to PyPI (without an API token)
id-token: write

steps:
- name: Checkout
Expand All @@ -90,18 +94,16 @@ jobs:

# Fetch the built archives from the "build" job
- name: Download built archives artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: pypi-${{ github.sha }}
path: dist

- name: Publish to Test PyPI
# Only publish to TestPyPI when a PR is merged (pushed to main)
if: success() && github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@bce3b74dbf8cc32833ffba9d15f83425c1a736e0
uses: pypa/gh-action-pypi-publish@v1.8.12
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
# Allow existing releases on test PyPI without errors.
# NOT TO BE USED in PyPI!
Expand All @@ -110,7 +112,4 @@ jobs:
- name: Publish to PyPI
# Only publish to PyPI when a release triggers the build
if: success() && github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@bce3b74dbf8cc32833ffba9d15f83425c1a736e0
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
uses: pypa/[email protected]
Loading