rm backup.xml #87
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 CI & Release | |
| 'on': | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - v* | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: temurin | |
| cache: gradle | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew assembleRelease | |
| env: | |
| GITHUB_RUN_NUMBER: '${{ github.run_number }}' | |
| GITHUB_REF_NAME: '${{ github.ref_name }}' | |
| - name: Setup build tool version variable | |
| shell: bash | |
| run: > | |
| BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail | |
| -n 1) | |
| echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | |
| echo Last build tool version is: $BUILD_TOOL_VERSION | |
| - name: Sign APK | |
| uses: r0adkll/sign-android-release@v1 | |
| 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: '${{ env.BUILD_TOOL_VERSION }}' | |
| - name: Rename and Isolate Signed APK | |
| if: 'success() && startsWith(github.ref, ''refs/tags/'')' | |
| shell: bash | |
| run: | | |
| # 1. Create a clean directory | |
| mkdir -p final_binaries | |
| # 2. Get the source path from the previous step's output | |
| # Using quotes to prevent shell expansion errors | |
| SOURCE_FILE="${{ steps.sign_app.outputs.signedReleaseFile }}" | |
| # 3. Define the new name using the tag | |
| NEW_NAME="LyriSync-${{ github.ref_name }}.apk" | |
| TARGET_PATH="final_binaries/$NEW_NAME" | |
| # 4. Move the file | |
| if [ -f "$SOURCE_FILE" ]; then | |
| mv "$SOURCE_FILE" "$TARGET_PATH" | |
| echo "FINAL_APK=$TARGET_PATH" >> $GITHUB_ENV | |
| echo "Successfully prepared: $NEW_NAME" | |
| else | |
| echo "Error: Source APK not found at $SOURCE_FILE" | |
| exit 1 | |
| fi | |
| - name: Upload to GitHub Release | |
| if: 'startsWith(github.ref, ''refs/tags/'')' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: '${{ env.FINAL_APK }}' | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |