From 5e16dca13a1bc068fc638891d02c3c3448d73a62 Mon Sep 17 00:00:00 2001 From: Vadim Date: Sat, 2 Sep 2023 12:18:01 +0200 Subject: [PATCH] increment build number by script --- .github/scripts/increment_build_number.sh | 7 +++++++ .github/workflows/build_apk.yml | 13 ++++++------- .github/workflows/create_release.yml | 15 +++++++-------- 3 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 .github/scripts/increment_build_number.sh diff --git a/.github/scripts/increment_build_number.sh b/.github/scripts/increment_build_number.sh new file mode 100644 index 0000000..cd2f60c --- /dev/null +++ b/.github/scripts/increment_build_number.sh @@ -0,0 +1,7 @@ +export newVersion="$1" + +if [[ -n "$newVersion" ]]; then + perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+)(\+)(\d+)$/$1.$ENV{'newVersion'}.$3.($4+1)/e' pubspec.yaml +else + echo "argument error" +fi diff --git a/.github/workflows/build_apk.yml b/.github/workflows/build_apk.yml index e61b38b..6acb464 100644 --- a/.github/workflows/build_apk.yml +++ b/.github/workflows/build_apk.yml @@ -27,6 +27,10 @@ jobs: runs-on: macos-11 timeout-minutes: 15 steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Connect private iap package uses: webfactory/ssh-agent@v0.8.0 if: ${{ inputs.include-iap }} @@ -35,13 +39,8 @@ jobs: - name: Override iap package with stub if: ${{ !inputs.include-iap }} - run: | - echo "\ndependency_overrides:\n m3_lightmeter_iap:\n path: iap" >> pubspec.yaml - - - uses: actions/checkout@v3 - with: - submodules: recursive - + run: bash ./.github/scripts/stub_iap.sh + - uses: actions/setup-java@v2 with: distribution: "zulu" diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index e0281e3..69a672b 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -46,6 +46,10 @@ jobs: runs-on: macos-11 timeout-minutes: 30 steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Connect private iap package uses: webfactory/ssh-agent@v0.8.0 if: ${{ inputs.include-iap }} @@ -54,12 +58,7 @@ jobs: - name: Override iap package with stub if: ${{ !inputs.include-iap }} - run: | - echo "\ndependency_overrides:\n m3_lightmeter_iap:\n path: iap" >> pubspec.yaml - - - uses: actions/checkout@v3 - with: - submodules: recursive + run: bash ./.github/scripts/stub_iap.sh - uses: actions/setup-java@v3 with: @@ -98,7 +97,7 @@ jobs: # Therefore here we have to increment it as well to build an apk with the same build number. - name: Increment build number & replace version number if: ${{ inputs.github-release }} - run: perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+)(\+)(\d+)$/$1."${{ github.event.inputs.version }}".$3.($4+1)/e' pubspec.yaml + run: bash ./.github/scripts/increment_build_number.sh ${{ github.event.inputs.version }} - name: Install Flutter uses: subosito/flutter-action@v2 @@ -160,7 +159,7 @@ jobs: submodules: recursive - name: Increment build number & replace version number - run: perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+)(\+)(\d+)$/$1."${{ github.event.inputs.version }}".$3.($4+1)/e' pubspec.yaml + run: bash ./.github/scripts/increment_build_number.sh ${{ github.event.inputs.version }} - name: Commit changes run: |