Skip to content

Commit

Permalink
feat!: VersionName independent BuildNumber (#7)
Browse files Browse the repository at this point in the history
* Add BuildNumber Offset to Android Build

* Add BuildNumberOffset to iOS

* Add Documentation

* Update Build Number Addition Expression

* Remove unused script

* Increase Version in Readme
  • Loading branch information
Anton Borries authored May 15, 2023
1 parent a4560a5 commit 158a9bd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 65 deletions.
14 changes: 0 additions & 14 deletions .github/scripts/generate_build_number.sh

This file was deleted.

22 changes: 3 additions & 19 deletions .github/workflows/build_android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,9 @@ on:
required: false
default: false
type: boolean
majorFactor:
buildNumberOffset:
required: false
default: 100000000
type: number
minorFactor:
required: false
default: 1000000
type: number
patchFactor:
required: false
default: 10000
default: 0
type: number
lfs:
required: false
Expand Down Expand Up @@ -71,15 +63,7 @@ jobs:
- name: Set Build Number
shell: bash
run: |
file=./${{ inputs.appDirectory }}/pubspec.yaml
version=$(awk '/version/{print $NF}' "$file")
IFS='.' read -r -a numbers <<< "$version"
major=${numbers[0]}
minor=${numbers[1]}
IFS='+' read -r -a patchAndBuild <<< "${numbers[2]}"
patch=${patchAndBuild[0]}
buildNumber=$(($(($(((major * ${{ inputs.majorFactor }}) + (minor * ${{ inputs.minorFactor }}))) + (patch * ${{ inputs.patchFactor }}))) + $GITHUB_RUN_NUMBER))
buildNumber=$((${{ inputs.buildNumberOffset }} + $GITHUB_RUN_NUMBER))
echo BUILD_NUMBER=$buildNumber >> $GITHUB_ENV
- name: Setup Signing
env:
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/build_ios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
required: false
default: false
type: boolean
buildNumberOffset:
required: false
default: 0
type: number
runner:
required: false
type: string
Expand Down Expand Up @@ -51,15 +55,7 @@ jobs:
- name: Set Build Number
shell: bash
run: |
file=./${{ inputs.appDirectory }}/pubspec.yaml
version=$(awk '/version/{print $NF}' "$file")
IFS='.' read -r -a numbers <<< "$version"
major=${numbers[0]}
minor=${numbers[1]}
IFS='+' read -r -a patchAndBuild <<< "${numbers[2]}"
patch=${patchAndBuild[0]}
buildNumber=$(($(($(((major * 100000000) + (minor * 1000000))) + (patch * 10000))) + $GITHUB_RUN_NUMBER))
buildNumber=$((${{ inputs.buildNumberOffset }} + $GITHUB_RUN_NUMBER))
echo BUILD_NUMBER=$buildNumber >> $GITHUB_ENV
- name: Match SSH Key
run: |
Expand Down
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Workflows used at [ZWEIDENKER](https://zweidenker.de) to build and deploy Flutte

```yaml
quality:
uses: zweidenker/flutter_workflows/.github/workflows/melos_quality_checks.yaml@v1
uses: zweidenker/flutter_workflows/.github/workflows/melos_quality_checks.yaml@v2
with:
setup: true
lint: false
Expand All @@ -32,7 +32,7 @@ Performs quality checks for repositories using [melos](https://github.com/invert
```yaml
build_android:
needs: quality
uses: zweidenker/flutter_workflows/.github/workflows/build_android.yaml@v1
uses: zweidenker/flutter_workflows/.github/workflows/build_android.yaml@v2
with:
appDirectory: packages/app
buildApk: false
Expand Down Expand Up @@ -92,18 +92,16 @@ Also in `/path/to/app/android/fastlane/Fastfile` there should be the following l

### Inputs

| Name | Type | Description | Default | required |
|------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|
| appDirectory | `string` | Directory where the app is based on the repository root. eg `packages/app` | | * |
| buildApk | `boolean` | Should build an Apk | true | |
| buildBundle | `boolean` | Should build an App Bundle | true | |
| upload | `boolean` | Should upload the App to Google Play. Note this will also check if the current workflow does **not** run on a pull_request event | false | |
| archiveArtifacts | `boolean` | If the workflow should archive apks and aabs. This normally should only be needed for a first release build to upload manually to Google Play or for certain PRs | false | |
| runner | `string` | Github actions runner | ubuntu-latest | |
| lfs | `boolean` | Enable git lfs | false | |
| majorFactor | `number` | Custom factor for build number generation for major component | 100000000 | |
| minorFactor | `number` | Custom factor for build number generation for minor component | 1000000 | |
| patchFactor | `number` | Custom factor for build number generation for patch component | 10000 | |
| Name | Type | Description | Default | required |
|-------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|
| appDirectory | `string` | Directory where the app is based on the repository root. eg `packages/app` | | * |
| buildApk | `boolean` | Should build an Apk | true | |
| buildBundle | `boolean` | Should build an App Bundle | true | |
| upload | `boolean` | Should upload the App to Google Play. Note this will also check if the current workflow does **not** run on a pull_request event | false | |
| archiveArtifacts | `boolean` | If the workflow should archive apks and aabs. This normally should only be needed for a first release build to upload manually to Google Play or for certain PRs | false | |
| runner | `string` | Github actions runner | ubuntu-latest | |
| lfs | `boolean` | Enable git lfs | false | |
| buildNumberOffset | `number` | An Offset used to generate the BuildNumber. This will result in the build number being the offset + the Run Number of Github. This is only required if there are already builds on the Play Store in order to have an increasing Build Number. | 0 | |
### Secrets

| Name | Description | required |
Expand All @@ -120,7 +118,7 @@ Also in `/path/to/app/android/fastlane/Fastfile` there should be the following l

```yaml
build_ios:
uses: zweidenker/flutter_workflows/.github/workflows/build_ios.yaml@v1
uses: zweidenker/flutter_workflows/.github/workflows/build_ios.yaml@v2
with:
appDirectory: packages/app
fastlaneEnv: app
Expand Down Expand Up @@ -179,14 +177,15 @@ The following lanes are defined in `path/to/app/ios/fastlane/Fastfile`

### Inputs

| Name | Type | Description | Default | required |
|--------------|-----------|---------------------------------------------------------------------------------------------------------------------------------|---------------|----------|
| appDirectory | `string` | Directory where the app is based on the repository root. eg `packages/app` | | * |
| matchHost | `string` | Host that is used for fastlane match repository. This is needed, as ZWEIDENKER currently host our match repository on bitbucket | bitbucket.org | |
| fastlaneEnv | `string` | Fastlane Environment | | * |
| upload | `boolean` | Should upload the App to Testflight. Note this will also check if the current workflow does **not** run on a pull_request event | false | |
| runner | `string` | Github actions runner | macos-latest | |
| lfs | `boolean` | Enable git lfs | false | |
| Name | Type | Description | Default | required |
|-------------------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|
| appDirectory | `string` | Directory where the app is based on the repository root. eg `packages/app` | | * |
| matchHost | `string` | Host that is used for fastlane match repository. This is needed, as ZWEIDENKER currently host our match repository on bitbucket | bitbucket.org | |
| fastlaneEnv | `string` | Fastlane Environment | | * |
| upload | `boolean` | Should upload the App to Testflight. Note this will also check if the current workflow does **not** run on a pull_request event | false | |
| runner | `string` | Github actions runner | macos-latest | |
| lfs | `boolean` | Enable git lfs | false | |
| buildNumberOffset | `number` | An Offset used to generate the BuildNumber. This will result in the build number being the offset + the Run Number of Github. This is only required if there are already builds on the App Store in order to have an increasing Build Number. | 0 | |

| Name | Description | required |
|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|----------|
Expand Down

0 comments on commit 158a9bd

Please sign in to comment.