Skip to content

ci: Add release workflow for PyPI #2

ci: Add release workflow for PyPI

ci: Add release workflow for PyPI #2

Workflow file for this run

name: Continuous delivery - PyPI
on: [push]
# 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 envrionment
run: make install
- name: Check version tag format
shell: bash
run: |
VERSION_TAG="${{ github.event.release.tag_name }}"
VERSION_TAG="v0.1.0"
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 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 envrionment
run: make install
- name: Build
run: poetry build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nitrokey-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@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