Workflow file for this run
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: Continuous delivery - PyPI | |
on: | |
release: | |
types: [released] | |
env: | |
REQUIRED_PACKAGES: make | |
jobs: | |
version-check: | |
name: Check versioning | |
runs-on: ubuntu-latest | |
container: python:3.9-slim | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install required packages | |
run: apt update && apt install -y ${REQUIRED_PACKAGES} | |
- name: Install Poetry | |
run: pip install poetry | |
- name: Create virtual environment | |
run: make install | |
- name: Check version tag format | |
shell: bash | |
run: | | |
VERSION_TAG="${{ github.event.release.tag_name }}" | |
if [[ $VERSION_TAG =~ ^v[0-9]+.[0-9]+.[0-9]+(-rc\.[1-9])?$ ]]; then exit 0; else exit 1; fi | |
- name: Check if version tag and package version are equal | |
shell: bash | |
run: | | |
VERSION_TAG="${{ github.event.release.tag_name }}" | |
PACKAGE_VERSION="v"$(poetry version --short) | |
if [ $VERSION_TAG == $PACKAGE_VERSION ]; then exit 0; else exit 1; fi | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
container: python:3.9-slim | |
needs: version-check | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install required packages | |
run: apt update && apt install -y ${REQUIRED_PACKAGES} | |
- name: Install Poetry | |
run: pip install poetry | |
- name: Create virtual environment | |
run: make install | |
- name: Build | |
run: poetry build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nitrokey-pypi | |
path: dist | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
container: python:3.9-slim | |
needs: build | |
environment: PyPI | |
env: | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} | |
POETRY_PYPI_URL: https://upload.pypi.org/legacy/ | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: nitrokey-pypi | |
path: dist | |
- name: Install Poetry | |
run: pip install poetry | |
- name: Configure PyPI repository | |
run: poetry config repositories.pypi $POETRY_PYPI_URL | |
- name: Publish release | |
run: poetry publish --repository pypi |