Skip to content

release

release #47

Workflow file for this run

name: release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
test-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- run: python -m pip install ".[dev]"
- run: mkdocs build --clean --strict
# Need to ensure we bump before we create any artifacts
bump:
runs-on: ubuntu-latest
needs: [test-code, test-docs]
steps:
- uses: actions/checkout@v4
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
changelog_increment_filename: changelog-increment.md
- run: |
mkdir changelog-output
mv changelog-increment.md changelog-output/changelog-increment.md
cat changelog-output/changelog-increment.md
- name: Upload the changelog
uses: actions/upload-artifact@v3
with:
name: changelog
path: changelog-output
build:
needs: [bump]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
fetch-tags: 1
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- run: python -m pip install build
- run: python -m build --sdist
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: build-output
path: dist
docs:
needs: [bump]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
fetch-tags: 1
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- run: python -m pip install ".[dev]"
- name: "Deploy Docs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name doc-bot
git config user.email [email protected]
current_version=$(git tag | sort --version-sort | tail -n 1)
# This block will rename previous retitled versions
retitled_versions=$(mike list -j | jq ".[] | select(.title != .version) | .version" | tr -d '"')
for version in $retitled_versions; do
mike retitle "${version}" "${version}"
done
echo "Deploying docs for ${current_version}"
mike deploy \
--push \
--title "${current_version} (latest)" \
--update-aliases \
"${current_version}" \
"latest"
release:
needs: [docs, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
fetch-tags: 1
fetch-depth: 0
- name: Download the build artifiact
uses: actions/download-artifact@v3
with:
name: build-output
path: dist
- run: ls -R dist
- name: Download the changelog
uses: actions/download-artifact@v3
with:
name: changelog
path: changelog-output
- run: |
ls -R changelog-output
mv changelog-output/changelog-increment.md changelog-increment.md
cat changelog-increment.md
- name: "Create Github Release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_version=$(git tag | sort --version-sort | tail -n 1)
echo "Release for ${current_version}"
gh release create \
--generate-notes \
--notes-file changelog-increment.md \
--verify-tag \
"${current_version}" "dist/amltk-${current_version}.tar.gz"
publish:
needs: [release]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
- uses: actions/download-artifact@v3
with:
name: build-output
path: dist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1