|
| 1 | +name: Update middleware version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + middle_version: |
| 7 | + description: "Middleware version" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + task_name: |
| 11 | + description: "Task name (e.g. IOS-123)" |
| 12 | + required: false |
| 13 | + type: string |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + pull-requests: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + main: |
| 21 | + name: Update build cache |
| 22 | + runs-on: macos-15 |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v3 |
| 27 | + |
| 28 | + - name: Restore cache for local build folder |
| 29 | + uses: actions/cache/restore@v4 |
| 30 | + with: |
| 31 | + path: build |
| 32 | + key: build-local-tools-${{ github.sha }} |
| 33 | + restore-keys: | |
| 34 | + build-local-tools- |
| 35 | + |
| 36 | + - name: Prepare deps |
| 37 | + uses: ./.github/actions/prepare-deps |
| 38 | + |
| 39 | + - name: Xcode Cache |
| 40 | + uses: irgaly/xcode-cache@v1 |
| 41 | + with: |
| 42 | + key: xcode-cache-deriveddata-${{ github.sha }} |
| 43 | + restore-keys: xcode-cache-deriveddata- |
| 44 | + swiftpm-cache-key: spm-soucepackages-${{ hashFiles('Anytype.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }} |
| 45 | + swiftpm-cache-restore-keys: spm-soucepackages- |
| 46 | + cache-read-only: true |
| 47 | + |
| 48 | + - name: Setup Xcode |
| 49 | + uses: maxim-lobanov/[email protected] |
| 50 | + with: |
| 51 | + xcode-version: '16.1' |
| 52 | + |
| 53 | + - name: Setup tools |
| 54 | + run: make setup-env |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + |
| 58 | + - name: Update Middleware Version |
| 59 | + run: make set-middle-version v=${{ inputs.middle_version }} |
| 60 | + |
| 61 | + - name: Download Middleware and Generate Files |
| 62 | + run: make setup-middle |
| 63 | + env: |
| 64 | + MIDDLEWARE_TOKEN: ${{ secrets.MIDDLEWARE_TOKEN }} |
| 65 | + |
| 66 | + - name: Update git config |
| 67 | + uses: ./.github/actions/update-git-config |
| 68 | + |
| 69 | + - name: Create Commit |
| 70 | + id: commit |
| 71 | + run: | |
| 72 | + BRANCH_NAME="${{ inputs.task_name != '' && format('{0}-update-middleware-{1}', inputs.task_name, inputs.middle_version) || format('update-middleware-{0}', inputs.middle_version) }}" |
| 73 | + COMMIT_MESSAGE="${{ inputs.task_name != '' && format('{0} Automation: Update middleware to {1}', inputs.task_name, inputs.middle_version) || format('Automation: Update middleware to {0}', inputs.middle_version) }}" |
| 74 | + |
| 75 | + # Delete local branch if exists |
| 76 | + git branch -D $BRANCH_NAME || true |
| 77 | + # Delete remote branch if exists |
| 78 | + git push origin --delete $BRANCH_NAME || true |
| 79 | + # Create new branch |
| 80 | + git checkout -b $BRANCH_NAME |
| 81 | + git add . |
| 82 | + git commit -m "$COMMIT_MESSAGE" --no-verify |
| 83 | + |
| 84 | + echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT |
| 85 | + echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT |
| 86 | + env: |
| 87 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + |
| 89 | + - name: Run unit tests |
| 90 | + run: bundle exec fastlane tests skip_notify:true |
| 91 | + env: |
| 92 | + FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT: 900 |
| 93 | + FASTLANE_XCODE_LIST_TIMEOUT: 900 |
| 94 | + |
| 95 | + - name: Create and Merge PR |
| 96 | + run: | |
| 97 | + git push origin ${{ steps.commit.outputs.branch_name }} --no-verify |
| 98 | + |
| 99 | + PR_BODY="This PR updates middleware to version ${{ inputs.middle_version }}" |
| 100 | + gh pr create --title "${{ steps.commit.outputs.commit_message }}" --body "$PR_BODY" --base ${{ github.ref_name }} |
| 101 | + gh pr merge ${{ steps.commit.outputs.branch_name }} --squash --delete-branch |
| 102 | + env: |
| 103 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 104 | + |
0 commit comments