Skip to content

Commit

Permalink
Ensure proper non-dev version string when publishing to PyPI (Generic…
Browse files Browse the repository at this point in the history
…MappingTools#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
  • Loading branch information
weiji14 authored and Josh Sixsmith committed Dec 21, 2022
1 parent 95534a8 commit c2a649b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/publish-to-pypi.yml
Expand Up @@ -19,12 +19,13 @@ jobs:
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
if: github.repository == 'GenericMappingTools/pygmt'

steps:
- name: Checkout
uses: actions/checkout@v2.3.4
with:
# fecth all history so that setuptools-scm works
# fetch all history so that setuptools-scm works
fetch-depth: 0

- name: Set up Python
Expand All @@ -35,13 +36,13 @@ jobs:
- name: Install dependencies
run: python -m pip install setuptools wheel

- name: Fix up version string
# This step is only necessary for testing purposes and for TestPyPI
- name: Fix up version string for TestPyPI
if: ${{ !startsWith(github.ref, 'refs/tags') }}
run: |
# Change setuptools-scm local_scheme to "no-local-version" so the
# local part of the version isn't included, making the version string
# compatible with PyPI.
#
# The step is only necessary for testing purpose
sed --in-place "s/node-and-date/no-local-version/g" setup.py
- name: Build source and wheel distributions
Expand All @@ -54,11 +55,11 @@ jobs:
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.test_pypi_password }}
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.pypi_password }}
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit c2a649b

Please sign in to comment.