From 850fcf60d9aba228cf2d678482681880dcec9557 Mon Sep 17 00:00:00 2001 From: danemadsen Date: Tue, 9 Jul 2024 12:07:07 +1000 Subject: [PATCH] scripts --- .github/workflows/build-android.yml | 4 +++- .github/workflows/build-linux.yml | 4 +++- .github/workflows/build-macos.yml | 4 +++- .github/workflows/build-windows.yml | 5 ++++- scripts/update_build_number.bat | 2 +- scripts/update_build_number.sh | 2 +- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index c0485a6a..97747aed 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -27,7 +27,9 @@ jobs: flutter-version: '3.22.2' - name: Update Build Number - run: ./scripts/update_build_number.sh + run: | + commit_count=$(git rev-list --count HEAD) + sed -i "s/version: \(.*\)+.*/version: \1+$commit_count/" pubspec.yaml - name: Decode Keystore File env: diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index da4772bd..a1925881 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -21,7 +21,9 @@ jobs: flutter-version: '3.22.2' - name: Update Build Number - run: ./scripts/update_build_number.sh + run: | + commit_count=$(git rev-list --count HEAD) + sed -i "s/version: \(.*\)+.*/version: \1+$commit_count/" pubspec.yaml - name: Install dependencies run: | diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index abc74c7f..afb4544a 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -25,7 +25,9 @@ jobs: flutter-version: '3.22.2' - name: Update Build Number - run: ./scripts/update_build_number.sh + run: | + commit_count=$(git rev-list --count HEAD) + sed -i "s/version: \(.*\)+.*/version: \1+$commit_count/" pubspec.yaml - name: Install Apple Certificate uses: apple-actions/import-codesign-certs@v1 diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index b3660749..7f012661 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -21,7 +21,10 @@ jobs: flutter-version: '3.22.2' - name: Update Build Number - run: ./scripts/update_build_number.bat + run: | + git fetch --prune --unshallow + commit_count=$(git rev-list --count HEAD) + (Get-Content pubspec.yaml) -replace 'version: (.*)\+.*', 'version: $1+' + $commit_count | Set-Content pubspec.yaml - name: Install dependencies run: | diff --git a/scripts/update_build_number.bat b/scripts/update_build_number.bat index 451918b6..27e9ca2c 100644 --- a/scripts/update_build_number.bat +++ b/scripts/update_build_number.bat @@ -3,4 +3,4 @@ for /f %%i in ('git rev-list --count HEAD') do set commit_count=%%i :: Update the pubspec.yaml file with the new build number -powershell -Command "(gc ../pubspec.yaml) -replace 'version: (.*)\+.*', 'version: $1+%commit_count%' | Out-File -encoding ASCII ./pubspec.yaml" +powershell -Command "(gc ../pubspec.yaml) -replace 'version: (.*)\+.*', 'version: $1+%commit_count%' | Out-File -encoding ASCII ../pubspec.yaml" diff --git a/scripts/update_build_number.sh b/scripts/update_build_number.sh index 9682d845..ffd70647 100755 --- a/scripts/update_build_number.sh +++ b/scripts/update_build_number.sh @@ -4,4 +4,4 @@ commit_count=$(git rev-list --count HEAD) # Update the pubspec.yaml file with the new build number -sed -i '' "s/version: \(.*\)+.*/version: \1+$commit_count/" ./pubspec.yaml \ No newline at end of file +sed -i '' "s/version: \(.*\)+.*/version: \1+$commit_count/" ../pubspec.yaml \ No newline at end of file