Manual Release Prep: Branch & Version Bump #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Manual Release Prep: Branch & Version Bump" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_version: | |
| description: 'Release version (e.g. 1.2.3 or 1.2.3-rc)' | |
| required: true | |
| source_branch: | |
| description: 'Create branch from' | |
| required: true | |
| default: 'develop' | |
| target_branch: | |
| description: 'Pull Request to' | |
| required: true | |
| default: 'master' | |
| jobs: | |
| validate-input: | |
| name: Validate release_version format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check version matches semver or semver-rc | |
| run: | | |
| VER="${{ github.event.inputs.release_version }}" | |
| echo "→ release_version = $VER" | |
| if ! [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then | |
| echo "❌ release_version must be X.Y.Z or X.Y.Z-rc" | |
| exit 1 | |
| fi | |
| validate-branches: | |
| name: Validate branch names | |
| runs-on: ubuntu-latest | |
| needs: validate-input | |
| steps: | |
| - name: Checkout minimal repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Validate source branch exists | |
| run: | | |
| SRC="${{ github.event.inputs.source_branch }}" | |
| if ! git ls-remote --heads origin "$SRC" | grep -q "$SRC"; then | |
| echo "❌ source_branch '$SRC' does not exist on origin" | |
| exit 1 | |
| fi | |
| - name: Validate target branch exists | |
| run: | | |
| DST="${{ github.event.inputs.target_branch }}" | |
| if ! git ls-remote --heads origin "$DST" | grep -q "$DST"; then | |
| echo "❌ target_branch '$DST' does not exist on origin" | |
| exit 1 | |
| fi | |
| bump_and_branch: | |
| name: Create release branch & bump version | |
| runs-on: macos-15 | |
| needs: validate-branches | |
| outputs: | |
| release_branch: ${{ steps.bump.outputs.release_branch }} | |
| steps: | |
| - name: Checkout source branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.source_branch }} | |
| fetch-depth: 0 | |
| - name: Create release branch & bump version | |
| id: bump | |
| run: | | |
| VERSION="${{ github.event.inputs.release_version }}" | |
| SRC="${{ github.event.inputs.source_branch }}" | |
| REL="release/$VERSION" | |
| echo "→ Branching from $SRC into $REL" | |
| git checkout -b "$REL" | |
| echo "→ Running bump script on $REL" | |
| ./.github/git-release-branch-create.sh "$VERSION" | |
| echo "release_branch=$REL" >> $GITHUB_OUTPUT | |
| - name: Push release branch | |
| run: | | |
| git push origin "${{ steps.bump.outputs.release_branch }}" | |
| check_sdk_version: | |
| name: Check SDK Version | |
| runs-on: macos-15 | |
| needs: bump_and_branch | |
| steps: | |
| - name: Checkout the release branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.bump_and_branch.outputs.release_branch }} | |
| fetch-depth: 0 | |
| - name: Pull latest changes | |
| run: git pull | |
| - name: Validate sdkVersion | |
| run: | | |
| EXPECT="${{ github.event.inputs.release_version }}" | |
| SDK_VERSION=$(sed -n 's/^.*sdkVersion = "\(.*\)"/\1/p' SDKVersionProvider/SDKVersionProvider.swift) | |
| echo "→ Found in code: $SDK_VERSION, expected: $EXPECT" | |
| if [ "$SDK_VERSION" != "$EXPECT" ]; then | |
| echo "❌ SDK version does not match!" | |
| exit 1 | |
| fi | |
| create_pull_request: | |
| name: Create Pull Request | |
| runs-on: ubuntu-latest | |
| needs: [bump_and_branch, check_sdk_version] | |
| steps: | |
| - name: Create PR via GitHub CLI | |
| env: | |
| GH_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} | |
| SRC: ${{ needs.bump_and_branch.outputs.release_branch }} | |
| DST: ${{ github.event.inputs.target_branch }} | |
| REPO: ${{ github.repository }} | |
| run: | | |
| echo "→ Creating PR from $SRC into $DST" | |
| gh pr create \ | |
| --repo "$REPO" \ | |
| --base "$DST" \ | |
| --head "$SRC" \ | |
| --title "Release ${{ github.event.inputs.release_version }}" \ | |
| --body "Updates the release version to ${{ github.event.inputs.release_version }}. Automated PR: merge $SRC into $DST" |