-
Notifications
You must be signed in to change notification settings - Fork 6
feat: GitHub workflow–based release strategy (PAPI-4873) #551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| name: "Merge Release" | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| branch: | ||
| description: 'Release branch to merge (e.g. "release/v1.1.0"). Auto-detected if omitted.' | ||
| required: false | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| merge-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Generate GitHub App token | ||
| id: app-token | ||
| uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0 | ||
|
olivermeyer marked this conversation as resolved.
|
||
| with: | ||
| app-id: ${{ secrets.RELEASE_BOT_APP_ID }} | ||
| private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} | ||
|
|
||
| - name: Configure git identity | ||
| run: | | ||
| git config --global user.name "aignostics-release-bot[bot]" | ||
| git config --global user.email "aignostics-release-bot[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Checkout main | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| ref: main | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Resolve release branch | ||
| id: branch | ||
| env: | ||
| INPUT: ${{ inputs.branch }} | ||
| run: | | ||
| if [ -n "$INPUT" ]; then | ||
| BRANCH="$INPUT" | ||
| else | ||
| MATCHES=$(git ls-remote --heads origin 'release/v*' | awk '{print $2}' | sed 's|refs/heads/||') | ||
| if [ -z "$MATCHES" ]; then | ||
| echo "❌ No release/v* branches found." | ||
| exit 1 | ||
| fi | ||
| COUNT=$(echo "$MATCHES" | wc -l | tr -d ' ') | ||
| if [ "$COUNT" -gt 1 ]; then | ||
| echo "❌ Multiple release/v* branches found. Specify one explicitly:" | ||
| echo "$MATCHES" | ||
| exit 1 | ||
| fi | ||
| BRANCH="$MATCHES" | ||
| fi | ||
|
olivermeyer marked this conversation as resolved.
|
||
| # Validate branch name pattern | ||
| if ! echo "$BRANCH" | grep -qE '^release/v[0-9]+\.[0-9]+\.[0-9]+$'; then | ||
| echo "❌ Branch '${BRANCH}' does not match 'release/vX.Y.Z'. Aborting." | ||
| exit 1 | ||
| fi | ||
| # Validate branch exists on origin | ||
| if ! git ls-remote --exit-code --heads origin "$BRANCH" > /dev/null 2>&1; then | ||
| echo "❌ Branch '${BRANCH}' does not exist on origin. Aborting." | ||
| exit 1 | ||
| fi | ||
| echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT" | ||
| echo "✅ Using release branch: ${BRANCH}" | ||
|
|
||
| - name: Fetch remote | ||
| run: git fetch origin | ||
|
|
||
| - name: Merge release branch into main | ||
| run: | | ||
| BRANCH="${{ steps.branch.outputs.branch }}" | ||
| git merge --no-ff "origin/${BRANCH}" -m "chore: merge ${BRANCH} into main" | ||
|
|
||
|
Comment on lines
+75
to
+82
|
||
| - name: Push main | ||
| run: git push origin main | ||
|
|
||
| - name: Delete remote release branch | ||
| run: git push origin --delete "${{ steps.branch.outputs.branch }}" | ||
|
|
||
| - name: Print job summary | ||
| run: | | ||
| BRANCH="${{ steps.branch.outputs.branch }}" | ||
| cat >> "$GITHUB_STEP_SUMMARY" << EOF | ||
| ## ✅ Release merged | ||
|
|
||
| | | | | ||
| |---|---| | ||
| | **Branch** | \`${BRANCH}\` | | ||
| | **Merged into** | \`main\` | | ||
|
|
||
| The release branch has been merged into \`main\` and deleted. | ||
| EOF | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| name: "Prepare Release" | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version to release (e.g. "1.3.0")' | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| prepare-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Generate GitHub App token | ||
| id: app-token | ||
| uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0 | ||
|
olivermeyer marked this conversation as resolved.
|
||
| with: | ||
| app-id: ${{ secrets.RELEASE_BOT_APP_ID }} | ||
| private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} | ||
|
|
||
| - name: Configure git identity | ||
| run: | | ||
| git config --global user.name "aignostics-release-bot[bot]" | ||
| git config --global user.email "aignostics-release-bot[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Checkout main | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| ref: main | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0 | ||
| with: | ||
| version-file: "pyproject.toml" | ||
| enable-cache: true | ||
| cache-dependency-glob: uv.lock | ||
|
|
||
| - name: Validate version | ||
| id: version | ||
| env: | ||
| INPUT: ${{ inputs.version }} | ||
| run: | | ||
| # Must be an explicit x.y.z semver | ||
| if ! echo "$INPUT" | grep -qE '^\d+\.\d+\.\d+$'; then | ||
| echo "❌ Invalid version: '$INPUT'. Must be an explicit semver like '1.3.0'." | ||
| exit 1 | ||
| fi | ||
|
|
||
| CURRENT=$(cat VERSION) | ||
| BRANCH_NAME="release/v${INPUT}" | ||
| echo "new_version=${INPUT}" >> "$GITHUB_OUTPUT" | ||
| echo "branch_name=${BRANCH_NAME}" >> "$GITHUB_OUTPUT" | ||
| echo "current_version=${CURRENT}" >> "$GITHUB_OUTPUT" | ||
|
|
||
|
olivermeyer marked this conversation as resolved.
|
||
| - name: Validate release refs do not already exist | ||
| run: | | ||
| BRANCH_NAME="${{ steps.version.outputs.branch_name }}" | ||
| TAG_NAME="v${{ steps.version.outputs.new_version }}" | ||
|
|
||
| if git ls-remote --exit-code --heads origin "${BRANCH_NAME}" > /dev/null 2>&1; then | ||
| echo "::error::Release branch '${BRANCH_NAME}' already exists on origin." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if git ls-remote --exit-code --tags origin "${TAG_NAME}" > /dev/null 2>&1; then | ||
| echo "::error::Release tag '${TAG_NAME}' already exists on origin." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Create release branch | ||
| run: git checkout -b "${{ steps.version.outputs.branch_name }}" | ||
|
|
||
| - name: Bump version | ||
| run: uv run --frozen bump-my-version bump --new-version "${{ steps.version.outputs.new_version }}" | ||
|
|
||
| - name: Push release branch | ||
| run: git push -u origin "${{ steps.version.outputs.branch_name }}" | ||
|
|
||
| - name: Print next-steps summary | ||
| run: | | ||
| cat >> "$GITHUB_STEP_SUMMARY" << EOF | ||
| ## ✅ Release branch created | ||
|
|
||
| | | | | ||
| |---|---| | ||
| | **Branch** | \`${{ steps.version.outputs.branch_name }}\` | | ||
| | **Version** | ${{ steps.version.outputs.current_version }} → ${{ steps.version.outputs.new_version }} | | ||
|
|
||
| ### Next steps | ||
|
|
||
| 1. Point your Ketryx release to branch \`${{ steps.version.outputs.branch_name }}\` and collect approvals. | ||
| 2. Once approvals are in place, run: | ||
| \`\`\`bash | ||
| make publish-release | ||
| \`\`\` | ||
| 3. After the tag CI pipeline completes successfully and the package is published, merge back: | ||
| \`\`\`bash | ||
| make merge-release | ||
| \`\`\` | ||
| EOF | ||
Uh oh!
There was an error while loading. Please reload this page.