|
| 1 | +name: Generate Release |
| 2 | +run-name: Generate Release ${{ fromJSON(inputs.major) }}.${{ fromJSON(inputs.minor) }}.${{ fromJSON(inputs.patch) }} |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + major: |
| 8 | + description: 'Major version' |
| 9 | + required: true |
| 10 | + default: '1' |
| 11 | + type: choice |
| 12 | + options: |
| 13 | + - '1' |
| 14 | + - '2' |
| 15 | + minor: |
| 16 | + description: 'Minor version' |
| 17 | + required: true |
| 18 | + type: number |
| 19 | + patch: |
| 20 | + description: 'Patch version' |
| 21 | + required: true |
| 22 | + type: number |
| 23 | + |
| 24 | +jobs: |
| 25 | + bump-version-and-raise-pr: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + contents: write |
| 29 | + pull-requests: write |
| 30 | + env: |
| 31 | + version: ${{ fromJSON(inputs.major) }}.${{ fromJSON(inputs.minor) }}.${{ fromJSON(inputs.patch) }} |
| 32 | + branch: ${{ inputs.major == 2 && 'develop' || 'develop_1.x' }} |
| 33 | + target: ${{ inputs.major == 2 && 'main' || 'main_1.x' }} |
| 34 | + steps: |
| 35 | + - name: Check minor has no decimals |
| 36 | + run: ${{ !contains(fromJSON(inputs.minor), '.') }} |
| 37 | + |
| 38 | + - name: Check patch has no decimals |
| 39 | + run: ${{ !contains(fromJSON(inputs.patch), '.') }} |
| 40 | + |
| 41 | + - name: Checkout ${{ env.target }} |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + ref: ${{ env.target }} |
| 45 | + fetch-depth: 0 |
| 46 | + |
| 47 | + - name: Ensure tag does not exist |
| 48 | + run: | |
| 49 | + if git show-ref --tags --verify --quiet "refs/tags/$version"; then |
| 50 | + echo "::error::Tag $version exists" && exit 1 |
| 51 | + else |
| 52 | + echo "Tag $version does not exist" |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Ensure branch does not exist |
| 56 | + run: | |
| 57 | + if git show-ref --verify --quiet "refs/remotes/origin/release/$version"; then |
| 58 | + echo "::error::Release branch release/$version exists" && exit 1 |
| 59 | + else |
| 60 | + echo "Release branch release/$version does not exist" |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Merge in ${{ env.branch }} |
| 64 | + run: | |
| 65 | + git config user.name github-actions |
| 66 | + git config user.email [email protected] |
| 67 | + git merge origin/${{ env.branch }} |
| 68 | + |
| 69 | + - name: Update version in txt file |
| 70 | + run: sed -i "s/[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}/$version/" ./mambaSharedFramework/Resources/version.txt |
| 71 | + |
| 72 | + - name: Update version in xcodeproj file |
| 73 | + run: sed -i "s/MARKETING_VERSION = [0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\};/MARKETING_VERSION = $version;/" ./mamba.xcodeproj/project.pbxproj |
| 74 | + |
| 75 | + - name: Update version in podspec file |
| 76 | + run: sed -i "s/= \"[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\"/= \"$version\"/" ./mamba.podspec |
| 77 | + |
| 78 | + - name: Create pull request |
| 79 | + uses: peter-evans/create-pull-request@v7 |
| 80 | + with: |
| 81 | + title: Release ${{ env.version }} |
| 82 | + commit-message: Bump version to ${{ env.version }} |
| 83 | + branch: release/${{ env.version }} |
| 84 | + body: | |
| 85 | + Automated version bump to ${{ env.version }} generated by [create-pull-request][1]. |
| 86 | + |
| 87 | + [1]: https://github.com/peter-evans/create-pull-request |
0 commit comments