|
| 1 | +name: Prepare Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + react_native_version: |
| 7 | + description: 'React Native Version (x.y.z)' |
| 8 | + required: true |
| 9 | + pattern: '^\d+\.\d+\.\d+$' |
| 10 | + proxy_version: |
| 11 | + description: 'Airship Framework Proxy Version (x.y.z)' |
| 12 | + required: true |
| 13 | + pattern: '^\d+\.\d+\.\d+$' |
| 14 | + ios_version: |
| 15 | + description: 'iOS SDK Version (x.y.z)' |
| 16 | + required: false |
| 17 | + pattern: '^\d+\.\d+\.\d+$' |
| 18 | + android_version: |
| 19 | + description: 'Android SDK Version (x.y.z)' |
| 20 | + required: false |
| 21 | + pattern: '^\d+\.\d+\.\d+$' |
| 22 | + draft: |
| 23 | + description: 'Create as draft PR' |
| 24 | + type: boolean |
| 25 | + default: false |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: write |
| 29 | + pull-requests: write |
| 30 | + |
| 31 | +jobs: |
| 32 | + prepare-release: |
| 33 | + runs-on: macos-latest |
| 34 | + timeout-minutes: 15 |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + ref: main |
| 40 | + fetch-depth: 0 |
| 41 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Run Updates |
| 44 | + run: | |
| 45 | + ./scripts/update_version.sh "${{ github.event.inputs.react_native_version }}" || exit 1 |
| 46 | + ./scripts/update_proxy_version.sh "${{ github.event.inputs.proxy_version }}" || exit 1 |
| 47 | + if [ -n "${{ github.event.inputs.ios_version }}" ] && [ -n "${{ github.event.inputs.android_version }}" ]; then |
| 48 | + ./scripts/update_changelog.sh "${{ github.event.inputs.react_native_version }}" "${{ github.event.inputs.proxy_version }}" "${{ github.event.inputs.ios_version }}" "${{ github.event.inputs.android_version }}" || exit 1 |
| 49 | + fi |
| 50 | +
|
| 51 | + - name: Verify Changes |
| 52 | + id: verify |
| 53 | + run: | |
| 54 | + CHANGED_FILES=$(git diff --name-only) |
| 55 | + if [ -z "$CHANGED_FILES" ]; then |
| 56 | + echo "No files were changed!" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + echo "Changed files:" |
| 60 | + echo "$CHANGED_FILES" |
| 61 | + echo "changed_files<<EOF" >> $GITHUB_OUTPUT |
| 62 | + echo "$CHANGED_FILES" >> $GITHUB_OUTPUT |
| 63 | + echo "EOF" >> $GITHUB_OUTPUT |
| 64 | +
|
| 65 | + - name: Create Pull Request |
| 66 | + id: create-pr |
| 67 | + uses: peter-evans/create-pull-request@v5 |
| 68 | + with: |
| 69 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + commit-message: | |
| 71 | + Release ${{ github.event.inputs.react_native_version }} |
| 72 | + title: "Release ${{ github.event.inputs.react_native_version }}" |
| 73 | + body: | |
| 74 | + - Framework Proxy: ${{ github.event.inputs.proxy_version }} |
| 75 | + - iOS SDK: ${{ github.event.inputs.ios_version }} |
| 76 | + - Android SDK: ${{ github.event.inputs.android_version }} |
| 77 | +
|
| 78 | + ## Changed Files: |
| 79 | + ``` |
| 80 | + ${{ steps.verify.outputs.changed_files }} |
| 81 | + ``` |
| 82 | + branch: release-${{ github.event.inputs.react_native_version }} |
| 83 | + base: main |
| 84 | + labels: | |
| 85 | + release |
| 86 | + automated pr |
| 87 | + draft: ${{ github.event.inputs.draft }} |
| 88 | + delete-branch: true |
| 89 | + |
| 90 | + - name: Handle Success |
| 91 | + if: success() && steps.create-pr.outputs.pull-request-number |
| 92 | + run: | |
| 93 | + echo "Pull request created successfully" |
| 94 | + echo "PR Number: ${{ steps.create-pr.outputs.pull-request-number }}" |
| 95 | + echo "PR URL: ${{ steps.create-pr.outputs.pull-request-url }}" |
| 96 | +
|
| 97 | + - name: Slack Notification (Success) |
| 98 | + if: success() && steps.create-pr.outputs.pull-request-number |
| 99 | + uses: homoluctus/slatify@master |
| 100 | + with: |
| 101 | + type: success |
| 102 | + job_name: ":tada: React Native plugin release pull request generated :tada:" |
| 103 | + message: "@mobile-team A new React Native plugin release pull request for (v${{ github.event.inputs.react_native_version }}) is ready! :rocket:" |
| 104 | + url: ${{ secrets.MOBILE_SLACK_WEBHOOK }} |
| 105 | + |
| 106 | + - name: Handle Failure |
| 107 | + if: failure() |
| 108 | + run: | |
| 109 | + echo "::error::Release preparation failed. Please check the logs above for details." |
| 110 | + exit 1 |
| 111 | +
|
| 112 | + - name: Slack Notification (Failure) |
| 113 | + if: failure() |
| 114 | + uses: homoluctus/slatify@master |
| 115 | + with: |
| 116 | + type: failure |
| 117 | + job_name: ":disappointed: React Native Plugin Release Failed :disappointed:" |
| 118 | + message: "@crow The release preparation failed. Please check the workflow logs. :sob:" |
| 119 | + url: ${{ secrets.MOBILE_SLACK_WEBHOOK }} |
0 commit comments