Skip to content

Commit 4ef9038

Browse files
authored
Ensure proper non-dev version string when publishing to PyPI (#900)
* Don't edit setuptools-scm for PyPI releases * Move up comment on 'Fix up version string for TestPyPI' step * Only run the Publish to PyPI workflow on GenericMappingTools/pygmt * Rename secrets from PYPI_PASSWORD to PYPI_API_TOKEN
1 parent 1aa62da commit 4ef9038

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ jobs:
1919
publish-pypi:
2020
name: Publish to PyPI
2121
runs-on: ubuntu-latest
22+
if: github.repository == 'GenericMappingTools/pygmt'
2223

2324
steps:
2425
- name: Checkout
2526
uses: actions/[email protected]
2627
with:
27-
# fecth all history so that setuptools-scm works
28+
# fetch all history so that setuptools-scm works
2829
fetch-depth: 0
2930

3031
- name: Set up Python
@@ -35,13 +36,13 @@ jobs:
3536
- name: Install dependencies
3637
run: python -m pip install setuptools wheel
3738

38-
- name: Fix up version string
39+
# This step is only necessary for testing purposes and for TestPyPI
40+
- name: Fix up version string for TestPyPI
41+
if: ${{ !startsWith(github.ref, 'refs/tags') }}
3942
run: |
4043
# Change setuptools-scm local_scheme to "no-local-version" so the
4144
# local part of the version isn't included, making the version string
4245
# compatible with PyPI.
43-
#
44-
# The step is only necessary for testing purpose
4546
sed --in-place "s/node-and-date/no-local-version/g" setup.py
4647
4748
- name: Build source and wheel distributions
@@ -54,11 +55,11 @@ jobs:
5455
- name: Publish to Test PyPI
5556
uses: pypa/[email protected]
5657
with:
57-
password: ${{ secrets.test_pypi_password }}
58+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
5859
repository_url: https://test.pypi.org/legacy/
5960

6061
- name: Publish to PyPI
6162
if: startsWith(github.ref, 'refs/tags')
6263
uses: pypa/[email protected]
6364
with:
64-
password: ${{ secrets.pypi_password }}
65+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)