Skip to content

Release

Release #39

Workflow file for this run

name: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
publish:
description: 'Whether to publish to PyPI'
required: true
default: '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]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.10"
- 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: Build
run: poetry build
- uses: sigstore/[email protected]
with:
inputs: dist/*
- 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 == 'release' || 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.10"
- 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.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: Upload wheel to release
uses: svenstaro/upload-release-action@v2
with:
file: dist/*.whl
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: Publish
uses: pypa/[email protected]