Skip to content

Commit

Permalink
Improvement: Add version code check to main github workflow (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
jidasetima authored Oct 24, 2024
1 parent 751d96d commit 197f7eb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 197f7eb

Please sign in to comment.