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 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/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: 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 diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index a5377234..d6139b37 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() @@ -113,12 +111,6 @@ class Fastfile: LaneFile { setAppVersion() AppStoreAuthentication.connectAPIKey() - if Secret.bumpAppStoreBuildNumber { - bumpAppstoreBuild() - } else { - bumpBuild() - } - buildAppStoreLane() Distribution.uploadToAppStore() @@ -132,7 +124,6 @@ class Fastfile: LaneFile { desc("Build Production app and upload to TestFlight") setAppVersion() - bumpBuild() buildAppStoreLane() @@ -195,22 +186,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)") - ) - } }