Skip to content

Workflow file for this run

name: Continuous delivery - PyPI
on:
release:
types: [released]
jobs:
version-check:
name: Check versioning
runs-on: ubuntu-latest
container: python:3.9-slim
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install required packages
run: |
apt update
apt install -y python3-poetry
- name: Create virtual envrionment
run: make init
- 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]+$ ]]; 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 env info --path)/bin/python -c "from nitrokeyapp import __version__; print(__version__)")
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@v3
- name: Install required packages
run: |
apt update
apt install -y binutils gcc libglib2.0-dev libpcsclite-dev libusb-1.0-0 make python3-poetry swig
- name: Create virtual environment
run: make init
- name: Build
run: make build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: nitrokeyapp-pypi
path: dist
publish-binary:
name: Publish
runs-on: ubuntu-latest
container: python:3.9-slim
needs: build
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
POETRY_PYPI_URL: https://upload.pypi.org/legacy/
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: nitrokeyapp-pypi
path: dist
- name: Install required packages
run: |
apt update
apt install -y python3-poetry
- name: Configure PyPI repository
run: poetry config repositories.pypi $POETRY_PYPI_URL
- name: Publish release
run: poetry publish -r pypi