From de5566ec2a941865bace735ae691979cd8191c5f Mon Sep 17 00:00:00 2001 From: Mark Chan <45706356+WindowsMEMZ@users.noreply.github.com> Date: Sat, 20 Jan 2024 14:11:04 +0800 Subject: [PATCH] Update and rename ui-test.yml to tf.yml --- .github/workflows/tf.yml | 222 ++++++++++++++++++++++++++++++++++ .github/workflows/ui-test.yml | 105 ---------------- 2 files changed, 222 insertions(+), 105 deletions(-) create mode 100644 .github/workflows/tf.yml delete mode 100644 .github/workflows/ui-test.yml diff --git a/.github/workflows/tf.yml b/.github/workflows/tf.yml new file mode 100644 index 000000000..600cbe0e0 --- /dev/null +++ b/.github/workflows/tf.yml @@ -0,0 +1,222 @@ +name: TestFlight Test Deploy + +on: + workflow_dispatch: + inputs: + psha: + required: true + repository: + required: true + lsha: + required: true + +jobs: + build: + name: Build & Deploy + runs-on: macos-13 + permissions: + contents: write + pull-requests: write + issues: write + repository-projects: write + checks: write + statuses: write + env: + ASCAPI_ISSUER_ID: ${{ secrets.ASCAPI_ISSUER_ID }} + ASCAPI_KEY_ID: ${{ secrets.ASCAPI_KEY_ID }} + ASCAPI_KEY: ${{ secrets.ASCAPI_KEY }} + FIN_STATUS: "error" + GH_TOKEN: ${{ github.token }} + steps: + - name: Update Check Status + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/${{ inputs.lsha }} \ + -f state='pending' \ + -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ + -f description='Preparing...' \ + -f context='TestFlight Internal Deploy' + + - name: Checkout + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.psha }} + + - name: Set Xcode Version + run: sudo xcode-select -s /Applications/Xcode_15.0.app + + - name: Prepare Version Folder + run: mkdir vers + + - name: Checkout Version Files + uses: actions/checkout@v3 + with: + ref: release-vers + persist-credentials: false + fetch-depth: 0 + path: vers + + - name: Change Project Version + run: | + read MVER < vers/ver.txt + MVER=$[MVER+1] + rm vers/ver.txt + echo $MVER >> vers/ver.txt + agvtool new-version -all $MVER + + - name: Commit Files + working-directory: vers + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -a -m "Updated versions" + + - name: Push Changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: release-vers + directory: vers + + - name: Install the Apple certificate and provisioning profile for Xcode + env: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + run: | + # create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + # import certificate and provisioning profile from secrets + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH + echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH + # create temporary keychain + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + # import certificate to keychain + security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH + security list-keychain -d user -s $KEYCHAIN_PATH + # apply provisioning profile + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles + + - name: Set Environment Varibles + run: | + CI=TRUE + CI_ARCHIVE_PATH=/Volumes/workspace/build.xcarchive + CI_BUNDLE_ID=com.darock.DarockBili + CI_PRODUCT=DarockBili + CI_PRODUCT_PLATFORM=iOS + CI_XCODEBUILD_ACTION=archive + CI_XCODE_PROJECT=DarockBili.xcodeproj + CI_XCODE_SCHEME=DarockBili + TMPDIR=$RUNNER_TEMP + + - name: Restore Caches + uses: actions/cache/restore@v3 + with: + key: ${{ runner.os }}-pr-deploy-cache- + path: ~/Library/Developer/Xcode/DerivedData + + - name: Update Check Status + run: | + echo "FIN_STATUS=failure" >> $GITHUB_ENV + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/${{ inputs.lsha }} \ + -f state='pending' \ + -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ + -f description='Resolving Package Dependencies...' \ + -f context='TestFlight Internal Deploy' + + - name: Resolve Package Dependencies + run: xcodebuild -resolvePackageDependencies -project ./DarockBili.xcodeproj -scheme 'DarockBili Watch App' + + - name: Update Check Status + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/${{ inputs.lsha }} \ + -f state='pending' \ + -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ + -f description='Archiving...' \ + -f context='TestFlight Internal Deploy' + + - name: Archive DarockBili App + env: + ASCAPI_KEY_ID: ${{ secrets.ASCAPI_KEY_ID }} + ASCAPI_ISSUER_ID: ${{ secrets.ASCAPI_ISSUER_ID }} + run: | + xcodebuild archive -project ./DarockBili.xcodeproj -scheme 'DarockBili Watch App' -archivePath ./build.xcarchive -IDEPostProgressNotifications=YES CODE_SIGN_IDENTITY=- AD_HOC_CODE_SIGNING_ALLOWED=YES CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=B57D8PP775 COMPILER_INDEX_STORE_ENABLE=NO + + - name: Get Current Time + id: current-time + run: echo "time=$(date +"%Y%m%d%H%M%S")" >> $GITHUB_OUTPUT + + - name: Save Caches + uses: actions/cache/save@v3 + with: + key: ${{ runner.os }}-pr-deploy-cache-${{ steps.current-time.outputs.time }} + path: ~/Library/Developer/Xcode/DerivedData + + - name: Update Check Status + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/${{ inputs.lsha }} \ + -f state='pending' \ + -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ + -f description='Exporting...' \ + -f context='TestFlight Internal Deploy' + + - name: Export IPA File + run: | + xcodebuild -exportArchive -archivePath ./build.xcarchive -exportPath ./ -exportOptionsPlist ./ExportOptions/app-store.plist -DVTProvisioningIsManaged=YES -DVTSkipCertificateValidityCheck=YES + + - name: Update Check Status + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/${{ inputs.lsha }} \ + -f state='pending' \ + -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ + -f description='Uploading...' \ + -f context='TestFlight Internal Deploy' + + - name: Prepare API Key + run: | + mkdir ~/.private_keys + echo "$ASCAPI_KEY" >> ~/.private_keys/AuthKey_${ASCAPI_KEY_ID}.p8 + + - name: Upload to App Store Connect + run: | + xcrun altool --upload-app -f ./DarockBili.ipa -t ios --apiKey $ASCAPI_KEY_ID --apiIssuer $ASCAPI_ISSUER_ID + echo "FIN_STATUS=success" >> $GITHUB_ENV + + - name: Update Check Status + if: always() + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/${{ inputs.lsha }} \ + -f state='${{ env.FIN_STATUS }}' \ + -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ + -f context='TestFlight Internal Deploy' + diff --git a/.github/workflows/ui-test.yml b/.github/workflows/ui-test.yml deleted file mode 100644 index dd5a84b39..000000000 --- a/.github/workflows/ui-test.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: UI Test Workflow - -on: - workflow_dispatch: - inputs: - psha: - required: true - repository: - required: true - lsha: - required: true - -jobs: - test: - name: UI Test - runs-on: macos-13 - permissions: - checks: write - statuses: write - env: - FIN_STATUS: "error" - GH_TOKEN: ${{ github.token }} - steps: - - name: Update Check Status - run: | - gh api \ - --method POST \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/${{ github.repository }}/statuses/${{ inputs.lsha }} \ - -f state='pending' \ - -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ - -f description='Testing...' \ - -f context='UI Test' - - - name: Checkout - uses: actions/checkout@v3 - with: - repository: ${{ inputs.repository }} - ref: ${{ inputs.psha }} - - - name: Set Xcode Version - run: sudo xcode-select -s /Applications/Xcode_15.0.app - - - name: Prepare Environment - run: | - brew install chargepoint/xcparse/xcparse - mkdir Caches - - - name: Restore Caches - uses: actions/cache/restore@v3 - with: - key: ${{ runner.os }}-ui-test-cache- - path: ~/Library/Developer/Xcode/DerivedData - - - name: Update Status Env - run: echo "FIN_STATUS=failure" >> $GITHUB_ENV - - - name: Resolve Package Dependencies - run: xcodebuild -resolvePackageDependencies -project ./DarockBili.xcodeproj -scheme 'DarockBili Watch App' - - - name: Build for Testing - run: xcodebuild build-for-testing -scheme 'DarockBili Watch App' -project ./DarockBili.xcodeproj -destination 'platform=watchOS Simulator,name=Apple Watch Series 7 (41mm),OS=10.0' -testProductsPath ./Caches/TestProducts.xctestproducts -testPlan WatchAppUITestPlan -IDEPostProgressNotifications=YES COMPILER_INDEX_STORE_ENABLE=NO -quiet - - - name: Get Current Time - id: current-time - run: echo "time=$(date +"%Y%m%d%H%M%S")" >> $GITHUB_OUTPUT - - - name: Save Caches - uses: actions/cache/save@v3 - with: - key: ${{ runner.os }}-ui-test-cache-${{ steps.current-time.outputs.time }} - path: ~/Library/Developer/Xcode/DerivedData - - - name: Run DarockBili Watch App UI Test - run: | - xcodebuild test-without-building -destination 'platform=watchOS Simulator,name=Apple Watch Series 7 (41mm),OS=10.0' -testPlan WatchAppUITestPlan -testProductsPath ./Caches/TestProducts.xctestproducts IDEPostProgressNotifications=YES -DTDKDisableSymbolCopying=YES - echo "FIN_STATUS=success" >> $GITHUB_ENV - - - name: Process Test Result - if: always() - run: | - mv ~/Library/Developer/Xcode/DerivedData/DarockBili-*/Logs/Test/Test-*.xcresult ./Caches/Test-1.xcresult - mkdir Caches/ExportFiles - xcparse -s ./Caches/Test-1.xcresult ./Caches/ExportFiles - - - name: Upload Test Attachments - if: always() - uses: actions/upload-artifact@v3 - with: - name: Test Attachments - path: ./Caches/ExportFiles - - - name: Update Check Status - if: always() - run: | - gh api \ - --method POST \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/${{ github.repository }}/statuses/${{ inputs.lsha }} \ - -f state='${{ env.FIN_STATUS }}' \ - -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ - -f context='UI Test' -