Skip to content

Release

Release #2

Workflow file for this run

name: Release
on:
push:
tags:
- v*
workflow_dispatch:
inputs:
version:
description: "The version string you would like to release."
type: string
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'
cache: 'pip'
- name: Compute version
id: version
run: |
version=""
case "${{ github.event_name }}" in
push)
version="${GITHUB_REF#refs/*/}"
;;
workflow_dispatch)
version="${{ inputs.version }}"
;;
*)
echo "::error::Unknown event ${{ github.event_name }}. Cannot compute package version."
exit 1
;;
esac
echo "result=$(echo $version | sed 's/^v//g')" >> $GITHUB_OUTPUT
- name: Ensure build & publishing tools
run: pip install build==0.7.0 twine==3.7.0
- name: Package
env:
VERSION: ${{ steps.version.outputs.result }}
run: python -m build
- name: Release
env:
PYPI_REPO_URL: ${{ vars.PYPI_REPO_URL }}
PYPI_REPO_USERNAME: ${{ vars.PYPI_REPO_USERNAME }}
PYPI_REPO_PASSWORD: ${{ secrets.PYPI_REPO_PASSWORD }}
run: |
python -m twine upload --repository-url "${PYPI_REPO_URL}"
--username "${PYPI_REPO_USERNAME}"
--password "${PYPI_REPO_PASSWORD}"
dist/*