From 2a5c231d3d35bb344eb7f77caf95010785ee777b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 3 Dec 2021 15:31:19 +0100 Subject: [PATCH] Polish release workflow (#207) * Do run tests in beta - Test and build app in same lane - Run tests with swift directly - Set timeout on build only - Set GYM_OUTPUT_DIRECTORY inline - Fix bad build number, broken in db075eb - Ignore updates to CHANGELOG for testing - Drop unnecessary exports - Drop unnecessary test env - Drop unused PLATFORM .env.* variable * Work around gym issues in CI - Set custom build paths for proper clean-up - Disable xcpretty (seems to hang job) * Add descriptive names to workflow - Rename beta to release - Add job names * Optimize release workflow - Use a matrix for multiplatform build - Only preinstall platform-specific certificates - Output app version/build early for job reuse - Do not depend app review on public beta release - Pull latest commits before pushing/tagging In release, ci/* scripts require Ruby. Make version an argument of the commit-release.sh script to fix dependency. * Import secret to notify external testers or not * [ci skip] Add CHANGELOG preface in local scripts * [ci skip] Update links to release via CI --- .beta-base | 1 + .env | 1 - .env.beta | 1 - .env.ios | 1 - .env.mac | 1 - .github/actions/prepare-build-app/action.yml | 6 +- .github/workflows/{beta.yml => release.yml} | 118 ++++++++++-------- .github/workflows/test.yml | 21 ++-- .gitignore | 1 + Gemfile.lock | 10 +- .../xcschemes/Passepartout-iOS.xcscheme | 10 ++ .../xcschemes/Passepartout-macOS.xcscheme | 10 ++ Passepartout/App/iOS/CHANGELOG.md | 4 + Passepartout/App/macOS/CHANGELOG.md | 4 + PassepartoutCore/Sources/PassepartoutCore/API | 2 +- README.md | 2 +- Submodules/fastlane-ci-templates | 2 +- fastlane/Fastfile | 5 - fastlane/Gymfile | 7 +- scripts/ci/commit-release.sh | 6 +- scripts/commit-beta.sh | 8 +- scripts/local/build-app.sh | 3 +- scripts/local/review-app.sh | 2 +- scripts/local/submit-app.sh | 8 +- scripts/local/test-app.sh | 7 ++ 25 files changed, 147 insertions(+), 94 deletions(-) create mode 100644 .beta-base rename .github/workflows/{beta.yml => release.yml} (56%) create mode 100755 scripts/local/test-app.sh diff --git a/.beta-base b/.beta-base new file mode 100644 index 00000000..e255a855 --- /dev/null +++ b/.beta-base @@ -0,0 +1 @@ +1072 diff --git a/.env b/.env index ca0e8122..dff1bf71 100644 --- a/.env +++ b/.env @@ -1,4 +1,3 @@ # constant (fastlane) LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" -BASE_BUILD_NUMBER="1071" diff --git a/.env.beta b/.env.beta index 42e6610d..d22bbd24 100644 --- a/.env.beta +++ b/.env.beta @@ -3,7 +3,6 @@ MATCH_TYPE="appstore" GYM_EXPORT_METHOD="app-store" GYM_SKIP_PACKAGE_PKG="false" SCAN_PACKAGE_PATH="PassepartoutCore" -SCAN_SCHEME="PassepartoutCore" DEMO_ACCOUNT_REQUIRED="true" PILOT_DISTRIBUTE_EXTERNAL="true" PILOT_BETA_APP_DESCRIPTION="Passepartout is a non-official, user-friendly OpenVPNĀ® client." diff --git a/.env.ios b/.env.ios index 07fb4ae6..6efce560 100644 --- a/.env.ios +++ b/.env.ios @@ -1,4 +1,3 @@ -PLATFORM="ios" APP_ROOT="Passepartout/App/iOS" MATCH_PLATFORM="ios" GYM_SCHEME="Passepartout-iOS" diff --git a/.env.mac b/.env.mac index 2d9f80b4..e0c2151f 100644 --- a/.env.mac +++ b/.env.mac @@ -1,4 +1,3 @@ -PLATFORM="mac" APP_ROOT="Passepartout/App/macOS" MATCH_PLATFORM="macos" MATCH_ADDITIONAL_CERT_TYPES="mac_installer_distribution" diff --git a/.github/actions/prepare-build-app/action.yml b/.github/actions/prepare-build-app/action.yml index c188c0c4..24e4234e 100644 --- a/.github/actions/prepare-build-app/action.yml +++ b/.github/actions/prepare-build-app/action.yml @@ -1,4 +1,8 @@ name: 'Prepare build environment' +inputs: + platform: + description: 'Platform for match' + required: true runs: using: 'composite' steps: @@ -11,4 +15,4 @@ runs: - shell: bash run: | scripts/ci/recognize-match-hostname.sh - bundle exec fastlane preinstall_development_certs + bundle exec fastlane --env ${{ inputs.platform }} preinstall_development_certs diff --git a/.github/workflows/beta.yml b/.github/workflows/release.yml similarity index 56% rename from .github/workflows/beta.yml rename to .github/workflows/release.yml index bb648250..dc7a2d42 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Public Beta +name: Release on: push: @@ -21,52 +21,74 @@ env: PILOT_GROUPS: ${{ secrets.PILOT_GROUPS }} PILOT_BETA_APP_FEEDBACK: ${{ secrets.PILOT_BETA_APP_FEEDBACK }} PILOT_BETA_APP_REVIEW_INFO: ${{ secrets.PILOT_BETA_APP_REVIEW_INFO }} + PILOT_NOTIFY_EXTERNAL_TESTERS: ${{ secrets.PILOT_NOTIFY_EXTERNAL_TESTERS }} CHANGELOG_PREFACE: ${{ secrets.CHANGELOG_PREFACE }} jobs: - build_upload_ios: + build_upload: + name: Upload to ASC runs-on: macos-11 - timeout-minutes: 60 + strategy: + fail-fast: true + matrix: + name: ["iOS", "macOS"] + include: + - name: "iOS" + platform: "ios" + use_version: true + - name: "macOS" + platform: "mac" + env: + PLATFORM: ${{ matrix.platform }} + GYM_OUTPUT_DIRECTORY: "dist/${{ matrix.platform }}" steps: - uses: actions/checkout@v2 with: submodules: true - name: Prepare build uses: ./.github/actions/prepare-build-app - - name: Build iOS (.ipa) - run: | - bundle exec fastlane --env ios,beta create_archive - - name: Submit to TestFlight - run: | - export PILOT_CHANGELOG=`ci/build-changelog.sh ios` - export PILOT_IPA="dist/ios/Passepartout.ipa" - bundle exec fastlane --env ios,beta store_beta - build_upload_mac: - runs-on: macos-11 - timeout-minutes: 60 - steps: - - uses: actions/checkout@v2 with: - submodules: true - - name: Prepare build - uses: ./.github/actions/prepare-build-app - - name: Build macOS (.pkg) + platform: ${{ matrix.platform }} + - name: Store app version + id: app_version + if: ${{ matrix.use_version }} run: | - bundle exec fastlane --env mac,beta create_archive + VERSION=`ci/version-number.sh $PLATFORM` + BUILD=`ci/build-number.sh $PLATFORM` + echo "::set-output name=version::$VERSION" + echo "::set-output name=build::$BUILD" + - name: Run tests + run: | + cd PassepartoutCore + swift test + - name: Build ${{ matrix.name }} app + timeout-minutes: 15 + run: | + bundle exec fastlane --env $PLATFORM,beta test_and_build_app test:false - name: Submit to TestFlight run: | - export PILOT_CHANGELOG=`ci/build-changelog.sh mac` - export PILOT_PKG="dist/mac/Passepartout.pkg" - bundle exec fastlane --env mac,beta store_beta - release_public_beta: + if [ $PLATFORM == "ios" ]; then + export PILOT_IPA="$GYM_OUTPUT_DIRECTORY/Passepartout.ipa" + else + export PILOT_PKG="$GYM_OUTPUT_DIRECTORY/Passepartout.pkg" + fi + export PILOT_CHANGELOG=`ci/build-changelog.sh $PLATFORM` + bundle exec fastlane --env $PLATFORM,beta run pilot + outputs: + version: ${{ steps.app_version.outputs.version }} + build: ${{ steps.app_version.outputs.build }} + distribute_public_beta: + name: Distribute Public Beta runs-on: ubuntu-latest - needs: [build_upload_ios, build_upload_mac] + needs: build_upload environment: name: public_beta - url: https://testflight.apple.com/join/K71mtLjZ + url: "https://testflight.apple.com/join/K71mtLjZ" env: PILOT_USERNAME: ${{ secrets.PILOT_USERNAME }} PILOT_GROUPS: ${{ secrets.PILOT_GROUPS }} + PILOT_APP_VERSION: ${{ needs.build_upload.outputs.version }} + PILOT_BUILD_NUMBER: ${{ needs.build_upload.outputs.build }} PILOT_DISTRIBUTE_ONLY: true steps: - name: Check out repository @@ -79,26 +101,23 @@ jobs: bundler-cache: true - name: Publish on TestFlight (iOS) run: | - export PILOT_APP_VERSION=`ci/version-number.sh ios` - export PILOT_BUILD_NUMBER=`ci/build-number.sh ios` - bundle exec fastlane --env ios,beta store_beta + bundle exec fastlane --env ios,beta run pilot # - name: Publish on TestFlight (macOS) # run: | -# export PILOT_APP_VERSION=`ci/version-number.sh mac` -# export PILOT_BUILD_NUMBER=`ci/build-number.sh mac` -# bundle exec fastlane --env mac,beta store_beta +# bundle exec fastlane --env mac,beta run pilot - name: Tag beta run: | - export VERSION=`ci/version-number.sh ios` - export BUILD=`ci/version-number.sh ios` - git tag "v$VERSION-b$BUILD" && git push --tags + git tag "v$PILOT_APP_VERSION-b$PILOT_BUILD_NUMBER" && git push --tags submit_for_app_review: + name: Submit to App Review runs-on: ubuntu-latest - needs: release_public_beta + needs: build_upload environment: name: app_review env: DELIVER_USERNAME: ${{ secrets.DELIVER_USERNAME }} + DELIVER_APP_VERSION: ${{ needs.build_upload.outputs.version }} + DELIVER_BUILD_NUMBER: ${{ needs.build_upload.outputs.build }} DELIVER_FORCE: true steps: - name: Check out repository @@ -111,19 +130,18 @@ jobs: bundler-cache: true - name: Submit for App Review (iOS) run: | - export DELIVER_APP_VERSION=`ci/version-number.sh ios` - export DELIVER_BUILD_NUMBER=`ci/build-number.sh ios` - bundle exec fastlane --env ios store_review add_id_info_uses_idfa:false + bundle exec fastlane --env ios deliver_review add_id_info_uses_idfa:false - name: Submit for App Review (macOS) run: | - export DELIVER_APP_VERSION=`ci/version-number.sh mac` - export DELIVER_BUILD_NUMBER=`ci/build-number.sh mac` - bundle exec fastlane --env mac store_review add_id_info_uses_idfa:false - release_to_app_store: + bundle exec fastlane --env mac deliver_review add_id_info_uses_idfa:false + publish_to_app_store: + name: Publish to App Store runs-on: ubuntu-latest needs: submit_for_app_review environment: name: app_store + env: + TAG_NAME: ${{ needs.build_upload.outputs.version }} steps: - name: Check out repository uses: actions/checkout@v2 @@ -139,14 +157,14 @@ jobs: git_tag_gpgsign: true git_push_gpgsign: false - name: Tag release - id: tag_release run: | - scripts/ci/commit-release.sh - git pull && git push && git push --tags - echo "::set-output name=tag_name::`git describe`" + git pull --no-tags origin $GITHUB_REF_NAME + git submodule update --recursive + scripts/ci/commit-release.sh $TAG_NAME + git push && git push --tags - name: Assemble notes run: | - export RELEASE_NOTES="release-notes.txt" + RELEASE_NOTES="release-notes.txt" echo "# App Store" >$RELEASE_NOTES echo >>$RELEASE_NOTES echo "## iOS" >>$RELEASE_NOTES @@ -158,7 +176,7 @@ jobs: - name: Publish release uses: softprops/action-gh-release@v1 with: - tag_name: ${{ steps.tag_release.outputs.tag_name }} + tag_name: "v${{ needs.build_upload.outputs.version }}" body_path: release-notes.txt files: | release-notes.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 198e8846..d991b4b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,29 +8,22 @@ on: - '.beta-*' - 'Passepartout.xcodeproj/project.pbxproj' - '**/Info.plist' + - '**/CHANGELOG.md' - '**/release_notes.txt' -env: - APP_STORE_CONNECT_API_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY }} - FASTLANE_USERNAME: ${{ secrets.FASTLANE_USERNAME }} - FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }} - MATCH_USERNAME: ${{ secrets.MATCH_USERNAME }} - MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }} - MATCH_GIT_PRIVATE_KEY: ${{ secrets.MATCH_GIT_PRIVATE_KEY }} - MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} - MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} - jobs: run_tests: + name: Run tests runs-on: macos-11 timeout-minutes: 20 steps: - uses: actions/checkout@v2 with: submodules: true - - name: Prepare build - uses: ./.github/actions/prepare-build-app + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable - name: Run tests run: | - bundle exec fastlane --env mac,beta test_target + cd PassepartoutCore + swift test diff --git a/.gitignore b/.gitignore index b5ebaa18..cce41cc9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ default.profraw asc-key.json .bundle vendor/ +build/ diff --git a/Gemfile.lock b/Gemfile.lock index 59dd02d4..f963ea08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,16 +17,16 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.532.0) - aws-sdk-core (3.122.1) + aws-partitions (1.537.0) + aws-sdk-core (3.124.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.51.0) + aws-sdk-kms (1.52.0) aws-sdk-core (~> 3, >= 3.122.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.106.0) + aws-sdk-s3 (1.109.0) aws-sdk-core (~> 3, >= 3.122.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) @@ -280,4 +280,4 @@ DEPENDENCIES fastlane-plugin-appcenter BUNDLED WITH - 2.2.15 + 2.2.22 diff --git a/Passepartout.xcodeproj/xcshareddata/xcschemes/Passepartout-iOS.xcscheme b/Passepartout.xcodeproj/xcshareddata/xcschemes/Passepartout-iOS.xcscheme index 1e11e9ca..d48d07d9 100644 --- a/Passepartout.xcodeproj/xcshareddata/xcschemes/Passepartout-iOS.xcscheme +++ b/Passepartout.xcodeproj/xcshareddata/xcschemes/Passepartout-iOS.xcscheme @@ -51,6 +51,16 @@ + + + + + + + + $MARKER_FILE +echo $BUILD >$BUILD_FILE # set release notes ci/update-release-notes.sh ios && @@ -23,7 +23,7 @@ git -C PassepartoutCore/Sources/PassepartoutCore/API pull origin master git add */PassepartoutCore/API # add build number -git add $MARKER_FILE +git add $BUILD_FILE git add Passepartout.xcodeproj git add *.plist diff --git a/scripts/local/build-app.sh b/scripts/local/build-app.sh index e89068ba..cee1069c 100755 --- a/scripts/local/build-app.sh +++ b/scripts/local/build-app.sh @@ -4,4 +4,5 @@ if [[ -z $PLATFORM ]]; then echo "Platform required" exit fi -bundle exec fastlane --env $PLATFORM,beta,secret create_archive +export GYM_OUTPUT_DIRECTORY="dist/$PLATFORM" +bundle exec fastlane --env $PLATFORM,beta,secret test_and_build_app test:false diff --git a/scripts/local/review-app.sh b/scripts/local/review-app.sh index 498ca2c9..e7b2e399 100755 --- a/scripts/local/review-app.sh +++ b/scripts/local/review-app.sh @@ -7,5 +7,5 @@ fi export DELIVER_APP_VERSION=`ci/version-number.sh $PLATFORM` export DELIVER_BUILD_NUMBER=`ci/build-number.sh $PLATFORM` export DELIVER_FORCE="true" -bundle exec fastlane --env $PLATFORM,secret store_review add_id_info_uses_idfa:false +bundle exec fastlane --env $PLATFORM,secret deliver_review add_id_info_uses_idfa:false diff --git a/scripts/local/submit-app.sh b/scripts/local/submit-app.sh index 401c7c7a..39c86184 100755 --- a/scripts/local/submit-app.sh +++ b/scripts/local/submit-app.sh @@ -4,10 +4,12 @@ if [[ -z $PLATFORM ]]; then echo "Platform required" exit fi +OUTPUT_DIRECTORY="dist/$PLATFORM" if [[ $PLATFORM == "ios" ]]; then - export PILOT_IPA="dist/ios/Passepartout.ipa" + export PILOT_IPA="$OUTPUT_DIRECTORY/Passepartout.ipa" else - export PILOT_PKG="dist/mac/Passepartout.pkg" + export PILOT_PKG="$OUTPUT_DIRECTORY/Passepartout.pkg" fi +export CHANGELOG_PREFACE=`cat templates/CHANGELOG.preface.md` export PILOT_CHANGELOG=`ci/build-changelog.sh $PLATFORM` -bundle exec fastlane --env $PLATFORM,beta,secret store_beta +bundle exec fastlane --env $PLATFORM,beta,secret run pilot diff --git a/scripts/local/test-app.sh b/scripts/local/test-app.sh new file mode 100755 index 00000000..3b02331b --- /dev/null +++ b/scripts/local/test-app.sh @@ -0,0 +1,7 @@ +#!/bin/sh +PLATFORM=$1 +if [[ -z $PLATFORM ]]; then + echo "Platform required" + exit +fi +bundle exec fastlane --env $PLATFORM,beta,secret test_and_build_app build:false