Skip to content

DOC: Update URLs from "http" to "https" if available (#3467) #1788

DOC: Update URLs from "http" to "https" if available (#3467)

DOC: Update URLs from "http" to "https" if available (#3467) #1788

# Publish archives to PyPI and TestPyPI using GitHub Actions
#
# This workflow is ran to publish PyGMT archives (source and binary distributions)
# to TestPyPI (for testing only) and PyPI.
#
# Archives will be pushed to TestPyPI for every commit to the main branch and
# tagged releases, and to PyPI for tagged releases only.
#
# Note that authentication to TestPyPI/PyPI is done via OpenID Connect, see also
# https://github.com/pypa/gh-action-pypi-publish/tree/release/v1#publishing-with-openid-connect
#
# Important: this workflow filename must be publish-to-pypi.yml to match the
# settings in PyPI and TestPyPI so that OIDC publishing works.
#
name: Publish to PyPI
# Only run for pushes to the main branch and releases.
on:
push:
branches: [ main ]
paths:
- 'pygmt/**'
- '!pygmt/tests/**'
- 'Makefile'
- 'MANIFEST.in'
- 'pyproject.toml'
- 'README.md'
- '.github/workflows/publish-to-pypi.yml'
release:
types:
- published
# Runs for pull requests should be disabled other than for testing purposes
#pull_request:
# branches:
# - main
jobs:
publish-pypi:
name: Publish to PyPI
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/checkout@v4.1.7
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5.2.0
with:
python-version: '3.12'
- name: Install dependencies
run: python -m pip install build
# 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.
sed --in-place "s/node-and-date/no-local-version/g" pyproject.toml
- name: Build source and wheel distributions
run: |
make package
echo ""
echo "Generated files:"
ls -lh dist/
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.10.2
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.10.2