-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Separate jobs for publishing to TestPyPI and PyPI
Have a dedicated build distribution job, and split the publish to TestPyPI and PyPI jobs, to workaround attestation file issue. Xref pypa/gh-action-pypi-publish#283
- Loading branch information
Showing
1 changed file
with
49 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,20 +35,17 @@ on: | |
# - main | ||
|
||
jobs: | ||
publish-pypi: | ||
name: Publish to PyPI | ||
build: | ||
name: Build distribution π¦ | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# This permission is mandatory for OIDC publishing | ||
id-token: write | ||
if: github.repository == 'GenericMappingTools/pygmt' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
# fetch all history so that setuptools-scm works | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
|
@@ -74,11 +71,54 @@ jobs: | |
echo "Generated files:" | ||
ls -lh dist/ | ||
- name: Publish to Test PyPI | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-testpypi: | ||
name: Publish Python π distribution π¦ to TestPyPI | ||
if: github.repository == 'GenericMappingTools/pygmt' | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: testpypi | ||
url: https://test.pypi.org/p/pygmt | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted OIDC publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
- name: Publish distribution π¦ to TestPyPI | ||
uses: pypa/[email protected] | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
- name: Publish to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
publish-pypi: | ||
name: Publish Python π distribution π¦ to PyPI | ||
if: github.repository == 'GenericMappingTools/pygmt' && startsWith(github.ref, 'refs/tags/') | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/pygmt | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted OIDC publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
- name: Publish distribution π¦ to PyPI | ||
uses: pypa/[email protected] |