|
| 1 | +name: "Manual Release Prep: Branch & Version Bump" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_version: |
| 7 | + description: 'Release version (e.g. 1.2.3 or 1.2.3-rc)' |
| 8 | + required: true |
| 9 | + source_branch: |
| 10 | + description: 'Create branch from' |
| 11 | + required: true |
| 12 | + default: 'develop' |
| 13 | + target_branch: |
| 14 | + description: 'Pull Request to' |
| 15 | + required: true |
| 16 | + default: 'master' |
| 17 | + |
| 18 | +jobs: |
| 19 | + validate-input: |
| 20 | + name: Validate release_version format |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Check version matches semver or semver-rc |
| 24 | + run: | |
| 25 | + VER="${{ github.event.inputs.release_version }}" |
| 26 | + echo "→ release_version = $VER" |
| 27 | + if ! [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then |
| 28 | + echo "❌ release_version must be X.Y.Z or X.Y.Z-rc" |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | +
|
| 32 | + validate-branches: |
| 33 | + name: Validate branch names |
| 34 | + runs-on: ubuntu-latest |
| 35 | + needs: validate-input |
| 36 | + steps: |
| 37 | + - name: Checkout minimal repo |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
| 41 | + |
| 42 | + - name: Validate source branch exists |
| 43 | + run: | |
| 44 | + SRC="${{ github.event.inputs.source_branch }}" |
| 45 | + if ! git ls-remote --heads origin "$SRC" | grep -q "$SRC"; then |
| 46 | + echo "❌ source_branch '$SRC' does not exist on origin" |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Validate target branch exists |
| 51 | + run: | |
| 52 | + DST="${{ github.event.inputs.target_branch }}" |
| 53 | + if ! git ls-remote --heads origin "$DST" | grep -q "$DST"; then |
| 54 | + echo "❌ target_branch '$DST' does not exist on origin" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | +
|
| 58 | + bump_and_branch: |
| 59 | + name: Create release branch & bump version |
| 60 | + runs-on: macos-15 |
| 61 | + needs: validate-branches |
| 62 | + outputs: |
| 63 | + release_branch: ${{ steps.bump.outputs.release_branch }} |
| 64 | + steps: |
| 65 | + - name: Checkout source branch |
| 66 | + uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + ref: ${{ github.event.inputs.source_branch }} |
| 69 | + fetch-depth: 0 |
| 70 | + |
| 71 | + - name: Create release branch & bump version |
| 72 | + id: bump |
| 73 | + run: | |
| 74 | + VERSION="${{ github.event.inputs.release_version }}" |
| 75 | + SRC="${{ github.event.inputs.source_branch }}" |
| 76 | + REL="release/$VERSION" |
| 77 | +
|
| 78 | + echo "→ Branching from $SRC into $REL" |
| 79 | + git checkout -b "$REL" |
| 80 | +
|
| 81 | + echo "→ Running bump script on $REL" |
| 82 | + ./.github/git-release-branch-create.sh "$VERSION" |
| 83 | +
|
| 84 | + echo "release_branch=$REL" >> $GITHUB_OUTPUT |
| 85 | +
|
| 86 | + - name: Push release branch |
| 87 | + run: | |
| 88 | + git push origin "${{ steps.bump.outputs.release_branch }}" |
| 89 | +
|
| 90 | + check_sdk_version: |
| 91 | + name: Check SDK Version |
| 92 | + runs-on: macos-15 |
| 93 | + needs: bump_and_branch |
| 94 | + steps: |
| 95 | + - name: Checkout the release branch |
| 96 | + uses: actions/checkout@v4 |
| 97 | + with: |
| 98 | + ref: ${{ needs.bump_and_branch.outputs.release_branch }} |
| 99 | + fetch-depth: 0 |
| 100 | + |
| 101 | + - name: Pull latest changes |
| 102 | + run: git pull |
| 103 | + |
| 104 | + - name: Validate sdkVersion |
| 105 | + run: | |
| 106 | + EXPECT="${{ github.event.inputs.release_version }}" |
| 107 | + SDK_VERSION=$(sed -n 's/^.*sdkVersion = "\(.*\)"/\1/p' SDKVersionProvider/SDKVersionProvider.swift) |
| 108 | + echo "→ Found in code: $SDK_VERSION, expected: $EXPECT" |
| 109 | + if [ "$SDK_VERSION" != "$EXPECT" ]; then |
| 110 | + echo "❌ SDK version does not match!" |
| 111 | + exit 1 |
| 112 | + fi |
| 113 | +
|
| 114 | + create_pull_request: |
| 115 | + name: Create Pull Request |
| 116 | + runs-on: ubuntu-latest |
| 117 | + needs: [bump_and_branch, check_sdk_version] |
| 118 | + steps: |
| 119 | + - name: Create PR via GitHub CLI |
| 120 | + env: |
| 121 | + GH_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} |
| 122 | + SRC: ${{ needs.bump_and_branch.outputs.release_branch }} |
| 123 | + DST: ${{ github.event.inputs.target_branch }} |
| 124 | + REPO: ${{ github.repository }} |
| 125 | + run: | |
| 126 | + echo "→ Creating PR from $SRC into $DST" |
| 127 | + gh pr create \ |
| 128 | + --repo "$REPO" \ |
| 129 | + --base "$DST" \ |
| 130 | + --head "$SRC" \ |
| 131 | + --title "Release ${{ github.event.inputs.release_version }}" \ |
| 132 | + --body "Updates the release version to ${{ github.event.inputs.release_version }}. Automated PR: merge $SRC into $DST" |
0 commit comments