From 197f7ebcdd7f65ddf83ec57b713c216476cde44e Mon Sep 17 00:00:00 2001 From: jidasetima Date: Thu, 24 Oct 2024 08:38:11 -0400 Subject: [PATCH] Improvement: Add version code check to main github workflow (#16) --- .github/workflows/main.yml | 24 ++++++++++++++++++++++++ app/build.gradle.kts | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d36a4c..5e08598 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,30 @@ jobs: - name: Build with Gradle run: ./gradlew build - run: echo "The build job's status is ${{ job.status }}." + check-version-code: + runs-on: ubuntu-latest + steps: + - name: Checkout and clone repository branch ${{ github.ref }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch the entire history, including all branches + - name: Extract version code from Pull Request branch ${{ github.ref }} + run: | + VERSION_PR=$(grep -oP '(?<=versionCode = )\d+' app/build.gradle.kts) + echo "version_pr=${VERSION_PR}" >> $GITHUB_ENV + - name: Extract version code from Main branch + run: | + git checkout main + VERSION_MAIN=$(grep -oP '(?<=versionCode = )\d+' app/build.gradle.kts) + echo "version_main=${VERSION_MAIN}" >> $GITHUB_ENV + - name: Compare ${{ github.ref }} branch and Main branch versions + run: | + if [ "$version_pr" -le "$version_main" ]; then + echo "VersionCode on PR branch ($version_pr) is not greater than on the main branch ($version_main)." + exit 1 + else + echo "VersionCode on PR branch ($version_pr) is greater than on the main branch ($version_main)." + fi unit-test: needs: build runs-on: ubuntu-latest diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 72917f0..03033c2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,8 +25,8 @@ android { applicationId = "com.jogasoft.moviefinder" minSdk = 24 targetSdk = 34 - versionCode = 11 - versionName = "0.0.11" + versionCode = 12 + versionName = "0.0.12" testInstrumentationRunner = "com.jogasoft.moviefinder.MovieFinderHiltTestRunner" vectorDrawables {