Skip to content

release

release #24

Workflow file for this run

# Whenever we have a prerelease, we want to:
# * Build the sdist and attach it to the release.
# * Ensure that the docs will build.
# This should be triggered from the cmdline with `just prerelease`.
# Could also be triggered from the release page.
name: release
on:
workflow_dispatch:
inputs:
test:
type: boolean
description: "Run tests?"
required: true
default: true
docs:
type: boolean
description: "Test docs?"
required: true
default: true
permissions:
contents: write
jobs:
test-code:
if: github.ref == 'refs/heads/main' && github.event.inputs.test == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- run: python -m pip install ".[dev]"
- run: pytest ${{ env.test-dir }}
test-docs:
needs: [test-code]
if: github.ref == 'refs/heads/main' && github.event.inputs.docs == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- run: python -m pip install ".[dev]"
- run: mkdocs build --clean --strict
bump-build-docdeploy:
runs-on: ubuntu-latest
needs: [test-code, test-docs]
if: always() && !failure() && !cancelled() && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
fetch-tags: 1 # Essential to later commitizen
fetch-depth: 0 # Reccommended by the action
token: ${{ secrets.PUSH_ACCESS }}
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- run: git tag # Debug statement
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
id: cz
with:
github_token: ${{ secrets.PUSH_ACCESS }}
debug: true
- run: python -m pip install build
- run: python -m build --sdist
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
- run: python -m pip install ".[dev]"
- name: "Build and Deploy Docs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_version="${{ steps.cz.outputs.version }}"
latest_tag="$(git tag | sort --version-sort | tail -n1)"
echo "Updated version: ${current_version}"
echo "Latest tag: ${latest_tag}"
# Deploy this verison at any rate
if [ "$latest_tag" == "$current_version" ]; then
mike deploy \
--push \
--title "${current_version} (latest)" \
--update-aliases \
"${current_version}" \
"latest"
else
mike deploy --push "${current_version}"
fi
release:
needs: [bump-build-docdeploy]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: "Create Github Release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
--generate-notes \
--prerelease \
--verify-tag \
${{ github.event.release.tag_name }} "dist/*.tar.gz"
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1