add new release apk #2
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 | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| pull_request: | |
| branches: [ "main", "master" ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build APK | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| 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: Cache Gradle packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Inject obfuscated API key | |
| env: | |
| CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} | |
| run: | | |
| python3 << 'PYEOF' | |
| import os | |
| api_key = os.environ.get('CURSEFORGE_API_KEY', '') | |
| xor_key = [0x4D, 0x6F, 0x64, 0x56, 0x61, 0x75, 0x6C, 0x74] | |
| obfuscated = [ord(c) ^ xor_key[i % len(xor_key)] for i, c in enumerate(api_key)] | |
| bytes_str = "{" + ", ".join(hex(b) for b in obfuscated) + "}" | |
| with open('app/src/main/java/com/modbundle/app/api/CurseForgeApi.java', 'r') as f: | |
| content = f.read() | |
| content = content.replace( | |
| 'KeyUtils.decode(new byte[]{0x50, 0x00, 0x00})', | |
| f'KeyUtils.decode(new byte[]{bytes_str})' | |
| ) | |
| with open('app/src/main/java/com/modbundle/app/api/CurseForgeApi.java', 'w') as f: | |
| f.write(content) | |
| print("Key injected!") | |
| PYEOF | |
| - name: Decode Keystore | |
| run: | | |
| echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > app/modbundle.jks | |
| - name: Build Debug APK | |
| run: ./gradlew assembleDebug --stacktrace | |
| - name: Build Release APK | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| run: ./gradlew assembleRelease --stacktrace | |
| - name: Upload Debug APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ModBundle-Debug | |
| path: app/build/outputs/apk/debug/app-debug.apk | |
| retention-days: 30 | |
| - name: Upload Release APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ModBundle-Release | |
| path: app/build/outputs/apk/release/app-release.apk | |
| retention-days: 30 |