Skip to content

Workflow file for this run

name: Publish Python 🐍 distributions 📦 to PyPI
on:
release:
types:
- published
permissions:
contents: read
jobs:
build:
name: Build Source distribution and Wheels
runs-on: ${{ matrix.os }}
strategy:
# fail-fast: false
matrix:
# os: ["ubuntu-latest", "macos-latest"]
# python-version: ["3.8", "3.9", "3.10", "3.11"]
include:
- os: ubuntu-latest
python-version: "3.x"
defaults:
run:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
submodules: true
- name: Set up Python3
if: ${{ matrix.os != 'windows-latest' }}
id: pyinstalled
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# - name: Set up Python${{ matrix.python-version }} with NetCDF4 (conda)
# if: ${{ matrix.os == 'windows-latest' }}
# uses: mamba-org/provision-with-micromamba@main
# with:
# cache-downloads: true
# micromamba-version: 'latest'
# extra-specs: |
# python=${{ matrix.python-version }}
# build
# virtualenv
# - name: Install NetCDF4 (Ubuntu/apt)
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# sudo apt-get update
# sudo apt-get install libnetcdf-dev
# - name: Install NetCDF4 (macOS/homebrew)
# if: ${{ matrix.os == 'macos-latest' }}
# uses: tecolicom/actions-use-homebrew-tools@v1
# with:
# tools: netcdf
# cache: yes
- name: Install packaging libraries (Ubuntu/macOS)
if: ${{ matrix.os != 'windows-latest' }}
run: ${{ steps.pyinstalled.outputs.python-path }} -m pip install build virtualenv
# - name: Build a binary wheel (Windows)
# if: ${{ matrix.os == 'windows-latest' }}
# run: python -m build --wheel
# - name: Build a binary wheel (Ubuntu/macOS)
# if: ${{ matrix.os != 'windows-latest' }}
# run: ${{ steps.pyinstalled.outputs.python-path }} -m build --wheel
- name: Build a source tarball (Ubuntu)
if: |
(matrix.os == 'ubuntu-latest') && (matrix.python-version == '3.x')
run: ${{ steps.pyinstalled.outputs.python-path }} -m build --sdist
- uses: actions/upload-artifact@v4
with:
path: |
dist/*.tar.gz
# dist/*.whl
if-no-files-found: error
publish-pypi:
name: Publish Python 🐍 distributions 📦 to PyPI
needs: build
runs-on: ubuntu-latest
environment: production
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
defaults:
run:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
id: download
with:
name: artifact
path: dist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
with:
print-hash: true