From 131a7eefae5283bd71a8df9cf90e354a5b7477fe Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Fri, 2 Dec 2022 13:47:45 +0100 Subject: [PATCH 01/14] Update gemfile, so it contains the `fastlane` gem --- Gemfile | 5 +- Gemfile.lock | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 190 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 08adaa5a..496becf3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ -source "https://rubygems.org" +source 'https://rubygems.org' +gem 'fastlane' gem "xcpretty" -gem "jazzy" +gem "jazzy" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index e3c69c64..be774cd7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,25 @@ GEM algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) + artifactory (3.0.15) atomos (0.1.3) + aws-eventstream (1.2.0) + aws-partitions (1.669.0) + aws-sdk-core (3.168.2) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.5) + jmespath (~> 1, >= 1.6.1) + aws-sdk-kms (1.60.0) + aws-sdk-core (~> 3, >= 3.165.0) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.117.2) + aws-sdk-core (~> 3, >= 3.165.0) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.4) + aws-sigv4 (1.5.2) + aws-eventstream (~> 1, >= 1.0.2) + babosa (1.0.4) claide (1.1.0) cocoapods (1.11.3) addressable (~> 2.8) @@ -53,15 +71,135 @@ GEM nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.2.0) + colored (1.2) colored2 (3.1.2) + commander (4.6.0) + highline (~> 2.0.0) concurrent-ruby (1.1.10) + declarative (0.0.20) + digest-crc (0.6.4) + rake (>= 12.0.0, < 14.0.0) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.8.1) + emoji_regex (3.2.3) escape (0.0.4) - ethon (0.15.0) + ethon (0.16.0) ffi (>= 1.15.0) + excon (0.94.0) + faraday (1.10.2) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) + ruby2_keywords (>= 0.0.4) + faraday-cookie_jar (0.0.7) + faraday (>= 0.8.0) + http-cookie (~> 1.0.0) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) + faraday_middleware (1.2.0) + faraday (~> 1.0) + fastimage (2.2.6) + fastlane (2.211.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.8, < 3.0.0) + artifactory (~> 3.0) + aws-sdk-s3 (~> 1.0) + babosa (>= 1.0.3, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander (~> 4.6) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 4.0) + excon (>= 0.71.0, < 1.0.0) + faraday (~> 1.0) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 1.0) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-apis-androidpublisher_v3 (~> 0.3) + google-apis-playcustomapp_v1 (~> 0.1) + google-cloud-storage (~> 1.31) + highline (~> 2.0) + json (< 3.0.0) + jwt (>= 2.1.0, < 3) + mini_magick (>= 4.9.4, < 5.0.0) + multipart-post (~> 2.0.0) + naturally (~> 2.2) + optparse (~> 0.1.1) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 2.0.0, < 3.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.13.0, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) ffi (1.15.5) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) + google-apis-androidpublisher_v3 (0.31.0) + google-apis-core (>= 0.9.1, < 2.a) + google-apis-core (0.9.1) + addressable (~> 2.5, >= 2.5.1) + googleauth (>= 0.16.2, < 2.a) + httpclient (>= 2.8.1, < 3.a) + mini_mime (~> 1.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.a) + rexml + webrick + google-apis-iamcredentials_v1 (0.16.0) + google-apis-core (>= 0.9.1, < 2.a) + google-apis-playcustomapp_v1 (0.12.0) + google-apis-core (>= 0.9.1, < 2.a) + google-apis-storage_v1 (0.19.0) + google-apis-core (>= 0.9.0, < 2.a) + google-cloud-core (1.6.0) + google-cloud-env (~> 1.0) + google-cloud-errors (~> 1.0) + google-cloud-env (1.6.0) + faraday (>= 0.17.3, < 3.0) + google-cloud-errors (1.3.0) + google-cloud-storage (1.44.0) + addressable (~> 2.8) + digest-crc (~> 0.4) + google-apis-iamcredentials_v1 (~> 0.1) + google-apis-storage_v1 (~> 0.19.0) + google-cloud-core (~> 1.6) + googleauth (>= 0.16.2, < 2.a) + mini_mime (~> 1.0) + googleauth (1.3.0) + faraday (>= 0.17.3, < 3.a) + jwt (>= 1.4, < 3.0) + memoist (~> 0.16) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (>= 0.16, < 2.a) + highline (2.0.3) + http-cookie (1.0.5) + domain_name (~> 0.5) httpclient (2.8.3) i18n (1.12.0) concurrent-ruby (~> 1.0) @@ -75,29 +213,72 @@ GEM sassc (~> 2.1) sqlite3 (~> 1.3) xcinvoke (~> 0.3.0) + jmespath (1.6.2) json (2.6.2) + jwt (2.5.0) liferaft (0.0.6) + memoist (0.16.2) + mini_magick (4.11.0) + mini_mime (1.1.2) mini_portile2 (2.8.0) minitest (5.16.3) molinillo (0.8.0) + multi_json (1.15.0) + multipart-post (2.0.0) mustache (1.1.1) nanaimo (0.3.0) nap (1.1.0) + naturally (2.2.1) netrc (0.11.0) open4 (1.3.4) + optparse (0.1.1) + os (1.1.4) + plist (3.6.0) public_suffix (4.0.7) + rake (13.0.6) redcarpet (3.5.1) + representable (3.2.0) + declarative (< 0.1.0) + trailblazer-option (>= 0.1.1, < 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) rexml (3.2.5) rouge (2.0.7) ruby-macho (2.5.1) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) sassc (2.4.0) ffi (~> 1.9) - sqlite3 (1.5.3) + security (0.1.3) + signet (0.17.0) + addressable (~> 2.8) + faraday (>= 0.17.5, < 3.a) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.8) + CFPropertyList + naturally + sqlite3 (1.5.4) mini_portile2 (~> 2.8.0) + terminal-notifier (2.0.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + trailblazer-option (0.1.2) + tty-cursor (0.7.1) + tty-screen (0.8.1) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.8.2) + unicode-display_width (1.8.0) + webrick (1.7.0) + word_wrap (1.0.0) xcinvoke (0.3.0) liferaft (~> 0.0.6) xcodeproj (1.22.0) @@ -109,12 +290,15 @@ GEM rexml (~> 3.2.4) xcpretty (0.3.0) rouge (~> 2.0.7) - zeitwerk (2.6.1) + xcpretty-travis-formatter (1.0.1) + xcpretty (~> 0.2, >= 0.0.7) + zeitwerk (2.6.6) PLATFORMS ruby DEPENDENCIES + fastlane jazzy xcpretty From d1f69ff615bbed8eac92a7308de0a4cfa295244f Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Fri, 2 Dec 2022 13:49:21 +0100 Subject: [PATCH 02/14] Add the TestFlight workflow for uploading Subscriber example app builds to TestFlight via Fastlane --- .github/workflows/testflight.yml | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/testflight.yml diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml new file mode 100644 index 00000000..4da1847d --- /dev/null +++ b/.github/workflows/testflight.yml @@ -0,0 +1,52 @@ +name: Upload iOS example apps to TestFlight +on: + pull_request: + push: + branches: + - main + +jobs: + build: + runs-on: macos-latest + steps: + - name: Select Specific Xcode Version + run: | + sudo xcode-select -s /Applications/Xcode_13.4.1.app + echo "Selected Xcode version:" + xcodebuild -version + + - name: Configure Mapbox SDK download token + run: | + echo "machine api.mapbox.com" >> ~/.netrc + echo "login mapbox" >> ~/.netrc + echo "password $MAPBOX_DOWNLOADS_TOKEN" >> ~/.netrc + env: + MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} + + - name: Configure runtime secrets + run: | + echo "MAPBOX_ACCESS_TOKEN = $EXAMPLE_APPS_MAPBOX_ACCESS_TOKEN" >> Examples/Secrets.xcconfig + echo "ABLY_API_KEY = $EXAMPLE_APPS_ABLY_API_KEY" >> Examples/Secrets.xcconfig + env: + MAPBOX_ACCESS_TOKEN: ${{ secrets.EXAMPLE_APPS_MAPBOX_ACCESS_TOKEN }} + ABLY_API_KEY: ${{ secrets.EXAMPLE_APPS_ABLY_API_KEY }} + AMPLIFY_CONFIGURATION: ${{ secrets.AMPLIFY_CONFIGURATION }} + FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }} + MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + + - name: Configure remaining runtime env + env: + FASTLANE_XCODE_LIST_TIMEOUT: 100 + FASTLANE_XCODEBUILD_SETTINGS_RETRIES: 15 + + - name: Setup Bundler + run: | + bundle install + + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Run Fastlane + run: bundle exec fastlane build_and_upload_to_testflight From f9b317433fe8033a865744c046e538859f82e3e9 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Fri, 2 Dec 2022 13:55:30 +0100 Subject: [PATCH 03/14] Add a Fastfile for the Subscriber example app with the `build_and_upload_to_testflight` lane. --- Examples/SubscriberExample/fastlane/Fastfile | 46 ++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Examples/SubscriberExample/fastlane/Fastfile diff --git a/Examples/SubscriberExample/fastlane/Fastfile b/Examples/SubscriberExample/fastlane/Fastfile new file mode 100644 index 00000000..8e41f701 --- /dev/null +++ b/Examples/SubscriberExample/fastlane/Fastfile @@ -0,0 +1,46 @@ +default_platform(:ios) + platform :ios do + desc "Build and upload the Subscriber Example app to TestFlight" + lane :build_and_upload_to_testflight do + # Creates a temporary keychain. Without this, the build could + # freeze and never finish. https://docs.fastlane.tools/actions/setup_ci/ + setup_ci if ENV['CI'] + update_project_team( + path: "SubscriberExample.xcodeproj", + teamid: "XXY98AVDR6") + update_build_number + match( + git_url: ENV["MATCH_GIT_URL"], + app_identifier: "com.ably.tracking.example.subscriber", + type: "appstore", + readonly: true) + build_app(scheme: "SubscriberExample", + project: "SubscriberExample.xcodeproj", + export_method: 'app-store', + output_name: "SubscriberExample.ipa", + clean: true, + include_bitcode: true) + upload_to_testflight( + skip_submission: true, + skip_waiting_for_build_processing: true, + apple_id: "6444409821", + itc_provider:"XXY98AVDR6") + end + + # Example output: 2022.12.1.1454 + desc "Set build number based on current time" + private_lane :update_build_number do + build_number = Time.new.strftime("%Y.%m.%d.%H%M") + increment_build_number( + build_number: build_number, + xcodeproj: "SubscriberExample.xcodeproj") + end + + # Helper lane, not used by CI, but can be used on local machines + # to fetch currently used certificate and profile from match repo + # by running `bundle exec fastlane fetch_certificate` + desc "Fetch the distribution certificate and appstore provisioning profile from git repo" + lane :fetch_certificate do + match(type: "appstore", readonly: true) + end +end \ No newline at end of file From 82351cace35b3f509d53168e327d5596093b4fd5 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Fri, 2 Dec 2022 13:56:38 +0100 Subject: [PATCH 04/14] Add auto-generated Fastlane readme --- Examples/SubscriberExample/fastlane/README.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Examples/SubscriberExample/fastlane/README.md diff --git a/Examples/SubscriberExample/fastlane/README.md b/Examples/SubscriberExample/fastlane/README.md new file mode 100644 index 00000000..7c03099e --- /dev/null +++ b/Examples/SubscriberExample/fastlane/README.md @@ -0,0 +1,40 @@ +fastlane documentation +---- + +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +```sh +xcode-select --install +``` + +For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane) + +# Available Actions + +## iOS + +### ios build_and_upload_to_testflight + +```sh +[bundle exec] fastlane ios build_and_upload_to_testflight +``` + +Build and upload the Subscriber Example app to TestFlight + +### ios fetch_certificate + +```sh +[bundle exec] fastlane ios fetch_certificate +``` + +Fetch the distribution certificate and appstore provisioning profile from git repo + +---- + +This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. + +More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools). + +The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools). From 0ae979c46312bdb0f1d7a14eb6828add2848d8a1 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Mon, 5 Dec 2022 10:37:09 +0100 Subject: [PATCH 05/14] Add git_basic_authorization param to match config, workflow improvements and fixes --- .github/workflows/testflight.yml | 13 ++++++++----- Examples/SubscriberExample/fastlane/Fastfile | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 4da1847d..62dfb8a8 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -24,9 +24,6 @@ jobs: MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} - name: Configure runtime secrets - run: | - echo "MAPBOX_ACCESS_TOKEN = $EXAMPLE_APPS_MAPBOX_ACCESS_TOKEN" >> Examples/Secrets.xcconfig - echo "ABLY_API_KEY = $EXAMPLE_APPS_ABLY_API_KEY" >> Examples/Secrets.xcconfig env: MAPBOX_ACCESS_TOKEN: ${{ secrets.EXAMPLE_APPS_MAPBOX_ACCESS_TOKEN }} ABLY_API_KEY: ${{ secrets.EXAMPLE_APPS_ABLY_API_KEY }} @@ -34,6 +31,10 @@ jobs: FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }} MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + run: | + echo "MAPBOX_ACCESS_TOKEN = $EXAMPLE_APPS_MAPBOX_ACCESS_TOKEN" >> Examples/Secrets.xcconfig + echo "ABLY_API_KEY = $EXAMPLE_APPS_ABLY_API_KEY" >> Examples/Secrets.xcconfig + - name: Configure remaining runtime env env: @@ -48,5 +49,7 @@ jobs: with: submodules: recursive - - name: Run Fastlane - run: bundle exec fastlane build_and_upload_to_testflight + - name: Run Fastlane for the Subscriber example app + run: | + cd Examples/SubscriberExample + bundle exec fastlane build_and_upload_to_testflight diff --git a/Examples/SubscriberExample/fastlane/Fastfile b/Examples/SubscriberExample/fastlane/Fastfile index 8e41f701..982e8be8 100644 --- a/Examples/SubscriberExample/fastlane/Fastfile +++ b/Examples/SubscriberExample/fastlane/Fastfile @@ -13,6 +13,7 @@ default_platform(:ios) git_url: ENV["MATCH_GIT_URL"], app_identifier: "com.ably.tracking.example.subscriber", type: "appstore", + git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), readonly: true) build_app(scheme: "SubscriberExample", project: "SubscriberExample.xcodeproj", From 3e4ba9d61b4bf412efaa8aab73cb5c1d1b3e04e3 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Mon, 5 Dec 2022 10:44:40 +0100 Subject: [PATCH 06/14] Fix the testflight.yml workflow syntax --- .github/workflows/testflight.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 62dfb8a8..68657ef3 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -50,6 +50,6 @@ jobs: submodules: recursive - name: Run Fastlane for the Subscriber example app - run: | - cd Examples/SubscriberExample - bundle exec fastlane build_and_upload_to_testflight + working-directory: ./Examples/SubscriberExample + run: | + bundle exec fastlane build_and_upload_to_testflight \ No newline at end of file From 87de5212fe9b09e37d4a7c71c47d1d719f738ecd Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Mon, 5 Dec 2022 10:47:38 +0100 Subject: [PATCH 07/14] Fix missing indentation --- .github/workflows/testflight.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 68657ef3..0a1b0031 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -52,4 +52,4 @@ jobs: - name: Run Fastlane for the Subscriber example app working-directory: ./Examples/SubscriberExample run: | - bundle exec fastlane build_and_upload_to_testflight \ No newline at end of file + bundle exec fastlane build_and_upload_to_testflight \ No newline at end of file From 8aca83e41868bdbbcfcdd1653ded3dca0de79544 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Mon, 5 Dec 2022 10:57:15 +0100 Subject: [PATCH 08/14] Github actions setup --- .github/workflows/testflight.yml | 56 ++++++++++--------- .../project.pbxproj | 4 ++ Examples/SubscriberExample/fastlane/Fastfile | 3 +- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 0a1b0031..fef2524d 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -9,12 +9,20 @@ jobs: build: runs-on: macos-latest steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Setup Bundler + run: | + bundle install + - name: Select Specific Xcode Version run: | sudo xcode-select -s /Applications/Xcode_13.4.1.app echo "Selected Xcode version:" xcodebuild -version - + - name: Configure Mapbox SDK download token run: | echo "machine api.mapbox.com" >> ~/.netrc @@ -23,33 +31,29 @@ jobs: env: MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} - - name: Configure runtime secrets + - name: Configure runtime secrets and ENVs + run: | + echo "MAPBOX_ACCESS_TOKEN = $MAPBOX_ACCESS_TOKEN" >> Examples/Secrets.xcconfig + echo "ABLY_API_KEY = $ASSET_TRACKING_TESTING_ABLY_API_KEY" >> Examples/Secrets.xcconfig env: - MAPBOX_ACCESS_TOKEN: ${{ secrets.EXAMPLE_APPS_MAPBOX_ACCESS_TOKEN }} - ABLY_API_KEY: ${{ secrets.EXAMPLE_APPS_ABLY_API_KEY }} + MAPBOX_ACCESS_TOKEN: ${{ secrets.ASSET_TRACKING_TESTING_MAPBOX_ACCESS_TOKEN }} + ABLY_API_KEY: ${{ secrets.ASSET_TRACKING_TESTING_ABLY_API_KEY }} AMPLIFY_CONFIGURATION: ${{ secrets.AMPLIFY_CONFIGURATION }} - FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }} - MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }} - MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - run: | - echo "MAPBOX_ACCESS_TOKEN = $EXAMPLE_APPS_MAPBOX_ACCESS_TOKEN" >> Examples/Secrets.xcconfig - echo "ABLY_API_KEY = $EXAMPLE_APPS_ABLY_API_KEY" >> Examples/Secrets.xcconfig - - - name: Configure remaining runtime env - env: - FASTLANE_XCODE_LIST_TIMEOUT: 100 - FASTLANE_XCODEBUILD_SETTINGS_RETRIES: 15 - - - name: Setup Bundler - run: | - bundle install - - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Run Fastlane for the Subscriber example app - working-directory: ./Examples/SubscriberExample + working-directory: Examples/SubscriberExample run: | - bundle exec fastlane build_and_upload_to_testflight \ No newline at end of file + echo "$MATCH_DEPLOY_KEY" > deployKey + eval "$(ssh-agent -s)" + chmod 400 deployKey + ssh-add deployKey + ssh-keyscan github.com >> ~/.ssh/known_hosts + bundle exec fastlane build_and_upload_to_testflight + env: + MATCH_DEPLOY_KEY: ${{ secrets.APPLE_APPS_MATCH_DEPLOY_KEY }} + FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APPS_APPLICATION_SPECIFIC_PASSWORD }} + MATCH_GIT_URL: ${{ secrets.APPLE_APPS_MATCH_GIT_URL }} + MATCH_PASSWORD: ${{ secrets.APPLE_APPS_MATCH_ENCRYPTION_PASSPHRASE }} + FASTLANE_XCODE_LIST_TIMEOUT: 100 + FASTLANE_XCODEBUILD_SETTINGS_RETRIES: 6 + \ No newline at end of file diff --git a/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj b/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj index 76ea21cc..2d6d5395 100644 --- a/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj +++ b/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj @@ -444,6 +444,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; @@ -456,6 +457,7 @@ MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.ably.tracking.example.subscriber; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -466,6 +468,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_IDENTITY = "Apple Distribution"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; @@ -478,6 +481,7 @@ MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.ably.tracking.example.subscriber; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/Examples/SubscriberExample/fastlane/Fastfile b/Examples/SubscriberExample/fastlane/Fastfile index 982e8be8..7e346568 100644 --- a/Examples/SubscriberExample/fastlane/Fastfile +++ b/Examples/SubscriberExample/fastlane/Fastfile @@ -8,12 +8,11 @@ default_platform(:ios) update_project_team( path: "SubscriberExample.xcodeproj", teamid: "XXY98AVDR6") - update_build_number + # update_build_number match( git_url: ENV["MATCH_GIT_URL"], app_identifier: "com.ably.tracking.example.subscriber", type: "appstore", - git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), readonly: true) build_app(scheme: "SubscriberExample", project: "SubscriberExample.xcodeproj", From 9cb73013770d75dec0aa41929e4d3f2efcb591e3 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Wed, 7 Dec 2022 10:45:58 +0100 Subject: [PATCH 09/14] Remove ${SRCROOT} from info.plist's path, since it causes errors when trying to update build numbers --- .../SubscriberExample.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj b/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj index 2d6d5395..ad62db3a 100644 --- a/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj +++ b/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj @@ -448,7 +448,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; + INFOPLIST_FILE = /Resources/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -472,7 +472,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; + INFOPLIST_FILE = /Resources/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", From 213914b8dd66280e3e92b0e17426273a5e162df6 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Wed, 7 Dec 2022 10:59:58 +0100 Subject: [PATCH 10/14] Further setup and fixes --- .../project.pbxproj | 24 +++++++++---------- Examples/SubscriberExample/fastlane/Fastfile | 19 ++++++++++----- Examples/SubscriberExample/fastlane/README.md | 2 +- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj b/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj index ad62db3a..38d0d8c7 100644 --- a/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj +++ b/Examples/SubscriberExample/SubscriberExample.xcodeproj/project.pbxproj @@ -444,11 +444,11 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = /Resources/Info.plist; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 2022.12.07.1304; + DEVELOPMENT_TEAM = XXY98AVDR6; + INFOPLIST_FILE = Resources/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -457,7 +457,7 @@ MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.ably.tracking.example.subscriber; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; + PROVISIONING_PROFILE_SPECIFIER = "match dist com.ably.tracking.example.subscriber"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -468,11 +468,11 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_IDENTITY = "Apple Distribution"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = /Resources/Info.plist; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 2022.12.07.1304; + DEVELOPMENT_TEAM = XXY98AVDR6; + INFOPLIST_FILE = Resources/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -481,7 +481,7 @@ MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.ably.tracking.example.subscriber; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; + PROVISIONING_PROFILE_SPECIFIER = "match dist com.ably.tracking.example.subscriber"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/Examples/SubscriberExample/fastlane/Fastfile b/Examples/SubscriberExample/fastlane/Fastfile index 7e346568..b551f5ac 100644 --- a/Examples/SubscriberExample/fastlane/Fastfile +++ b/Examples/SubscriberExample/fastlane/Fastfile @@ -5,10 +5,16 @@ default_platform(:ios) # Creates a temporary keychain. Without this, the build could # freeze and never finish. https://docs.fastlane.tools/actions/setup_ci/ setup_ci if ENV['CI'] - update_project_team( - path: "SubscriberExample.xcodeproj", - teamid: "XXY98AVDR6") - # update_build_number + # We want to leave the default config as Automatic code signing, since it's easier + # to use for users. So instead of changing those settings in pbxproj, we're using the + # `update_code_signing_settings` step. + update_code_signing_settings( + use_automatic_signing: false, + path: "SubscriberExample.xcodeproj", + team_id: "XXY98AVDR6", + code_sign_identity: "iPhone Distribution", + profile_name: "match dist com.ably.tracking.example.subscriber") + update_build_number match( git_url: ENV["MATCH_GIT_URL"], app_identifier: "com.ably.tracking.example.subscriber", @@ -16,7 +22,8 @@ default_platform(:ios) readonly: true) build_app(scheme: "SubscriberExample", project: "SubscriberExample.xcodeproj", - export_method: 'app-store', + configuration: "Release", + export_method: "app-store", output_name: "SubscriberExample.ipa", clean: true, include_bitcode: true) @@ -39,7 +46,7 @@ default_platform(:ios) # Helper lane, not used by CI, but can be used on local machines # to fetch currently used certificate and profile from match repo # by running `bundle exec fastlane fetch_certificate` - desc "Fetch the distribution certificate and appstore provisioning profile from git repo" + desc "Fetch the distribution certificate and appstore provisioning profile from match git repo" lane :fetch_certificate do match(type: "appstore", readonly: true) end diff --git a/Examples/SubscriberExample/fastlane/README.md b/Examples/SubscriberExample/fastlane/README.md index 7c03099e..d4d2df96 100644 --- a/Examples/SubscriberExample/fastlane/README.md +++ b/Examples/SubscriberExample/fastlane/README.md @@ -29,7 +29,7 @@ Build and upload the Subscriber Example app to TestFlight [bundle exec] fastlane ios fetch_certificate ``` -Fetch the distribution certificate and appstore provisioning profile from git repo +Fetch the distribution certificate and appstore provisioning profile from match git repo ---- From 380453e61b4980a66d47309ddb82e7204ef12973 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Thu, 8 Dec 2022 13:13:43 +0100 Subject: [PATCH 11/14] Setup workflow and fastlane/match for PublisherExampleSwiftUI app, some minor improvements to the SubscriberExample's Fastfile --- .github/workflows/testflight.yml | 38 ++++++++++--- .../PublisherExampleSwiftUI/fastlane/Fastfile | 54 +++++++++++++++++++ Examples/SubscriberExample/fastlane/Fastfile | 33 ++++++------ Gemfile.lock | 8 +-- 4 files changed, 106 insertions(+), 27 deletions(-) create mode 100644 Examples/PublisherExampleSwiftUI/fastlane/Fastfile diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index fef2524d..a3a1ee10 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -5,6 +5,14 @@ on: branches: - main +env: + FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APPS_APPLICATION_SPECIFIC_PASSWORD }} + MATCH_GIT_URL: ${{ secrets.APPLE_APPS_MATCH_GIT_URL }} + MATCH_PASSWORD: ${{ secrets.APPLE_APPS_MATCH_ENCRYPTION_PASSPHRASE }} + FASTLANE_XCODE_LIST_TIMEOUT: 100 + FASTLANE_XCODEBUILD_SETTINGS_RETRIES: 6 + MATCH_DEPLOY_KEY: ${{ secrets.APPLE_APPS_MATCH_DEPLOY_KEY }} + jobs: build: runs-on: macos-latest @@ -40,6 +48,27 @@ jobs: ABLY_API_KEY: ${{ secrets.ASSET_TRACKING_TESTING_ABLY_API_KEY }} AMPLIFY_CONFIGURATION: ${{ secrets.AMPLIFY_CONFIGURATION }} + # Needed for communication with the Match secrets repo + # - name: Add deploy key to keychain + # run: | + # echo "$MATCH_DEPLOY_KEY" > deployKey + # eval "$(ssh-agent -s)" + # chmod 400 deployKey + # ssh-add deployKey + # ssh-keyscan github.com >> ~/.ssh/known_hosts + # env: + # MATCH_DEPLOY_KEY: ${{ secrets.APPLE_APPS_MATCH_DEPLOY_KEY }} + + - name: Run Fastlane for the Publisher example app + working-directory: Examples/PublisherExampleSwiftUI + run: | + echo "$MATCH_DEPLOY_KEY" > deployKey + eval "$(ssh-agent -s)" + chmod 400 deployKey + ssh-add deployKey + ssh-keyscan github.com >> ~/.ssh/known_hosts + bundle exec fastlane build_and_upload_to_testflight + - name: Run Fastlane for the Subscriber example app working-directory: Examples/SubscriberExample run: | @@ -49,11 +78,6 @@ jobs: ssh-add deployKey ssh-keyscan github.com >> ~/.ssh/known_hosts bundle exec fastlane build_and_upload_to_testflight - env: - MATCH_DEPLOY_KEY: ${{ secrets.APPLE_APPS_MATCH_DEPLOY_KEY }} - FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APPS_APPLICATION_SPECIFIC_PASSWORD }} - MATCH_GIT_URL: ${{ secrets.APPLE_APPS_MATCH_GIT_URL }} - MATCH_PASSWORD: ${{ secrets.APPLE_APPS_MATCH_ENCRYPTION_PASSPHRASE }} - FASTLANE_XCODE_LIST_TIMEOUT: 100 - FASTLANE_XCODEBUILD_SETTINGS_RETRIES: 6 + + \ No newline at end of file diff --git a/Examples/PublisherExampleSwiftUI/fastlane/Fastfile b/Examples/PublisherExampleSwiftUI/fastlane/Fastfile new file mode 100644 index 00000000..716799f2 --- /dev/null +++ b/Examples/PublisherExampleSwiftUI/fastlane/Fastfile @@ -0,0 +1,54 @@ +default_platform(:ios) + platform :ios do + desc "Build and upload the Publisher Example app to TestFlight" + lane :build_and_upload_to_testflight do + # Creates a temporary keychain. Without this, the build could + # freeze and never finish. https://docs.fastlane.tools/actions/setup_ci/ + setup_ci if ENV['CI'] + # We want to leave the default config as Automatic code signing, since it's easier + # to use for users. So instead of changing those settings in pbxproj, we're using the + # `update_code_signing_settings` step. + update_code_signing_settings( + use_automatic_signing: false, + path: "PublisherExampleSwiftUI.xcodeproj", + team_id: "XXY98AVDR6", + code_sign_identity: "iPhone Distribution", + profile_name: "match appstore com.ably.tracking.example.publisher") + update_build_number + match( + git_url: ENV["MATCH_GIT_URL"], + app_identifier: "com.ably.tracking.example.publisher", + type: "appstore", + readonly: true) + build_app(scheme: "PublisherExampleSwiftUI", + project: "PublisherExampleSwiftUI.xcodeproj", + configuration: "Release", + export_method: "app-store", + output_name: "PublisherExample.ipa", + clean: true, + include_bitcode: true) + # upload_to_testflight( + #skip_submission: true, + #skip_waiting_for_build_processing: true, + #apple_id: "6444406485", + #username: ENV["APPLE_APPS_USERNAME"], + # itc_provider:"XXY98AVDR6") + end + + # Example output: 2022.12.1.1454 + desc "Set build number based on current time" + private_lane :update_build_number do + build_number = Time.new.strftime("%Y.%m.%d.%H%M") + increment_build_number(build_number: build_number) + end + + # Helper lane, not used by CI, but can be used on local machines + # to fetch currently used certificate and profile from match repo + # by running `bundle exec fastlane fetch_certificate` + desc "Fetch the distribution certificate and appstore provisioning profile from match git repo" + lane :fetch_certificate do + match(type: "appstore", + readonly: true, + app_identifier: com.ably.tracking.example.publisher) + end +end \ No newline at end of file diff --git a/Examples/SubscriberExample/fastlane/Fastfile b/Examples/SubscriberExample/fastlane/Fastfile index b551f5ac..b62b6ac6 100644 --- a/Examples/SubscriberExample/fastlane/Fastfile +++ b/Examples/SubscriberExample/fastlane/Fastfile @@ -21,26 +21,25 @@ default_platform(:ios) type: "appstore", readonly: true) build_app(scheme: "SubscriberExample", - project: "SubscriberExample.xcodeproj", - configuration: "Release", - export_method: "app-store", - output_name: "SubscriberExample.ipa", - clean: true, - include_bitcode: true) - upload_to_testflight( - skip_submission: true, - skip_waiting_for_build_processing: true, - apple_id: "6444409821", - itc_provider:"XXY98AVDR6") + project: "SubscriberExample.xcodeproj", + configuration: "Release", + export_method: "app-store", + output_name: "SubscriberExample.ipa", + clean: true, + include_bitcode: true) + #upload_to_testflight( + #skip_submission: true, + #skip_waiting_for_build_processing: true, + #apple_id: "6444409821", + #username: ENV["APPLE_APPS_USERNAME"], + #itc_provider:"XXY98AVDR6") end # Example output: 2022.12.1.1454 desc "Set build number based on current time" private_lane :update_build_number do - build_number = Time.new.strftime("%Y.%m.%d.%H%M") - increment_build_number( - build_number: build_number, - xcodeproj: "SubscriberExample.xcodeproj") + build_number = Time.new.strftime("%Y.%m.%d.%H%M") + increment_build_number(build_number: build_number) end # Helper lane, not used by CI, but can be used on local machines @@ -48,6 +47,8 @@ default_platform(:ios) # by running `bundle exec fastlane fetch_certificate` desc "Fetch the distribution certificate and appstore provisioning profile from match git repo" lane :fetch_certificate do - match(type: "appstore", readonly: true) + match(type: "appstore", + readonly: true, + app_identifier: com.ably.tracking.example.subscriber) end end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index be774cd7..05ea472f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,8 +17,8 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.669.0) - aws-sdk-core (3.168.2) + aws-partitions (1.672.0) + aws-sdk-core (3.168.3) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) @@ -214,11 +214,11 @@ GEM sqlite3 (~> 1.3) xcinvoke (~> 0.3.0) jmespath (1.6.2) - json (2.6.2) + json (2.6.3) jwt (2.5.0) liferaft (0.0.6) memoist (0.16.2) - mini_magick (4.11.0) + mini_magick (4.12.0) mini_mime (1.1.2) mini_portile2 (2.8.0) minitest (5.16.3) From ffc7de28edc7550651a2b5af6ab3683a0f2c664c Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Fri, 9 Dec 2022 12:38:39 +0100 Subject: [PATCH 12/14] Add a section to Contributing.md about how to maintain the testflight.yml workflow. --- .github/workflows/testflight.yml | 11 -------- CONTRIBUTING.md | 25 +++++++++++++++++++ .../PublisherExampleSwiftUI/fastlane/Fastfile | 4 +-- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index a3a1ee10..2ec53f85 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -48,17 +48,6 @@ jobs: ABLY_API_KEY: ${{ secrets.ASSET_TRACKING_TESTING_ABLY_API_KEY }} AMPLIFY_CONFIGURATION: ${{ secrets.AMPLIFY_CONFIGURATION }} - # Needed for communication with the Match secrets repo - # - name: Add deploy key to keychain - # run: | - # echo "$MATCH_DEPLOY_KEY" > deployKey - # eval "$(ssh-agent -s)" - # chmod 400 deployKey - # ssh-add deployKey - # ssh-keyscan github.com >> ~/.ssh/known_hosts - # env: - # MATCH_DEPLOY_KEY: ${{ secrets.APPLE_APPS_MATCH_DEPLOY_KEY }} - - name: Run Fastlane for the Publisher example app working-directory: Examples/PublisherExampleSwiftUI run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cc8510b0..17c82538 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -105,3 +105,28 @@ We use [Sourcery](https://github.com/krzysztofzablocki/Sourcery) to generate moc At the time of writing, there is no way to automatically generate these mocks as part of the SPM build process, so when you update these files you’ll need to manually run the command `Scripts/generate-mocks.sh`. When [Swift package plugins](https://developer.apple.com/videos/play/wwdc2022/110359/) get introduced in Swift 5.6, we might be able to generate these mocks automatically. + +## Example apps distribution to TestFlight + +We have a `testflight.yml` workflow that builds and uploads both the Publisher and Subscriber example apps to testflight for internal testing whenever code is pushed to the `main` branch. + +`testflight.yml` workflow uses [fastlane](https://docs.fastlane.tools/) for creating and uploading builds, along with [match](https://docs.fastlane.tools/actions/match/) for handling code signing. The match secrets repo is available under git organization level secrets - `secrets.APPLE_APPS_MATCH_GIT_URL`, with it's `secrets.APPLE_APPS_MATCH_ENCRYPTION_PASSPHRASE`. +There are two separate `Fastfile`s that fastlane uses in this workflow - one for the publisher, and one for the example apps: `Examples/PublisherExampleSwiftUI/fastlane/Fastfile` and `Examples/SubscriberExample/fastlane/Fastfile`. + +`testflight.yml` workflow will need some manual maintenance, since the distribution signing certificate used for signing the example apps builds expires a year after it's creation date. +Whenever that happens, we will need to recreate it, and the corresponding provisioning profiles (currently named `match dist com.ably.tracking.example.subscriber` and `match appstore com.ably.tracking.example.publisher`) and upload them to the `Match secrets repo`. + +This can be done automatically by `match` using `bundle exec fastlane match appstore` command from `Examples/SubsriberExample` and `Examples/PublisherExampleSwiftUI`, however this command creates both a new distribution cert and an appstore provisioning profile each time it is run - so it will create two distribution certs. + +Since the ammount of distribution certificates linked to an App Store Connect organization is limited, it's preferable to create a new distribution certificate manually in Xcode, and then [export it](https://sarunw.com/posts/how-to-share-ios-distribution-certificate/#exporting-a-certificate) from your keychain - both the .p12 and .cer files. + +Then create new `App Store` type provisioning profiles for both example apps in [Apple dev center](https://developer.apple.com/account/resources/profiles/list), and download them. + +Finally, run the command `bundle exec fastlane match import --readonly true --type appstore` to import the created distribution cert and provisioning profiles into the match secrets repo. + +If provisioning profiles' names were changed in the process, make sure to update the corresponing values in both fastfiles: +``` +update_code_signing_settings( + ... + profile_name: "new name") +``` diff --git a/Examples/PublisherExampleSwiftUI/fastlane/Fastfile b/Examples/PublisherExampleSwiftUI/fastlane/Fastfile index 716799f2..02d082de 100644 --- a/Examples/PublisherExampleSwiftUI/fastlane/Fastfile +++ b/Examples/PublisherExampleSwiftUI/fastlane/Fastfile @@ -6,8 +6,8 @@ default_platform(:ios) # freeze and never finish. https://docs.fastlane.tools/actions/setup_ci/ setup_ci if ENV['CI'] # We want to leave the default config as Automatic code signing, since it's easier - # to use for users. So instead of changing those settings in pbxproj, we're using the - # `update_code_signing_settings` step. + # to use for users. So instead of changing those settings in pbxproj in git, we're using + # the `update_code_signing_settings` step here. update_code_signing_settings( use_automatic_signing: false, path: "PublisherExampleSwiftUI.xcodeproj", From bb064009fbbaf710a2f87f0cf2bf4080ca871165 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Mon, 12 Dec 2022 14:59:36 +0100 Subject: [PATCH 13/14] Uncomment the upload_to_testflight step from both Fastfiles --- Examples/PublisherExampleSwiftUI/fastlane/Fastfile | 12 ++++++------ Examples/SubscriberExample/fastlane/Fastfile | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Examples/PublisherExampleSwiftUI/fastlane/Fastfile b/Examples/PublisherExampleSwiftUI/fastlane/Fastfile index 02d082de..377dd747 100644 --- a/Examples/PublisherExampleSwiftUI/fastlane/Fastfile +++ b/Examples/PublisherExampleSwiftUI/fastlane/Fastfile @@ -27,12 +27,12 @@ default_platform(:ios) output_name: "PublisherExample.ipa", clean: true, include_bitcode: true) - # upload_to_testflight( - #skip_submission: true, - #skip_waiting_for_build_processing: true, - #apple_id: "6444406485", - #username: ENV["APPLE_APPS_USERNAME"], - # itc_provider:"XXY98AVDR6") + upload_to_testflight( + skip_submission: true, + skip_waiting_for_build_processing: true, + apple_id: "6444406485", + username: ENV["APPLE_APPS_USERNAME"], + itc_provider:"XXY98AVDR6") end # Example output: 2022.12.1.1454 diff --git a/Examples/SubscriberExample/fastlane/Fastfile b/Examples/SubscriberExample/fastlane/Fastfile index b62b6ac6..90df0571 100644 --- a/Examples/SubscriberExample/fastlane/Fastfile +++ b/Examples/SubscriberExample/fastlane/Fastfile @@ -27,12 +27,12 @@ default_platform(:ios) output_name: "SubscriberExample.ipa", clean: true, include_bitcode: true) - #upload_to_testflight( - #skip_submission: true, - #skip_waiting_for_build_processing: true, - #apple_id: "6444409821", - #username: ENV["APPLE_APPS_USERNAME"], - #itc_provider:"XXY98AVDR6") + upload_to_testflight( + skip_submission: true, + skip_waiting_for_build_processing: true, + apple_id: "6444409821", + username: ENV["APPLE_APPS_USERNAME"], + itc_provider:"XXY98AVDR6") end # Example output: 2022.12.1.1454 From 58b53f6f0b70a3092090516ba5b21ca8a0e0b45e Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Mon, 12 Dec 2022 15:19:10 +0100 Subject: [PATCH 14/14] Add a APPLE_APPS_USERNAME env var to testflight workflow, also actually create the amplifyConfiguration.json file from the ENV --- .github/workflows/testflight.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 2ec53f85..5846f65c 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -12,6 +12,7 @@ env: FASTLANE_XCODE_LIST_TIMEOUT: 100 FASTLANE_XCODEBUILD_SETTINGS_RETRIES: 6 MATCH_DEPLOY_KEY: ${{ secrets.APPLE_APPS_MATCH_DEPLOY_KEY }} + APPLE_APPS_USERNAME: ${{ secrets.APPLE_APPS_USERNAME }} jobs: build: @@ -39,16 +40,17 @@ jobs: env: MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }} - - name: Configure runtime secrets and ENVs + - name: Create runtime secret files run: | echo "MAPBOX_ACCESS_TOKEN = $MAPBOX_ACCESS_TOKEN" >> Examples/Secrets.xcconfig echo "ABLY_API_KEY = $ASSET_TRACKING_TESTING_ABLY_API_KEY" >> Examples/Secrets.xcconfig + echo "AMPLIFY_CONFIGURATION" = $AMPLIFY_CONFIGURATION >> Examples/PublisherExampleSwiftUI/PublisherExampleSwiftUI/Optional\ Resources/amplifyconfiguration.json env: MAPBOX_ACCESS_TOKEN: ${{ secrets.ASSET_TRACKING_TESTING_MAPBOX_ACCESS_TOKEN }} ABLY_API_KEY: ${{ secrets.ASSET_TRACKING_TESTING_ABLY_API_KEY }} AMPLIFY_CONFIGURATION: ${{ secrets.AMPLIFY_CONFIGURATION }} - - name: Run Fastlane for the Publisher example app + - name: Configure Match Deploy key and Run Fastlane for the Publisher example app working-directory: Examples/PublisherExampleSwiftUI run: | echo "$MATCH_DEPLOY_KEY" > deployKey @@ -58,7 +60,7 @@ jobs: ssh-keyscan github.com >> ~/.ssh/known_hosts bundle exec fastlane build_and_upload_to_testflight - - name: Run Fastlane for the Subscriber example app + - name: Configure Match Deploy key and run Fastlane for the Subscriber example app working-directory: Examples/SubscriberExample run: | echo "$MATCH_DEPLOY_KEY" > deployKey @@ -66,7 +68,4 @@ jobs: chmod 400 deployKey ssh-add deployKey ssh-keyscan github.com >> ~/.ssh/known_hosts - bundle exec fastlane build_and_upload_to_testflight - - - \ No newline at end of file + bundle exec fastlane build_and_upload_to_testflight \ No newline at end of file