Release #89
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: 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@v4 | |
with: | |
fetch-depth: 0 | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
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/[email protected] | |
with: | |
bump: '${{ github.event.inputs.bump }}' | |
- run: echo ${{ steps.bumper.outputs.new_version }} | |
- name: Set new project version | |
uses: sandstromviktor/[email protected] | |
with: | |
file: pyproject.toml | |
key: tool.poetry.version | |
value: ${{ steps.bumper.outputs.new_version }} | |
# yamllint disable rule:line-length | |
- name: Commit, tag, and push | |
run: | | |
git add pyproject.toml | |
git commit -m "build: bump version to ${{ steps.bumper.outputs.new_version }} [skip ci]" | |
git push | |
git tag ${{ steps.bumper.outputs.new_version }} -m "${{ steps.bumper.outputs.new_version }}" | |
git push origin ${{ steps.bumper.outputs.new_version }} | |
# yamllint enable rule:line-length | |
- name: Verify documentation site build | |
run: | | |
poetry lock --no-update | |
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/[email protected] | |
with: | |
file: pyproject.toml | |
key: tool.poetry.version | |
value: ${{ steps.bumper.outputs.next_dev_iteration }} | |
# yamllint disable rule:line-length | |
- name: Commit and push | |
run: | | |
git add pyproject.toml | |
git commit -m "build: bump version to ${{ steps.bumper.outputs.next_dev_iteration }} [skip ci]" | |
git push | |
# yamllint enable rule:line-length | |
- name: Create a release name | |
id: release_name | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
var retval = '${{ steps.bumper.outputs.new_version }}' | |
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@v7 | |
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.new_version }}', | |
name: '${{ steps.release_name.outputs.value }}', | |
generate_release_notes: true | |
}) | |
core.setOutput('html_url', response.data.html_url) |