Release #74
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 | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
environment: deployment | |
name: Build, publish, and release | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
- name: Setup Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Cache pip repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
- 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@v3 | |
with: | |
path: .venv | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
- 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.2 | |
with: | |
bump: '${{ github.event.inputs.bump }}' | |
- name: Set new project version | |
uses: sandstromviktor/toml-editor@2.0.0 | |
with: | |
file: pyproject.toml | |
key: tool.poetry.version | |
value: ${{ steps.bumper.outputs.new_version }} | |
- name: Commit, tag, and push | |
# yamllint disable rule:line-length | |
# editorconfig-checker-disable | |
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 | |
# editorconfig-checker-enable | |
- name: Verify documentation site build | |
run: | | |
make install-docs-only-deps | |
make docs-build | |
- name: Publish build to PyPi | |
run: PYPI_TOKEN="${{ secrets.PYPI_TOKEN }}" make publish | |
- name: Set development project version | |
uses: sandstromviktor/toml-editor@2.0.0 | |
with: | |
file: pyproject.toml | |
key: tool.poetry.version | |
value: ${{ steps.bumper.outputs.next_dev_iteration }} | |
- name: Commit and push | |
# yamllint disable rule:line-length | |
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@v6 | |
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@v6 | |
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) |