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

Ensure proper non-dev version string when publishing to PyPI #900

Merged
merged 9 commits into from Feb 16, 2021
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') }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand it correctly, when we make a release/tag, this sed command won't run. So, we are pushing the same versions (e.g., v0.3.1) to both PyPI and TestPyPI, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct. But I think pushing v0.3.1 to both PyPI and TestPyPI is fine right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks good.

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 }}