Skip to content

Continuous Delivery of Python package #101

Continuous Delivery of Python package

Continuous Delivery of Python package #101

Workflow file for this run

name: Continuous Delivery of Python package
on:
push:
branches:
- main
workflow_dispatch:
inputs:
production_release:
description: "Production release?"
type: boolean
required: true
default: true
concurrency: release
permissions:
contents: write
packages: read
jobs:
ci-check-python:
name: Check Python
uses: ./.github/workflows/check-python.yaml
ci-build-python:
name: Build Python
uses: ./.github/workflows/build-python.yaml
needs: ci-check-python
release:
name: Release Library
needs: ci-build-python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Fetch entire repository history so we can determine version number from it
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Set up Poetry
uses: ./.github/actions/setup-poetry
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Get branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: get_branch
- name: Set Git user as GitHub actions
run: git config --global user.email "[email protected]" && git config --global user.name "github-actions"
- name: Create Continuous Deployment - Beta (non-prod)
if: steps.get_branch.outputs.branch == 'main' && !inputs.production_release
run: |
poetry run semantic-release \
-v DEBUG \
--prerelease \
--define=branch=main \
--define=upload_to_repository=true \
publish
gh release edit --prerelease "v$(poetry run semantic-release print-version --current)"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_USERNAME: __token__
REPOSITORY_PASSWORD: ${{ secrets.PYPI_API_KEY }}
- name: Create Continuous Deployment - Production
if: steps.get_branch.outputs.branch == 'main' && inputs.production_release
run: |
poetry run semantic-release \
-v DEBUG \
--define=version_source="commit" \
--define=patch_without_tag=true \
--define=upload_to_repository=true \
--define=branch=main \
publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_USERNAME: __token__
REPOSITORY_PASSWORD: ${{ secrets.PYPI_API_KEY }}