Bump com.google.devtools.ksp from 2.1.20-2.0.1 to 2.1.21-2.0.2 #200
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android Build | |
permissions: | |
contents: write | |
on: | |
workflow_dispatch: | |
push: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Important: get all tags! | |
- name: Get Latest Tag | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0) | |
echo "LATEST_TAG=${latest_tag}" >> $GITHUB_ENV | |
- name: Count Commits Since Latest Tag | |
run: | | |
# Get the number of commits since the latest tag | |
commits_since_tag=$(git rev-list ${LATEST_TAG}..HEAD --count) | |
echo "COMMITS_SINCE_TAG=${commits_since_tag}" >> $GITHUB_ENV | |
- name: Generate Version | |
run: | | |
# Extract version components | |
version_base="${LATEST_TAG#v}" | |
major=$(echo $version_base | cut -d. -f1) | |
minor=$(echo $version_base | cut -d. -f2) | |
patch=$(echo $version_base | cut -d. -f3) | |
# Increment patch by the number of commits since the last tag | |
new_patch=$((patch + $COMMITS_SINCE_TAG)) | |
# Construct the new version string | |
new_version="$major.$minor.$new_patch" | |
# Calculate the version code (e.g., 1.0.5 -> 10005) | |
version_code=$((major * 10000 + minor * 100 + new_patch)) | |
# Set environment variables | |
echo "NEW_VERSION_NAME=${new_version}" >> $GITHUB_ENV | |
echo "NEW_VERSION_CODE=${version_code}" >> $GITHUB_ENV | |
- name: Update build.gradle with new version code and version name | |
run: | | |
# Update versionCode and versionName in build.gradle | |
sed -i "s/versionCode [0-9]\+/versionCode ${NEW_VERSION_CODE}/" app/build.gradle | |
sed -i "s/versionName \"[^\"]*\"/versionName \"${NEW_VERSION_NAME}\"/" app/build.gradle | |
- name: Print Version | |
run: | | |
echo "Version Name: $NEW_VERSION_NAME" | |
echo "Version Code: $NEW_VERSION_CODE" | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: 21 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew assembleRelease | |
tree app/build/outputs/apk/release | |
- uses: r0adkll/sign-android-release@v1.0.4 | |
name: Sign app APK | |
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
id: sign_app | |
with: | |
releaseDirectory: app/build/outputs/apk/release | |
signingKeyBase64: ${{ secrets.KEYSTORE }} | |
alias: ${{ secrets.KEY_ALIAS }} | |
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }} | |
keyPassword: ${{ secrets.KEY_PASSWORD }} | |
env: | |
BUILD_TOOLS_VERSION: "35.0.0" | |
- name: Rename APK | |
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
run: | | |
ls -al app/build/outputs/apk/release | |
echo "Signed APK: ${{steps.sign_app.outputs.signedReleaseFile}}" | |
cp ${{steps.sign_app.outputs.signedReleaseFile}} KernelFlasher_${{ env.NEW_VERSION_CODE }}.apk | |
- name: Rename APK | |
if: github.repository != github.event.pull_request.head.repo.full_name && github.event_name == 'pull_request' | |
run: | | |
ls -al app/build/outputs/apk/release | |
cp ./app/build/outputs/apk/release/app-release-unsigned.apk KernelFlasher_${{ env.NEW_VERSION_CODE }}.apk | |
- name: Upload APK | |
uses: actions/upload-artifact@v4.3.5 | |
with: | |
name: KernelFlasher_${{ env.NEW_VERSION_CODE }} | |
path: KernelFlasher_${{ env.NEW_VERSION_CODE }}.apk | |
# - name: Rename apk | |
# run: | | |
# ls -al | |
# DATE=$(date +'%y.%m.%d') | |
# echo "TAG=$DATE" >> $GITHUB_ENV | |
# - name: Upload release | |
# uses: ncipollo/release-action@v1.14.0 | |
# with: | |
# allowUpdates: true | |
# removeArtifacts: true | |
# name: "1.${{ github.run_number }}.0" | |
# tag: "v1.${{ github.run_number }}.0" | |
# body: | | |
# Note: QMod KernelFlasher, support ksu-lkm | |
# artifacts: "*.apk" |