Skip to content

Commit

Permalink
chore: updated push pipeline to configure automatic versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
AsCress committed May 31, 2024
1 parent 6552dc9 commit aa22daa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/push-event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- development
- versions

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -18,6 +19,8 @@ jobs:
steps:
- name: Download repository
uses: actions/checkout@v3
with:
ref: versions

- uses: actions/cache@v4
with:
Expand All @@ -34,6 +37,41 @@ jobs:
distribution: 'adopt'
java-version: '17'

- name: Update version
id: update_version
run: |
version_name_file=versionName
version_name=$(sed -n '1p' $version_name_file)
IFS='.' read -r -a version_parts <<< "$version_name"
major=${version_parts[0]}
minor=${version_parts[1]}
patch=${version_parts[2]}
next_patch=$((patch + 1))
next_patch_version_name="$major.$minor.$next_patch"
echo "VERSION_NAME=$next_patch_version_name" >> $GITHUB_ENV
version_code_file=versionCode
version_code=$(sed -n '1p' $version_code_file)
new_version_code=$((version_code + 1))
echo "VERSION_CODE=$new_version_code" >> $GITHUB_ENV
echo "${{ env.VERSION_NAME }}" > $version_name_file
echo "${{ env.VERSION_CODE }}" > $version_code_file
git config --global user.name "${{ github.workflow }}"
git config --global user.email "gh-actions@${{ github.repository_owner }}"
git add .
git commit -m"Update versionName to ${{ env.VERSION_NAME }} and versionCode to ${{ env.VERSION_CODE }}"
git push origin versions
- name: Checkout development branch
uses: actions/checkout@v3
with:
ref: development

- name: Prepare Build Keys
env:
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "io.pslab"
minSdk = 24
targetSdk = 34
versionCode = 26
versionName = "3.1.2"
versionCode = System.getenv("VERSION_CODE")?.toInt() ?: 1
versionName = System.getenv("VERSION_NAME")
resConfigs("en","ru","ar","si","pl")
}

Expand Down

0 comments on commit aa22daa

Please sign in to comment.