chore: utils-v3 migration (#18) #18
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: Continuous Delivery of Python package | |
on: | |
push: | |
branches: | |
- main | |
- release/* | |
concurrency: release | |
permissions: | |
contents: write | |
packages: read | |
jobs: | |
release: | |
name: Semantic Release | |
runs-on: ubuntu-latest | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
contents: write | |
packages: read | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.BOT_ID }} | |
private-key: ${{ secrets.BOT_SK }} | |
- uses: actions/checkout@v4 | |
with: | |
# Fetch entire repository history so we can determine version number from it | |
fetch-depth: 0 | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Setup Python and algokit | |
uses: ./.github/actions/setup-algokit-python | |
- name: Check if version is already released | |
id: check_version | |
run: | | |
rc=0 | |
poetry run semantic-release --strict --noop version || rc=$? | |
echo "return_code=$rc" >> $GITHUB_OUTPUT | |
if [ $rc -ne 2 ]; then | |
exit $rc | |
fi | |
- name: pre-commit and pytest | |
if: steps.check_version.outputs.return_code == '0' | |
run: | | |
set -o pipefail | |
poetry run pre-commit run --all-files && git diff --exit-code | |
poetry run pytest | |
- name: Set Git user as GitHub actions | |
if: steps.check_version.outputs.return_code == '0' | |
run: git config --global user.email "[email protected]" && git config --global user.name "github-actions" | |
- name: Update release | |
if: steps.check_version.outputs.return_code == '0' | |
run: poetry run semantic-release --strict version | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
- name: Create Wheel | |
if: steps.check_version.outputs.return_code == '0' | |
run: poetry build --format wheel | |
- uses: actions/upload-artifact@v4 # upload artifacts so they are retained on the job | |
if: steps.check_version.outputs.return_code == '0' | |
with: | |
path: dist | |
- name: Publish to GitHub | |
if: steps.check_version.outputs.return_code == '0' | |
run: poetry run semantic-release publish | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
- name: Publish to PyPI | |
if: steps.check_version.outputs.return_code == '0' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
publish-docs: | |
name: Publish Docs | |
# Don't publish canary docs | |
if: github.ref != 'refs/heads/main' | |
uses: ./.github/workflows/gh-pages.yaml | |
permissions: | |
contents: read | |
pages: write | |
id-token: write |