diff --git a/.github/scripts/generate_build_number.sh b/.github/scripts/generate_build_number.sh deleted file mode 100755 index 0f98c09..0000000 --- a/.github/scripts/generate_build_number.sh +++ /dev/null @@ -1,14 +0,0 @@ -# Pass in the pubspec.yaml file as the first argument -# Pass in the Build number as the second argument - -version=$(awk '/version/{print $NF}' "$1") - -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))) + $2)) - -echo "$buildNumber" diff --git a/.github/workflows/build_android.yaml b/.github/workflows/build_android.yaml index 5ab386e..ca11a19 100644 --- a/.github/workflows/build_android.yaml +++ b/.github/workflows/build_android.yaml @@ -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 @@ -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: diff --git a/.github/workflows/build_ios.yaml b/.github/workflows/build_ios.yaml index 9e4bb08..77937e6 100644 --- a/.github/workflows/build_ios.yaml +++ b/.github/workflows/build_ios.yaml @@ -19,6 +19,10 @@ on: required: false default: false type: boolean + buildNumberOffset: + required: false + default: 0 + type: number runner: required: false type: string @@ -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: | diff --git a/README.md b/README.md index c0a94e4..f746416 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 | @@ -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 @@ -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 | |--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|----------|