|
| 1 | +--- |
| 2 | +name: Build |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + types: |
| 9 | + - opened |
| 10 | + - synchronize |
| 11 | + - reopened |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - master |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: Build |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: android-actions/setup-android@v3 |
| 28 | + with: |
| 29 | + cmdline-tools-version: 9477386 |
| 30 | + |
| 31 | + - uses: actions/setup-java@v4 |
| 32 | + with: |
| 33 | + java-version: 17 |
| 34 | + distribution: 'adopt' |
| 35 | + |
| 36 | + - name: Set up environment |
| 37 | + run: | |
| 38 | + echo "ANDROID_SDK_ROOT=$ANDROID_HOME" >> $GITHUB_ENV |
| 39 | + echo "COMMIT_PREFIX=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_ENV |
| 40 | +
|
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + submodules: recursive |
| 45 | + |
| 46 | + - name: Decode debug keystore |
| 47 | + env: |
| 48 | + DEBUG_KEYSTORE: ${{ secrets.DEBUG_KEYSTORE }} |
| 49 | + run: | |
| 50 | + if [ -z "$DEBUG_KEYSTORE" ] |
| 51 | + then |
| 52 | + echo "No debug keystore value" |
| 53 | + else |
| 54 | + echo $DEBUG_KEYSTORE > debug.keystore.base64 |
| 55 | + base64 --decode debug.keystore.base64 > debug.keystore |
| 56 | + sudo cp -f debug.keystore /root/.android/. |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Build artifact |
| 60 | + run: ./gradlew assemble |
| 61 | + |
| 62 | + - name: Copy artifact |
| 63 | + run: | |
| 64 | + mkdir moonlight-android |
| 65 | + cp app/build/outputs/apk/root/debug/app-root-debug.apk "moonlight-android/app-root-debug-${COMMIT_PREFIX}.apk" |
| 66 | + cp app/build/outputs/apk/nonRoot/debug/app-nonRoot-debug.apk "moonlight-android/app-nonRoot-debug-${COMMIT_PREFIX}.apk" |
| 67 | +
|
| 68 | + - name: Upload artifact |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: moonlight-android |
| 72 | + path: ${{ github.workspace }}/moonlight-android |
| 73 | + if-no-files-found: error |
| 74 | + |
| 75 | + release: |
| 76 | + name: Release |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: [build] |
| 79 | + if: github.ref == 'refs/heads/master' |
| 80 | + |
| 81 | + steps: |
| 82 | + - name: Checkout |
| 83 | + uses: actions/checkout@v4 |
| 84 | + |
| 85 | + - name: Download Artifacts |
| 86 | + uses: actions/download-artifact@v4 |
| 87 | + with: |
| 88 | + path: dist |
| 89 | + merge-multiple: true |
| 90 | + |
| 91 | + - name: Re-zip artifacts |
| 92 | + run: | |
| 93 | + cd dist |
| 94 | + COMMIT_PREFIX=$(echo ${{ github.sha }} | cut -c1-8) |
| 95 | + for artifact in *.apk |
| 96 | + do |
| 97 | + file_name="${artifact%.apk}" |
| 98 | + echo "-> Creating ${file_name//-${COMMIT_PREFIX}/}.zip" |
| 99 | + zip "${file_name//-${COMMIT_PREFIX}/}.zip" "${file_name}.apk" |
| 100 | + done |
| 101 | +
|
| 102 | + - name: Update Git Tag |
| 103 | + run: | |
| 104 | + git tag -f Pre-release |
| 105 | + git push -f origin Pre-release |
| 106 | +
|
| 107 | + - name: Create Release |
| 108 | + uses: ncipollo/release-action@v1 |
| 109 | + with: |
| 110 | + prerelease: true |
| 111 | + allowUpdates: true |
| 112 | + removeArtifacts: true |
| 113 | + replacesArtifacts: false |
| 114 | + tag: Pre-release |
| 115 | + artifacts: "dist/*.zip" |
0 commit comments