Skip to content

Commit b8df490

Browse files
committed
chore(cicd): switched to python semantic release github action
also fixed the beta and production release workflow
1 parent c1e90df commit b8df490

File tree

2 files changed

+39
-46
lines changed

2 files changed

+39
-46
lines changed

.github/workflows/cd.yaml

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
name: Continuous Delivery of Python package
22

3+
run-name: ${{ inputs.production_release && 'Production Release' || 'Beta Release' }}
4+
35
on:
46
push:
57
branches:
68
- main
7-
- release/*
9+
paths-ignore:
10+
- "docs/**"
11+
workflow_dispatch:
12+
inputs:
13+
production_release:
14+
description: "Production release?"
15+
type: boolean
16+
required: true
17+
default: true
818

919
concurrency: release
1020

@@ -17,7 +27,7 @@ jobs:
1727
name: Semantic Release
1828
runs-on: ubuntu-latest
1929
permissions:
20-
# IMPORTANT: this permission is mandatory for trusted publishing
30+
# IMPORTANT: mandatory for trusted publishing and GitHub releases
2131
id-token: write
2232
contents: write
2333
packages: read
@@ -37,58 +47,45 @@ jobs:
3747
- name: Setup Python and algokit
3848
uses: ./.github/actions/setup-algokit-python
3949

40-
- name: Check if version is already released
41-
id: check_version
42-
run: |
43-
rc=0
44-
poetry run semantic-release --strict --noop version || rc=$?
45-
echo "return_code=$rc" >> $GITHUB_OUTPUT
46-
if [ $rc -ne 2 ]; then
47-
exit $rc
48-
fi
49-
50-
- name: pre-commit and pytest
51-
if: steps.check_version.outputs.return_code == '0'
50+
- name: Run tests and quality checks (dummy for testing)
5251
run: |
5352
set -o pipefail
5453
poetry run pre-commit run --all-files && git diff --exit-code
5554
poetry run pytest
5655
57-
- name: Set Git user as GitHub actions
58-
if: steps.check_version.outputs.return_code == '0'
59-
run: git config --global user.email "actions@github.com" && git config --global user.name "github-actions"
60-
61-
- name: Update release
62-
if: steps.check_version.outputs.return_code == '0'
63-
run: poetry run semantic-release --strict version
64-
env:
65-
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
66-
67-
- name: Create Wheel
68-
if: steps.check_version.outputs.return_code == '0'
69-
run: poetry build --format wheel
56+
- name: Get branch name
57+
shell: bash
58+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
59+
id: get_branch
7060

71-
- uses: actions/upload-artifact@v4 # upload artifacts so they are retained on the job
72-
if: steps.check_version.outputs.return_code == '0'
61+
- name: Python Semantic Release - Beta (non-prod)
62+
id: release-beta
63+
if: steps.get_branch.outputs.branch == 'main' && !inputs.production_release
64+
uses: python-semantic-release/python-semantic-release@v10.3.1
7365
with:
74-
path: dist
66+
github_token: ${{ steps.app-token.outputs.token }}
67+
prerelease: true
7568

76-
- name: Publish to GitHub
77-
if: steps.check_version.outputs.return_code == '0'
78-
run: poetry run semantic-release publish
79-
env:
80-
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
69+
- name: Python Semantic Release - Production
70+
id: release-prod
71+
if: steps.get_branch.outputs.branch == 'main' && inputs.production_release
72+
uses: python-semantic-release/python-semantic-release@v10.3.1
73+
with:
74+
github_token: ${{ steps.app-token.outputs.token }}
8175

8276
- name: Publish to PyPI
83-
if: steps.check_version.outputs.return_code == '0'
8477
uses: pypa/gh-action-pypi-publish@release/v1
78+
with:
79+
verbose: true
80+
8581

8682
publish-docs:
8783
name: Publish Docs
88-
# Don't publish canary docs
89-
if: github.ref != 'refs/heads/main'
84+
needs: release
85+
# Don't publish docs for beta releases from main
86+
if: inputs.production_release
9087
uses: ./.github/workflows/gh-pages.yaml
9188
permissions:
9289
contents: read
9390
pages: write
94-
id-token: write
91+
id-token: write

pyproject.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ py-algorand-sdk = "^2.9.1"
1111

1212
[tool.poetry.group.dev.dependencies]
1313
algokit-utils = "^4.1.0"
14-
python-semantic-release = "^10.2.0"
1514
mypy = "^1.17.1"
1615
ruff = "^0.12.8"
1716
pytest = "^8.4.1"
@@ -140,18 +139,15 @@ docs-dev = { shell = "poetry run poe docs-build && sphinx-autobuild docs docs/_b
140139

141140
[tool.semantic_release]
142141
version_toml = ["pyproject.toml:tool.poetry.version"]
142+
build_command = "pip install build && python -m build"
143143
commit_message = "{version}\n\n[skip ci] Automatically generated by python-semantic-release"
144144
tag_format = "v{version}"
145145
allow_zero_version = false
146146

147-
[tool.semantic_release.branches.stable]
148-
match = "release/*"
149-
prerelease = false
150-
151-
[tool.semantic_release.branches.canary]
147+
[tool.semantic_release.branches.main]
152148
match = "main"
153149
prerelease_token = "beta"
154-
prerelease = true
150+
prerelease = false
155151

156152
[tool.semantic_release.commit_parser_options]
157153
allowed_tags = [

0 commit comments

Comments
 (0)