Skip to content

Commit d601e16

Browse files
committed
feat: add prepare-release GitHub workflow and make target
1 parent 64544ab commit d601e16

2 files changed

Lines changed: 113 additions & 2 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: "Prepare Release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_part:
7+
description: 'Version part to bump ("patch", "minor", "major") or an explicit "x.y.z" version'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
prepare-release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Generate GitHub App token
19+
id: app-token
20+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
21+
with:
22+
app-id: ${{ secrets.RELEASE_BOT_APP_ID }}
23+
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
24+
25+
- name: Configure git identity
26+
run: |
27+
git config --global user.name "aignostics-release-bot[bot]"
28+
git config --global user.email "aignostics-release-bot[bot]@users.noreply.github.com"
29+
30+
- name: Checkout main
31+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
32+
with:
33+
token: ${{ steps.app-token.outputs.token }}
34+
ref: main
35+
fetch-depth: 0
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
39+
with:
40+
version-file: "pyproject.toml"
41+
enable-cache: true
42+
cache-dependency-glob: uv.lock
43+
44+
- name: Compute next version
45+
id: version
46+
run: |
47+
CURRENT=$(cat VERSION)
48+
INPUT="${{ inputs.version_part }}"
49+
50+
if echo "$INPUT" | grep -qE '^\d+\.\d+\.\d+$'; then
51+
NEW_VERSION="$INPUT"
52+
else
53+
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
54+
MINOR=$(echo "$CURRENT" | cut -d. -f2)
55+
PATCH=$(echo "$CURRENT" | cut -d. -f3)
56+
case "$INPUT" in
57+
major) NEW_VERSION="$((MAJOR + 1)).0.0" ;;
58+
minor) NEW_VERSION="${MAJOR}.$((MINOR + 1)).0" ;;
59+
patch) NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;;
60+
*) echo "❌ Invalid version_part: '$INPUT'. Use patch, minor, major, or x.y.z."; exit 1 ;;
61+
esac
62+
fi
63+
64+
BRANCH_NAME="release/v${NEW_VERSION}"
65+
echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
66+
echo "branch_name=${BRANCH_NAME}" >> "$GITHUB_OUTPUT"
67+
echo "current_version=${CURRENT}" >> "$GITHUB_OUTPUT"
68+
69+
- name: Create release branch
70+
run: git checkout -b "${{ steps.version.outputs.branch_name }}"
71+
72+
- name: Bump version
73+
run: uv run --frozen bump-my-version bump --new-version "${{ steps.version.outputs.new_version }}"
74+
75+
- name: Push release branch
76+
run: git push -u origin "${{ steps.version.outputs.branch_name }}"
77+
78+
- name: Print next-steps summary
79+
run: |
80+
cat >> "$GITHUB_STEP_SUMMARY" << EOF
81+
## ✅ Release branch created
82+
83+
| | |
84+
|---|---|
85+
| **Branch** | \`${{ steps.version.outputs.branch_name }}\` |
86+
| **Version** | ${{ steps.version.outputs.current_version }} → ${{ steps.version.outputs.new_version }} |
87+
88+
### Next steps
89+
90+
1. Point your Ketryx release to branch \`${{ steps.version.outputs.branch_name }}\` and collect approvals.
91+
2. Once approvals are in place, run:
92+
\`\`\`bash
93+
make publish-release
94+
\`\`\`
95+
3. After the tag CI pipeline completes successfully and the package is published, merge back:
96+
\`\`\`bash
97+
make merge-release
98+
\`\`\`
99+
EOF

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $(error Python version validation failed. See error message above.)
2121
endif
2222

2323
# Define all PHONY targets
24-
.PHONY: act all audit bump clean codegen dist dist_native docs docker_build gui_watch install lint lint_fix pre_commit_run_all profile setup test test_coverage_reset test_default test_e2e test_e2e_matrix test_integration test_integration_matrix test_long_running test_scheduled test_stress test_sequential test_unit test_unit_matrix test_very_long_running update_from_template
24+
.PHONY: act all audit bump clean codegen dist dist_native docs docker_build gui_watch install lint lint_fix pre_commit_run_all prepare-release profile setup test test_coverage_reset test_default test_e2e test_e2e_matrix test_integration test_integration_matrix test_long_running test_scheduled test_stress test_sequential test_unit test_unit_matrix test_very_long_running update_from_template
2525

2626

2727
# Main target i.e. default sessions defined in noxfile.py
@@ -103,6 +103,17 @@ test_coverage_reset:
103103
rm -rf .coverage
104104
rm -rf reports/coverage*
105105

106+
## Trigger the prepare-release GitHub workflow to create a release/vX.Y.Z branch
107+
## Usage: make prepare-release patch|minor|major|x.y.z
108+
prepare-release:
109+
$(eval VERSION_PART := $(filter-out $@,$(MAKECMDGOALS)))
110+
@if [ -z "$(VERSION_PART)" ]; then \
111+
echo "❌ Usage: make prepare-release patch|minor|major|x.y.z"; \
112+
exit 1; \
113+
fi
114+
gh workflow run prepare-release.yml --field version_part=$(VERSION_PART)
115+
@echo "Workflow triggered. Monitor at: https://github.com/aignostics/python-sdk/actions"
116+
106117
## Clean build artifacts and caches
107118
clean:
108119
rm -rf .mypy_cache
@@ -192,7 +203,8 @@ help:
192203
@echo " act - Run GitHub actions locally via act"
193204
@echo " all - Run all default nox sessions, i.e. lint, test, docs, audit"
194205
@echo " audit - Run security and license compliance audit"
195-
@echo " bump patch|minor|major|x.y.z - Bump version"
206+
@echo " bump patch|minor|major|x.y.z - Bump version (local, legacy)"
207+
@echo " prepare-release patch|minor|major|x.y.z - Create release/vX.Y.Z branch via GitHub workflow"
196208
@echo " clean - Clean build artifacts and caches"
197209
@echo " codegen - Download openapi.json from Aignostics platform, generate API code"
198210
@echo " dist - Build wheel and sdist into dist/"

0 commit comments

Comments
 (0)