From cc1e8490746b637660963c01fda9b0365a3a81fc Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Wed, 8 Mar 2023 14:58:58 +0700 Subject: [PATCH 1/7] [316] Set project build number from CI in bitrise workflows --- bitrise.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bitrise.yml b/bitrise.yml index ebe78c74..b328a58f 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -30,6 +30,9 @@ workflows: - git-clone@6.1: {} - cache-pull@2: {} - cocoapods-install@2: {} + - set-xcode-build-number@1: + inputs: + - plist_path: Project/$BITRISE_SCHEME/Configurations/Plists/Info.plist - xcode-test@4.0: {} - fastlane-match@0: inputs: @@ -75,6 +78,9 @@ workflows: - git-clone@6.1: {} - cache-pull@2: {} - cocoapods-install@2: {} + - set-xcode-build-number@1: + inputs: + - plist_path: Project/$BITRISE_SCHEME/Configurations/Plists/Info.plist - xcode-test@4.0: {} - fastlane-match@0: inputs: @@ -120,6 +126,9 @@ workflows: - git-clone@6.1: {} - cache-pull@2: {} - cocoapods-install@2: {} + - set-xcode-build-number@1: + inputs: + - plist_path: Project/$BITRISE_SCHEME/Configurations/Plists/Info.plist - xcode-test@4.0: {} - fastlane-match@0: inputs: From d5280df88339f969409dfd62c1933960a2f34fbc Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Wed, 8 Mar 2023 15:25:50 +0700 Subject: [PATCH 2/7] [316] Use build number from github actions --- .github/workflows/deploy_app_store.yml | 4 ++ .../workflows/deploy_production_firebase.yml | 4 ++ .github/workflows/deploy_staging_firebase.yml | 4 ++ .../test_upload_build_to_test_flight.yml | 4 ++ fastlane/Fastfile.swift | 50 +++++++++---------- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/.github/workflows/deploy_app_store.yml b/.github/workflows/deploy_app_store.yml index a054675e..89be3476 100644 --- a/.github/workflows/deploy_app_store.yml +++ b/.github/workflows/deploy_app_store.yml @@ -72,6 +72,10 @@ jobs: run: bundle exec pod install shell: bash + - uses: yanamura/ios-bump-version@v1 + with: + build-number: ${{github.run_number}} + - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/deploy_production_firebase.yml b/.github/workflows/deploy_production_firebase.yml index ad71aed9..46decd00 100644 --- a/.github/workflows/deploy_production_firebase.yml +++ b/.github/workflows/deploy_production_firebase.yml @@ -69,6 +69,10 @@ jobs: run: bundle exec pod install shell: bash + - uses: yanamura/ios-bump-version@v1 + with: + build-number: ${{github.run_number}} + - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/deploy_staging_firebase.yml b/.github/workflows/deploy_staging_firebase.yml index fff0630a..de1532ae 100644 --- a/.github/workflows/deploy_staging_firebase.yml +++ b/.github/workflows/deploy_staging_firebase.yml @@ -75,6 +75,10 @@ jobs: run: bundle exec pod install shell: bash + - uses: yanamura/ios-bump-version@v1 + with: + build-number: ${{github.run_number}} + - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/test_upload_build_to_test_flight.yml b/.github/workflows/test_upload_build_to_test_flight.yml index 28baf490..95644ac6 100644 --- a/.github/workflows/test_upload_build_to_test_flight.yml +++ b/.github/workflows/test_upload_build_to_test_flight.yml @@ -62,6 +62,10 @@ jobs: env: MATCH_PASSWORD: ${{ secrets.MATCH_PASS }} + - uses: yanamura/ios-bump-version@v1 + with: + build-number: ${{github.run_number}} + - name: Build App and Distribute to AppStore run: bundle exec fastlane buildAndUploadToAppStore env: diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index a5377234..10b3aac9 100644 --- a/fastlane/Fastfile.swift +++ b/fastlane/Fastfile.swift @@ -80,7 +80,7 @@ class Fastfile: LaneFile { desc("Build Staging app and upload to Firebase") setAppVersion() - bumpBuild() +// bumpBuild() buildAdHocStagingLane() @@ -96,7 +96,7 @@ class Fastfile: LaneFile { desc("Build Production app and upload to Firebase") setAppVersion() - bumpBuild() +// bumpBuild() buildAdHocProductionLane() @@ -113,11 +113,11 @@ class Fastfile: LaneFile { setAppVersion() AppStoreAuthentication.connectAPIKey() - if Secret.bumpAppStoreBuildNumber { - bumpAppstoreBuild() - } else { - bumpBuild() - } +// if Secret.bumpAppStoreBuildNumber { +// bumpAppstoreBuild() +// } else { +// bumpBuild() +// } buildAppStoreLane() @@ -132,7 +132,7 @@ class Fastfile: LaneFile { desc("Build Production app and upload to TestFlight") setAppVersion() - bumpBuild() +// bumpBuild() buildAppStoreLane() @@ -196,21 +196,21 @@ class Fastfile: LaneFile { ) } - private func bumpBuild(buildNumber: Int = numberOfCommits()) { - desc("Set build number with number of commits") - incrementBuildNumber( - buildNumber: .userDefined(String(buildNumber)), - xcodeproj: .userDefined(Constant.projectPath) - ) - } - - private func bumpAppstoreBuild() { - desc("Set build number with App Store latest build") - let theLatestBuildNumber = latestTestflightBuildNumber( - appIdentifier: Constant.productionBundleId - ) + 1 - incrementBuildNumber( - buildNumber: .userDefined("\(theLatestBuildNumber)") - ) - } +// private func bumpBuild(buildNumber: Int = numberOfCommits()) { +// desc("Set build number with number of commits") +// incrementBuildNumber( +// buildNumber: .userDefined(String(buildNumber)), +// xcodeproj: .userDefined(Constant.projectPath) +// ) +// } +// +// private func bumpAppstoreBuild() { +// desc("Set build number with App Store latest build") +// let theLatestBuildNumber = latestTestflightBuildNumber( +// appIdentifier: Constant.productionBundleId +// ) + 1 +// incrementBuildNumber( +// buildNumber: .userDefined("\(theLatestBuildNumber)") +// ) +// } } From ac7505048ebebcd1d0b5c08db8e1f5aad3c21afa Mon Sep 17 00:00:00 2001 From: David Date: Wed, 19 Apr 2023 11:28:59 +0700 Subject: [PATCH 3/7] [316] Remove commented code --- fastlane/Fastfile.swift | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index 10b3aac9..6a0ac126 100644 --- a/fastlane/Fastfile.swift +++ b/fastlane/Fastfile.swift @@ -80,7 +80,6 @@ class Fastfile: LaneFile { desc("Build Staging app and upload to Firebase") setAppVersion() -// bumpBuild() buildAdHocStagingLane() @@ -96,7 +95,6 @@ class Fastfile: LaneFile { desc("Build Production app and upload to Firebase") setAppVersion() -// bumpBuild() buildAdHocProductionLane() @@ -132,7 +130,6 @@ class Fastfile: LaneFile { desc("Build Production app and upload to TestFlight") setAppVersion() -// bumpBuild() buildAppStoreLane() @@ -195,22 +192,4 @@ class Fastfile: LaneFile { versionNumber: .userDefined(Constant.manualVersion) ) } - -// private func bumpBuild(buildNumber: Int = numberOfCommits()) { -// desc("Set build number with number of commits") -// incrementBuildNumber( -// buildNumber: .userDefined(String(buildNumber)), -// xcodeproj: .userDefined(Constant.projectPath) -// ) -// } -// -// private func bumpAppstoreBuild() { -// desc("Set build number with App Store latest build") -// let theLatestBuildNumber = latestTestflightBuildNumber( -// appIdentifier: Constant.productionBundleId -// ) + 1 -// incrementBuildNumber( -// buildNumber: .userDefined("\(theLatestBuildNumber)") -// ) -// } } From e9f0de5e47e6c8dd472758c12e18393ca3098fed Mon Sep 17 00:00:00 2001 From: David Date: Wed, 19 Apr 2023 14:15:29 +0700 Subject: [PATCH 4/7] [316] Update workflows ${{ github.run_number }} --- .github/workflows/deploy_app_store.yml | 2 +- .github/workflows/deploy_production_firebase.yml | 2 +- .github/workflows/deploy_staging_firebase.yml | 2 +- .github/workflows/test_upload_build_to_test_flight.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy_app_store.yml b/.github/workflows/deploy_app_store.yml index 89be3476..e3f367df 100644 --- a/.github/workflows/deploy_app_store.yml +++ b/.github/workflows/deploy_app_store.yml @@ -74,7 +74,7 @@ jobs: - uses: yanamura/ios-bump-version@v1 with: - build-number: ${{github.run_number}} + build-number: ${{ github.run_number }} - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/deploy_production_firebase.yml b/.github/workflows/deploy_production_firebase.yml index 46decd00..672c6953 100644 --- a/.github/workflows/deploy_production_firebase.yml +++ b/.github/workflows/deploy_production_firebase.yml @@ -71,7 +71,7 @@ jobs: - uses: yanamura/ios-bump-version@v1 with: - build-number: ${{github.run_number}} + build-number: ${{ github.run_number }} - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/deploy_staging_firebase.yml b/.github/workflows/deploy_staging_firebase.yml index de1532ae..18de9850 100644 --- a/.github/workflows/deploy_staging_firebase.yml +++ b/.github/workflows/deploy_staging_firebase.yml @@ -77,7 +77,7 @@ jobs: - uses: yanamura/ios-bump-version@v1 with: - build-number: ${{github.run_number}} + build-number: ${{ github.run_number }} - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/test_upload_build_to_test_flight.yml b/.github/workflows/test_upload_build_to_test_flight.yml index 95644ac6..f1d7050b 100644 --- a/.github/workflows/test_upload_build_to_test_flight.yml +++ b/.github/workflows/test_upload_build_to_test_flight.yml @@ -64,7 +64,7 @@ jobs: - uses: yanamura/ios-bump-version@v1 with: - build-number: ${{github.run_number}} + build-number: ${{ github.run_number }} - name: Build App and Distribute to AppStore run: bundle exec fastlane buildAndUploadToAppStore From ea55da98dce394180432635d60cd6418af8a8e38 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 25 Apr 2023 15:06:13 +0700 Subject: [PATCH 5/7] [316] Update syntax Remove redundant code --- .github/workflows/deploy_app_store.yml | 2 +- .github/workflows/deploy_production_firebase.yml | 2 +- .github/workflows/deploy_staging_firebase.yml | 2 +- .github/workflows/test_upload_build_to_test_flight.yml | 2 +- fastlane/Fastfile.swift | 6 ------ 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy_app_store.yml b/.github/workflows/deploy_app_store.yml index e3f367df..89be3476 100644 --- a/.github/workflows/deploy_app_store.yml +++ b/.github/workflows/deploy_app_store.yml @@ -74,7 +74,7 @@ jobs: - uses: yanamura/ios-bump-version@v1 with: - build-number: ${{ github.run_number }} + build-number: ${{github.run_number}} - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/deploy_production_firebase.yml b/.github/workflows/deploy_production_firebase.yml index 672c6953..46decd00 100644 --- a/.github/workflows/deploy_production_firebase.yml +++ b/.github/workflows/deploy_production_firebase.yml @@ -71,7 +71,7 @@ jobs: - uses: yanamura/ios-bump-version@v1 with: - build-number: ${{ github.run_number }} + build-number: ${{github.run_number}} - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/deploy_staging_firebase.yml b/.github/workflows/deploy_staging_firebase.yml index 18de9850..de1532ae 100644 --- a/.github/workflows/deploy_staging_firebase.yml +++ b/.github/workflows/deploy_staging_firebase.yml @@ -77,7 +77,7 @@ jobs: - uses: yanamura/ios-bump-version@v1 with: - build-number: ${{ github.run_number }} + build-number: ${{github.run_number}} - name: Build and Test run: bundle exec fastlane buildAndTest diff --git a/.github/workflows/test_upload_build_to_test_flight.yml b/.github/workflows/test_upload_build_to_test_flight.yml index f1d7050b..95644ac6 100644 --- a/.github/workflows/test_upload_build_to_test_flight.yml +++ b/.github/workflows/test_upload_build_to_test_flight.yml @@ -64,7 +64,7 @@ jobs: - uses: yanamura/ios-bump-version@v1 with: - build-number: ${{ github.run_number }} + build-number: ${{github.run_number}} - name: Build App and Distribute to AppStore run: bundle exec fastlane buildAndUploadToAppStore diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index 6a0ac126..d6139b37 100644 --- a/fastlane/Fastfile.swift +++ b/fastlane/Fastfile.swift @@ -111,12 +111,6 @@ class Fastfile: LaneFile { setAppVersion() AppStoreAuthentication.connectAPIKey() -// if Secret.bumpAppStoreBuildNumber { -// bumpAppstoreBuild() -// } else { -// bumpBuild() -// } - buildAppStoreLane() Distribution.uploadToAppStore() From b3de306d646eb5715a2148e4fae9555f7728c6f5 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 25 Apr 2023 15:22:31 +0700 Subject: [PATCH 6/7] [316] Add set the build version in CodeMagic --- codemagic.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/codemagic.yaml b/codemagic.yaml index 58272b88..6bd288a2 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -22,6 +22,13 @@ workflows: script: bundle install --path vendor/bundle - name: Install Pods Dependencies script: bundle exec pod install + - name: Set the build version + script: | + #!/bin/sh + set -e + set -x + cd $CM_BUILD_DIR + agvtool new-version -all $(($BUILD_NUMBER + 1)) - name: Build and Test script: bundle exec fastlane buildAndTest - name: Match Ad-hoc @@ -54,6 +61,13 @@ workflows: script: bundle install --path vendor/bundle - name: Install Pods Dependencies script: bundle exec pod install + - name: Set the build version + script: | + #!/bin/sh + set -e + set -x + cd $CM_BUILD_DIR + agvtool new-version -all $(($BUILD_NUMBER + 1)) - name: Build and Test script: bundle exec fastlane buildAndTest - name: Match Ad-hoc @@ -86,6 +100,13 @@ workflows: script: bundle install --path vendor/bundle - name: Install Pods Dependencies script: bundle exec pod install + - name: Set the build version + script: | + #!/bin/sh + set -e + set -x + cd $CM_BUILD_DIR + agvtool new-version -all $(($BUILD_NUMBER + 1)) - name: Build and Test script: bundle exec fastlane buildAndTest - name: Match AppStore From d3c55a5032148982f3ab18967215d44f13a5356c Mon Sep 17 00:00:00 2001 From: David Date: Tue, 25 Apr 2023 15:35:35 +0700 Subject: [PATCH 7/7] [316] Update Bitrise Wiki about BUILD NUMBER OFFSET --- .github/wiki/Bitrise.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/wiki/Bitrise.md b/.github/wiki/Bitrise.md index 878c9e21..763fcbe8 100644 --- a/.github/wiki/Bitrise.md +++ b/.github/wiki/Bitrise.md @@ -34,6 +34,10 @@ Out of the box, the Bitrise Template has the following workflows and steps: - MATCH_REPO_URL > Link to a repository that contains your Fastlane Match it can be either HTTPS or SSH link (e.g., https://github.com/nimblehq/fastlane-match.git) +- BUILD NUMBER OFFSET + +> Set this variable value in the **Set Xcode Project Build Number** step in Bitrise in case you switch to Bitrise from another CI/CD and want to keep the build number of the application. + ### Workflow Environment Variables All four workflows have their own variables: @@ -52,14 +56,14 @@ All four workflows have their own variables: ## Installation 1. Follow the setup instruction in [`README.md`](https://github.com/nimblehq/ios-templates#readme). -2. To connect your repository to Bitrise please follow the instruction in this page: [Adding a new app](https://devcenter.bitrise.io/en/getting-started/adding-your-first-app.html). -3. Make sure the option where the `bitrise.yml` locate is set to `Store in-app repository`. +2. To connect your repository to Bitrise, please follow the instruction on this page: [Adding a new app](https://devcenter.bitrise.io/en/getting-started/adding-your-first-app.html). +3. Ensure the option where the `bitrise.yml` is located is set to `Store in-app repository`.

Bitrise Store in-app repository

4. Provide all the required variables and secrets. -> Final project directory structure +> The final project directory structure ``` ROOT ├── ExampleApp.xcworkspace