Merge pull request #1 from Dhangofa/dev #16
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: Build and Automate LSPosed Module Release | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: | |
| - 'v*' # Triggers the release block when a tag starting with 'v' is pushed | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Crucial permission that allows GitHub Actions to publish releases | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Java Development Kit (JDK) | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Compile Release APK using Gradle | |
| run: gradle assembleRelease -PversionCode=${{ github.run_number }} | |
| - name: Decode Permanent Keystore | |
| run: | | |
| cat << 'EOF' > encoded_key.txt | |
| ${{ secrets.KEYSTORE_BASE64 }} | |
| EOF | |
| sed -i '/---/d' encoded_key.txt | |
| tr -d '\r\n ' < encoded_key.txt | base64 --decode > release.keystore | |
| - name: Zipalign and Sign Release APK (V2 Signature) | |
| run: | | |
| BUILD_TOOLS_DIR=$(ls -d $ANDROID_HOME/build-tools/* | tail -1) | |
| $BUILD_TOOLS_DIR/zipalign -v -p 4 app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/app-release-aligned.apk | |
| $BUILD_TOOLS_DIR/apksigner sign --ks release.keystore --ks-pass pass:${{ secrets.KEYSTORE_PASSWORD }} --out app/build/outputs/apk/release/BatteryRemapper.apk app/build/outputs/apk/release/app-release-aligned.apk | |
| - name: Upload APK as Build Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: BatteryRemapper-Package | |
| path: app/build/outputs/apk/release/BatteryRemapper.apk | |
| compression-level: 0 | |
| # AUTOMATED DEPLOYMENT STEP | |
| - name: Create Public GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| if: startsWith(github.ref, 'refs/tags/v') # Ensures this ONLY runs on tag pushes | |
| with: | |
| files: app/build/outputs/apk/release/BatteryRemapper.apk | |
| generate_release_notes: true # Automatically generates a beautiful changelog | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |