|
| 1 | +name: Create Release Pull Request |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + nextVersion: |
| 7 | + description: "Next version (eg. 1.0.0)" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + create_release_pull_request: |
| 17 | + name: Create Release Pull Request |
| 18 | + runs-on: ubuntu-latest |
| 19 | + timeout-minutes: 30 |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Find HEAD commit |
| 25 | + id: head |
| 26 | + run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 27 | + |
| 28 | + - name: Build changelog on "main" |
| 29 | + id: changelog |
| 30 | + uses: mikepenz/release-changelog-builder-action@v4 |
| 31 | + with: |
| 32 | + configuration: ".github/workflows/configs/changelog-config.json" |
| 33 | + # Listing PRs from the last tag to the HEAD commit |
| 34 | + toTag: ${{ steps.head.outputs.sha }} |
| 35 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Prepare variables |
| 38 | + run: | |
| 39 | + filename=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj \; | head -n 1) |
| 40 | + release_version=$(sed -n 's/.*MARKETING_VERSION *= *\([^;]*\);.*/\1/p' "$filename.xcodeproj/project.pbxproj" | head -n 1 | sed 's/^[^=]*=\s*//' | tr -d ' ') |
| 41 | + echo $release_version |
| 42 | + echo "RELEASE_VERSION=$release_version" >> "$GITHUB_ENV" |
| 43 | + echo "${{ steps.changelog.outputs.changelog }}" | sed 's/"/\\"/g' > escaped-changelog.txt |
| 44 | +
|
| 45 | + - name: Create Release branch |
| 46 | + uses: peterjgrainger/[email protected] |
| 47 | + env: |
| 48 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + with: |
| 50 | + branch: release/${{ env.RELEASE_VERSION }} |
| 51 | + |
| 52 | + - name: Create pull request |
| 53 | + run: gh pr create --draft -B main -H release/${{ env.RELEASE_VERSION }} -t 'Release - ${{ env.RELEASE_VERSION }}' -b "$(cat escaped-changelog.txt)" |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + |
| 57 | + create_bump_version_pull_request: |
| 58 | + name: Create Bump Version Pull Request |
| 59 | + runs-on: macos-latest |
| 60 | + timeout-minutes: 30 |
| 61 | + permissions: |
| 62 | + contents: write |
| 63 | + pull-requests: write |
| 64 | + steps: |
| 65 | + - name: Create Bump Version branch |
| 66 | + uses: peterjgrainger/[email protected] |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + with: |
| 70 | + branch: chore/bump-version-to-${{ github.event.inputs.nextVersion }} |
| 71 | + |
| 72 | + - name: Checkout code |
| 73 | + uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + ref: chore/bump-version-to-${{ github.event.inputs.nextVersion }} |
| 76 | + |
| 77 | + - name: Bump version |
| 78 | + run: | |
| 79 | + filename=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj \; | head -n 1) |
| 80 | + sed -i "" "s/MARKETING_VERSION = .*/MARKETING_VERSION = ${{ github.event.inputs.nextVersion }};/g" $filename.xcodeproj/project.pbxproj |
| 81 | + |
| 82 | + - name: Set up Git |
| 83 | + run: | |
| 84 | + git config --global user.name 'Github Actions' |
| 85 | + git config --global user.email '[email protected]' |
| 86 | +
|
| 87 | + - name: Commit changes |
| 88 | + run: | |
| 89 | + git add . |
| 90 | + git commit -m "[Chore] Bump version to ${{ github.event.inputs.nextVersion }}" |
| 91 | + git push origin HEAD |
| 92 | +
|
| 93 | + - name: Create pull request |
| 94 | + run: | |
| 95 | + echo -e "## What happened 👀\n\nBump version to ${{ github.event.inputs.nextVersion }}" > body |
| 96 | + export body=$(cat body) ; gh pr create --draft -B develop -H chore/bump-version-to-${{ github.event.inputs.nextVersion }} -t '[Chore] Bump version to ${{ github.event.inputs.nextVersion }}' -b "$body" |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments