1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
---
name: Release
on:
workflow_dispatch:
inputs:
title:
description: "Release title defaults to the semantic version"
required: false
bump:
description: "Bump type (major/minor/patch) defaults to auto"
default: "auto"
required: true
env:
MAIN_PY_VER: "3.13"
jobs:
release:
runs-on: ubuntu-latest
environment: deployment
name: Build, publish, and release
steps:
- name: Checkout sources
uses: actions/checkout@v5
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PY_VER }}
- name: Cache pip repository
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ env.MAIN_PY_VER }}
- name: Prepare python environment
run: |
pip install -r requirements.txt
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Cache poetry virtual environment
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/pyproject.toml') }}-${{ env.MAIN_PY_VER }}
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Determine version and create changelog
id: bumper
uses: tomerfi/version-bumper-action@2.0.5
with:
bump: '${{ github.event.inputs.bump }}'
- name: Set new project version
uses: sandstromviktor/toml-editor@2.0.0
with:
file: pyproject.toml
key: project.version
value: ${{ steps.bumper.outputs.next }}
- name: Commit, tag, and push
run: |
git add pyproject.toml
git commit -m "build: bump version to ${{ steps.bumper.outputs.next }} [skip ci]"
git push
git tag ${{ steps.bumper.outputs.next }} -m "${{ steps.bumper.outputs.next }}"
git push origin ${{ steps.bumper.outputs.next }}
- name: Verify documentation site build
run: |
poetry lock
poetry install --no-interaction
poetry run poe docs_build
- name: Publish build to PyPi
run: |
rm -rf ./dist
poetry publish --build --no-interaction -u __token__ -p ${{ secrets.PYPI_TOKEN }}
- name: Set development project version
uses: sandstromviktor/toml-editor@2.0.0
with:
file: pyproject.toml
key: project.version
value: ${{ steps.bumper.outputs.dev }}
- name: Commit and push
run: |
git add pyproject.toml
git commit -m "build: bump version to ${{ steps.bumper.outputs.dev }} [skip ci]"
git push
- name: Create a release name
id: release_name
uses: actions/github-script@v8
with:
script: |
var retval = '${{ steps.bumper.outputs.next }}'
if ('${{ github.event.inputs.title }}') {
retval = retval.concat(' - ${{ github.event.inputs.title }}')
}
core.setOutput('value', retval)
- name: Create a release
id: gh_release
uses: actions/github-script@v8
with:
github-token: ${{ secrets.RELEASE_PAT }}
script: |
const repo_name = context.payload.repository.full_name
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ steps.bumper.outputs.next }}',
name: '${{ steps.release_name.outputs.value }}',
generate_release_notes: true
})
core.setOutput('html_url', response.data.html_url)
|