Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#316] Use build number from CI/CD #451

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/wiki/Bitrise.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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`.
<p align="center">
<img src="assets/images/operations/bitrise/Bitrise-YML-Storage-Location.png" alt="Bitrise Store in-app repository" width="600"/>
</p>

4. Provide all the required variables and secrets.
> Final project directory structure
> The final project directory structure
```
ROOT
├── ExampleApp.xcworkspace
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/deploy_app_store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/deploy_production_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/deploy_staging_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_upload_build_to_test_flight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ workflows:
- [email protected]: {}
- cache-pull@2: {}
- cocoapods-install@2: {}
- set-xcode-build-number@1:
inputs:
- plist_path: Project/$BITRISE_SCHEME/Configurations/Plists/Info.plist
- [email protected]: {}
- fastlane-match@0:
inputs:
Expand Down Expand Up @@ -75,6 +78,9 @@ workflows:
- [email protected]: {}
- cache-pull@2: {}
- cocoapods-install@2: {}
- set-xcode-build-number@1:
inputs:
- plist_path: Project/$BITRISE_SCHEME/Configurations/Plists/Info.plist
- [email protected]: {}
- fastlane-match@0:
inputs:
Expand Down Expand Up @@ -120,6 +126,9 @@ workflows:
- [email protected]: {}
- cache-pull@2: {}
- cocoapods-install@2: {}
- set-xcode-build-number@1:
inputs:
- plist_path: Project/$BITRISE_SCHEME/Configurations/Plists/Info.plist
- [email protected]: {}
- fastlane-match@0:
inputs:
Expand Down
21 changes: 21 additions & 0 deletions codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 0 additions & 27 deletions fastlane/Fastfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class Fastfile: LaneFile {
desc("Build Staging app and upload to Firebase")

setAppVersion()
bumpBuild()

buildAdHocStagingLane()

Expand All @@ -96,7 +95,6 @@ class Fastfile: LaneFile {
desc("Build Production app and upload to Firebase")

setAppVersion()
bumpBuild()

buildAdHocProductionLane()

Expand All @@ -113,12 +111,6 @@ class Fastfile: LaneFile {

setAppVersion()
AppStoreAuthentication.connectAPIKey()
if Secret.bumpAppStoreBuildNumber {
bumpAppstoreBuild()
} else {
bumpBuild()
}

buildAppStoreLane()

Distribution.uploadToAppStore()
Expand All @@ -132,7 +124,6 @@ class Fastfile: LaneFile {
desc("Build Production app and upload to TestFlight")

setAppVersion()
bumpBuild()

buildAppStoreLane()

Expand Down Expand Up @@ -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)")
)
}
}
Loading