Skip to content

Fix release workflow. #17

Fix release workflow.

Fix release workflow. #17

Workflow file for this run

name: Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
workflow_dispatch:
inputs:
tag:
description: The tag to manually run a deploy for.
required: true
jobs:
org-check:
name: Check GitHub Organization
if: ${{ github.repository_owner == 'jsirois' }}
runs-on: ubuntu-22.04
steps:
- name: Noop
run: "true"
determine-tag:
name: Determine the release tag to operate against.
needs: org-check
runs-on: ubuntu-22.04
outputs:
release-tag: ${{ steps.determine-tag.outputs.release-tag }}
release-version: ${{ steps.determine-tag.outputs.release-version }}
steps:
- name: Determine Tag
id: determine-tag
run: |
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
RELEASE_TAG=${{ github.event.inputs.tag }}
else
RELEASE_TAG=${GITHUB_REF#refs/tags/}
fi
if [[ "${RELEASE_TAG}" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo "release-tag=${RELEASE_TAG}" >> $GITHUB_OUTPUT
echo "release-version=${RELEASE_TAG#v}" >> $GITHUB_OUTPUT
else
echo "::error::Release tag '${RELEASE_TAG}' must match 'v\d+.\d+.\d+'."
exit 1
fi
package-36-dists:
name: Package Distributions for Python 3.6
needs: determine-tag
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-12]
steps:
- name: Checkout p537 ${{ needs.determine-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-tag.outputs.release-tag }}
- name: Setup Python 3.6
uses: gabrielfalcao/pyenv-action@v18
env:
ENSUREPIP: no
with:
default: "3.6.15"
command: pip install -U tox
- name: Package ${{ needs.determine-tag.outputs.release-tag }}
run: tox -e package
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.os }}-${{ needs.determine-tag.outputs.release-tag }}-3.6-distributions"
path: dist/
retention-days: 1
package-37-313-dists:
name: Package Distributions for Python 3.7 - 3.13
needs: determine-tag
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
python-version: [[3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13, "0-alpha.2"]]
steps:
- name: Checkout p537 ${{ needs.determine-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-tag.outputs.release-tag }}
- name: Setup Python ${{ join(matrix.python-version, '.') }}
uses: actions/setup-python@v5
with:
python-version: "${{ join(matrix.python-version, '.') }}"
- name: Package ${{ needs.determine-tag.outputs.release-tag }}
uses: pantsbuild/actions/run-tox@b16b9cf47cd566acfe217b1dafc5b452e27e6fd7
with:
tox-env: package
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.os }}-${{ needs.determine-tag.outputs.release-tag }}-${{ join(matrix.python-version, '.') }}-distributions"
path: dist/
retention-days: 1
pypi:
name: Publish sdist and wheel to PyPI
needs:
- determine-tag
- package-36-dists
- package-37-313-dists
runs-on: ubuntu-22.04
environment: Release
permissions:
id-token: write
steps:
- name: Download all packaged distributions
uses: actions/download-artifact@v4
with:
path: dist/
- name: Re-organize distributions for upload
run: |
mv -v dist/ubuntu-22.04-${{ needs.determine-tag.outputs.release-tag }}-3.12-distributions/*.tar.gz dist/
mv -v dist/*-distributions/*.whl dist/
rm -rf dist/*-distributions
- name: Publish p537 ${{ needs.determine-tag.outputs.release-tag }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
print-hash: true
verbose: true