Release #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: 'Whether to publish to PyPI' | |
required: true | |
default: 'false' | |
tag: | |
description: 'Tag to use for release' | |
required: false | |
permissions: | |
contents: write | |
id-token: write | |
jobs: | |
build: | |
name: Build wheel and sdist | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
with: | |
fetch-tags: true | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: "3.12" | |
- name: Upgrade pip | |
env: | |
PIP_CONSTRAINT: .github/workflows/constraints.txt | |
run: | | |
pip install pip | |
pip --version | |
- name: Install Poetry | |
env: | |
PIP_CONSTRAINT: .github/workflows/constraints.txt | |
run: | | |
pipx install poetry | |
pipx inject poetry poetry-dynamic-versioning[plugin] | |
poetry --version | |
poetry self show plugins | |
- name: Build | |
run: poetry build | |
- name: Upload artifacts | |
uses: actions/[email protected] | |
with: | |
name: dist | |
path: dist | |
publish: | |
name: Publish to PyPI | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' || github.event.inputs.publish == 'true' | |
needs: [build] | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: "3.12" | |
- name: Upgrade pip | |
env: | |
PIP_CONSTRAINT: .github/workflows/constraints.txt | |
run: | | |
pip install pip | |
pip --version | |
- name: Install Poetry | |
env: | |
PIP_CONSTRAINT: .github/workflows/constraints.txt | |
run: | | |
pipx install poetry | |
poetry --version | |
- name: Check version | |
run: | | |
version=$(poetry version | awk '{print $2}') | |
tag=$(echo "${{ github.event.inputs.tag || github.ref }}" | awk '{split($0,p,"/"); print p[3]}') | |
if [ $version != $tag ]; then echo "Release tag and package version do not match!"; exit 1; fi; | |
- name: Download artifacts | |
uses: actions/[email protected] | |
with: | |
name: dist | |
path: dist | |
- name: Publish | |
uses: pypa/[email protected] | |
# Move this up when PyPI supports signing | |
- uses: sigstore/[email protected] | |
with: | |
inputs: dist/* | |
- name: Upload wheel to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
file: dist/*.whl | |
tag: ${{ github.event.inputs.tag || github.ref }} | |
overwrite: true | |
file_glob: true |