diff --git a/.github/workflows/test_upload_build_to_test_flight.yml b/.github/workflows/test_upload_build_to_test_flight.yml index 1606fdab..387c835b 100644 --- a/.github/workflows/test_upload_build_to_test_flight.yml +++ b/.github/workflows/test_upload_build_to_test_flight.yml @@ -47,7 +47,7 @@ jobs: run: sh make.sh --bundle-id co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit - name: Start Setup Script for Template App TestFlight Upload - run: sh set_up_test_testflight.sh + run: cat Scripts/Swift/SetUpTestTestFlight.swift Scripts/Swift/Extensions/FileManager+Utils.swift | swift - env: MATCH_REPO: ${{ secrets.MATCH_REPO }} API_KEY_ID: ${{ secrets.API_KEY_ID }} diff --git a/Scripts/Swift/SetUpTestTestFlight.swift b/Scripts/Swift/SetUpTestTestFlight.swift new file mode 100644 index 00000000..950c4952 --- /dev/null +++ b/Scripts/Swift/SetUpTestTestFlight.swift @@ -0,0 +1,16 @@ +let teamIdPlaceholder = "<#teamId#>" +let apiKeyIdPlaceholder = "<#API_KEY_ID#>" +let issuerIdPlaceholder = "<#ISSUER_ID#>" +let matchRepoPlaceholder = "git@github.com:{organization}/{repo}.git" + +let envMatchRepo = ProcessInfo.processInfo.environment["MATCH_REPO"] ?? "" +let envApiKey = ProcessInfo.processInfo.environment["API_KEY_ID"] ?? "" +let envIssuerId = ProcessInfo.processInfo.environment["ISSUER_ID"] ?? "" +let envTeamId = ProcessInfo.processInfo.environment["TEAM_ID"] ?? "" + +let fileManager = FileManager.default + +fileManager.replaceAllOccurrences(of: teamIdPlaceholder, to: envTeamId) +fileManager.replaceAllOccurrences(of: apiKeyIdPlaceholder, to: envApiKey) +fileManager.replaceAllOccurrences(of: issuerIdPlaceholder, to: envIssuerId) +fileManager.replaceAllOccurrences(of: matchRepoPlaceholder, to: envMatchRepo) diff --git a/set_up_test_testflight.sh b/set_up_test_testflight.sh deleted file mode 100644 index c1e1290e..00000000 --- a/set_up_test_testflight.sh +++ /dev/null @@ -1,12 +0,0 @@ -readonly CONSTANT_TEAM_ID="<#teamId#>" -readonly CONSTANT_API_KEY_ID="<#API_KEY_ID#>" -readonly CONSTANT_ISSUER_ID="<#ISSUER_ID#>" -readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" - -readonly WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) -MATCH_REPO_ESCAPED=$(echo "${MATCH_REPO//\//\\\/}") - -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/$TEAM_ID/g" {} + -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_API_KEY_ID/$API_KEY_ID/g" {} + -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_ISSUER_ID/$ISSUER_ID/g" {} + -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_MATCH_REPO/$MATCH_REPO_ESCAPED/g" {} +