|
34 | 34 | distribution: 'adopt' |
35 | 35 | java-version: '17' |
36 | 36 |
|
| 37 | + - name: Hydrate and Update Version |
| 38 | + id: android-version |
| 39 | + run: | |
| 40 | + git config --global user.name "${{ github.workflow }}" |
| 41 | + git config --global user.email "gh-actions@${{ github.repository_owner }}" |
| 42 | + |
| 43 | + git clone --branch=version https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} version |
| 44 | + cd version |
| 45 | +
|
| 46 | + # Read and increment version name |
| 47 | + IFS='.' read -r major minor patch < versionName.txt |
| 48 | + current_patch_version_name="$major.$minor.$patch" |
| 49 | + echo "VERSION_NAME=$current_patch_version_name" >> $GITHUB_OUTPUT |
| 50 | + |
| 51 | + next_patch=$((patch + 1)) |
| 52 | + next_patch_version_name="$major.$minor.$next_patch" |
| 53 | + echo "$next_patch_version_name" > versionName.txt |
| 54 | +
|
| 55 | + # Read and increment version code |
| 56 | + read -r version_code < versionCode.txt |
| 57 | + echo "VERSION_CODE=$version_code" >> $GITHUB_OUTPUT |
| 58 | + |
| 59 | + new_version_code=$((version_code + 1)) |
| 60 | + echo "$new_version_code" > versionCode.txt |
| 61 | +
|
| 62 | + # Force push to version branch |
| 63 | + git checkout --orphan temporary |
| 64 | + git add --all . |
| 65 | + git commit -am "[Auto] Update versionName: $next_patch_version_name & versionCode: $new_version_code ($(date +%Y-%m-%d.%H:%M:%S))" |
| 66 | + git branch -D version |
| 67 | + git branch -m version |
| 68 | + git push --force origin version |
| 69 | +
|
37 | 70 | - name: Prepare Build Keys |
38 | 71 | env: |
39 | 72 | ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }} |
|
46 | 79 | STORE_PASS: ${{ secrets.STORE_PASS }} |
47 | 80 | ALIAS: ${{ secrets.ALIAS }} |
48 | 81 | KEY_PASS: ${{ secrets.KEY_PASS }} |
| 82 | + VERSION_CODE: ${{ steps.android-version.outputs.VERSION_CODE }} |
| 83 | + VERSION_NAME: ${{ steps.android-version.outputs.VERSION_NAME }} |
49 | 84 | run: | |
50 | 85 | bash ./gradlew build --stacktrace |
51 | 86 | bash ./gradlew bundle --stacktrace |
|
0 commit comments