|
| 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 |
0 commit comments