From 9e22b0b7f2da51a772767c59de33489efc45cdd2 Mon Sep 17 00:00:00 2001 From: bjornoleh <63544115+bjornoleh@users.noreply.github.com> Date: Wed, 12 Jun 2024 10:05:56 +0200 Subject: [PATCH 1/2] Create PR_test_build.yml Test-build pull requests with TestFlight. Usage: Add repository variables: Mandatory: - PR_NUMBER (Pull-request number in the nightscout/Trio repository) Optional: - ALTERNATIVE_BUNDLE_ID (the bundle ID which is associated with the TestFlight app you wish to build to) --- .github/workflows/PR_test_build.yml | 82 +++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/PR_test_build.yml diff --git a/.github/workflows/PR_test_build.yml b/.github/workflows/PR_test_build.yml new file mode 100644 index 000000000..eac786e9f --- /dev/null +++ b/.github/workflows/PR_test_build.yml @@ -0,0 +1,82 @@ +name: Test-build pull request +run-name: PR ${{ vars.PR_NUMBER }} +on: + workflow_dispatch: + +jobs: + # Builds Trio + build: + name: Build + runs-on: macos-14 + permissions: + contents: write + + steps: + # Uncomment to manually select Xcode version if needed + #- name: Select Xcode version + # run: "sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer" + + - name: Checkout Repo + uses: actions/checkout@v4 + with: + token: ${{ secrets.GH_PAT }} + submodules: recursive + fetch-depth: 1 + + - name: Checkout pull request for building + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + run: | + gh pr checkout ${{ vars.PR_NUMBER }} --repo nightscout/Trio --recurse-submodules + git submodule + + - name: Get ALTERNATIVE_BUNDLE_ID, or set empty value if it does not exist as a repository variable + run: echo "ALTERNATIVE_BUNDLE_ID=${{ vars.ALTERNATIVE_BUNDLE_ID }}" >> $GITHUB_ENV + + - name: Check if alternative bundle ID is set + if: ${{ env.ALTERNATIVE_BUNDLE_ID == '' }} + run: echo 'ALTERNATIVE_BUNDLE_ID is not set. Skipping BUNDLE_IDENTIFIER configuration.' + + - name: Use alternative bundle ID for PR test build + if: ${{ env.ALTERNATIVE_BUNDLE_ID != '' }} + run: echo 'BUNDLE_IDENTIFIER = ${{ env.ALTERNATIVE_BUNDLE_ID }}' >> Config.xcconfig + + # Patch Fastlane Match to not print tables + - name: Patch Match Tables + run: find /usr/local/lib/ruby/gems -name table_printer.rb | xargs sed -i "" "/puts(Terminal::Table.new(params))/d" + + # Install project dependencies + - name: Install project dependencies + run: bundle install + + # Build signed Trio IPA file + - name: Fastlane Build & Archive + run: bundle exec fastlane build_trio + env: + TEAMID: ${{ secrets.TEAMID }} + GH_PAT: ${{ secrets.GH_PAT }} + FASTLANE_KEY_ID: ${{ secrets.FASTLANE_KEY_ID }} + FASTLANE_ISSUER_ID: ${{ secrets.FASTLANE_ISSUER_ID }} + FASTLANE_KEY: ${{ secrets.FASTLANE_KEY }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + + # Upload to TestFlight + - name: Fastlane upload to TestFlight + run: bundle exec fastlane release + env: + TEAMID: ${{ secrets.TEAMID }} + GH_PAT: ${{ secrets.GH_PAT }} + FASTLANE_KEY_ID: ${{ secrets.FASTLANE_KEY_ID }} + FASTLANE_ISSUER_ID: ${{ secrets.FASTLANE_ISSUER_ID }} + FASTLANE_KEY: ${{ secrets.FASTLANE_KEY }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + + # Upload Build artifacts + - name: Upload build log, IPA and Symbol artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: | + artifacts + buildlog \ No newline at end of file From ad33090a64c75dd717ed6bcdb50822ba3780fa0d Mon Sep 17 00:00:00 2001 From: bjornoleh <63544115+bjornoleh@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:52:23 +0200 Subject: [PATCH 2/2] PR_test_build.yml: Start with checkout of nightscout/Trio dev --- .github/workflows/PR_test_build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/PR_test_build.yml b/.github/workflows/PR_test_build.yml index eac786e9f..788df0477 100644 --- a/.github/workflows/PR_test_build.yml +++ b/.github/workflows/PR_test_build.yml @@ -19,6 +19,8 @@ jobs: - name: Checkout Repo uses: actions/checkout@v4 with: + repository: nightscout/Trio + ref: dev token: ${{ secrets.GH_PAT }} submodules: recursive fetch-depth: 1 @@ -79,4 +81,4 @@ jobs: name: build-artifacts path: | artifacts - buildlog \ No newline at end of file + buildlog