|
1 | | -name: Build APK and root module (and create nightly release) |
| 1 | +name: Android CI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - '*' |
7 | 7 | paths: |
8 | 8 | - 'android/**' |
9 | | - workflow_dispatch: |
10 | | - inputs: |
11 | | - release: |
12 | | - description: 'Create a nightly release' |
13 | | - required: true |
14 | | - type: boolean |
15 | | - default: false |
16 | | - custom_notes: |
17 | | - description: 'Custom updates to add to What''s Changed section' |
18 | | - required: false |
19 | | - type: string |
20 | 9 | workflow_call: |
21 | 10 |
|
22 | 11 | jobs: |
23 | | - build-debug-apk: |
| 12 | + build: |
24 | 13 | runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + short_sha: ${{ steps.vars.outputs.short_sha }} |
25 | 16 | steps: |
26 | 17 | - uses: actions/checkout@v4 |
27 | 18 | with: |
28 | 19 | submodules: true |
29 | 20 | - uses: actions/setup-java@v4 |
30 | 21 | with: |
31 | | - distribution: 'zulu' |
| 22 | + distribution: zulu |
32 | 23 | java-version: 21 |
33 | 24 | - uses: gradle/actions/setup-gradle@v4 |
34 | | - - name: Build debug APK |
35 | | - run: ./gradlew assembleDebug |
| 25 | + - name: Decode keystore |
| 26 | + run: echo "${{ secrets.RELEASE_KEYSTORE_FILE }}" | base64 --decode > android/release.keystore |
| 27 | + - name: Create local.properties |
| 28 | + run: | |
| 29 | + cat <<EOF > android/local.properties |
| 30 | + RELEASE_STORE_FILE=release.keystore |
| 31 | + RELEASE_STORE_PASSWORD=${{ secrets.RELEASE_STORE_PASSWORD }} |
| 32 | + RELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }} |
| 33 | + RELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }} |
| 34 | + EOF |
| 35 | + - name: Build |
| 36 | + run: ./gradlew packageReleaseArtifacts |
36 | 37 | working-directory: android |
37 | | - - name: Upload artifact |
38 | | - uses: actions/upload-artifact@v4 |
| 38 | + - id: vars |
| 39 | + run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 40 | + - uses: actions/upload-artifact@v4 |
39 | 41 | with: |
40 | | - name: Debug APK |
41 | | - path: android/app/build/outputs/apk/**/*.apk |
42 | | - nightly-release: |
| 42 | + name: release-artifacts |
| 43 | + path: release/* |
| 44 | + |
| 45 | + release: |
43 | 46 | runs-on: ubuntu-latest |
44 | | - if: github.event_name == 'push' && github.ref == 'refs/heads/release-nightly' || github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true' |
45 | | - needs: build-debug-apk |
| 47 | + needs: build |
46 | 48 | permissions: |
47 | 49 | contents: write |
48 | 50 | steps: |
49 | 51 | - uses: actions/checkout@v4 |
50 | 52 | - uses: actions/download-artifact@v4 |
51 | | - - name: Export APK_NAME for later use |
52 | | - run: echo "APK_NAME=LibrePods-$(echo ${{ github.sha }} | cut -c1-7).apk" >> $GITHUB_ENV |
53 | | - - name: Rename .apk file |
54 | | - run: mv "./Debug APK/debug/"*.apk "./$APK_NAME" |
55 | | - - name: Decode keystore file |
56 | | - run: echo "${{ secrets.DEBUG_KEYSTORE_FILE }}" | base64 --decode > debug.keystore |
57 | | - - name: Install apksigner |
58 | | - run: sudo apt-get update && sudo apt-get install -y apksigner |
59 | | - - name: Sign APK |
60 | | - run: | |
61 | | - apksigner sign --ks debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android --key-pass pass:android "./$APK_NAME" |
62 | | - - name: Verify APK |
63 | | - run: apksigner verify "./$APK_NAME" |
64 | | - - name: Fetch the latest non-nightly release tag |
65 | | - id: fetch-tag |
66 | | - run: echo "::set-output name=tag::$(git describe --tags $(git rev-list --tags --max-count=1))" |
67 | | - - name: Retrieve commits since the last release |
68 | | - id: get-commits |
| 53 | + with: |
| 54 | + name: release-artifacts |
| 55 | + path: artifacts |
| 56 | + - id: prev |
69 | 57 | run: | |
70 | | - COMMITS=$(git log ${{ steps.fetch-tag.outputs.tag }}..HEAD --pretty=format:"- %s (%h)" --abbrev-commit) |
71 | | - echo "::set-output name=commits::${COMMITS}" |
72 | | - - name: Prepare release notes |
73 | | - id: release-notes |
| 58 | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") |
| 59 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 60 | + - id: changelog |
74 | 61 | run: | |
75 | | - # Create a temporary file for release notes |
76 | | - NOTES_FILE=$(mktemp) |
77 | | - |
78 | | - # Process custom notes if they exist |
79 | | - if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.custom_notes }}" ]; then |
80 | | - CUSTOM_NOTES="${{ github.event.inputs.custom_notes }}" |
81 | | - |
82 | | - # Check if custom notes already have bullet points or GitHub-style formatting |
83 | | - if echo "$CUSTOM_NOTES" | grep -q "^\*\|^- \|http.*commit\|in #[0-9]\+"; then |
84 | | - # Already formatted, use as is |
85 | | - echo "$CUSTOM_NOTES" > "$NOTES_FILE" |
86 | | - else |
87 | | - # Add bullet point formatting |
88 | | - echo "- $CUSTOM_NOTES" > "$NOTES_FILE" |
89 | | - fi |
| 62 | + if [ -z "${{ steps.prev.outputs.tag }}" ]; then |
| 63 | + NOTES=$(git log --pretty=format:"- %s (%h)") |
| 64 | + else |
| 65 | + NOTES=$(git log ${{ steps.prev.outputs.tag }}..HEAD --pretty=format:"- %s (%h)") |
90 | 66 | fi |
91 | | - |
92 | | - echo "notes_file=$NOTES_FILE" >> $GITHUB_OUTPUT |
93 | | - - name: Zip root-module directory |
94 | | - run: sh ./build-magisk-module.sh |
95 | | - - name: Delete release if exist then create release |
96 | | - env: |
| 67 | + echo "notes<<EOF" >> $GITHUB_OUTPUT |
| 68 | + echo "$NOTES" >> $GITHUB_OUTPUT |
| 69 | + echo "EOF" >> $GITHUB_OUTPUT |
| 70 | + - id: tag |
| 71 | + run: echo "tag=nightly-${{ needs.build.outputs.short_sha }}" >> $GITHUB_OUTPUT |
| 72 | + - env: |
97 | 73 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
98 | 74 | run: | |
99 | | - gh release view "nightly" && gh release delete "nightly" -y --cleanup-tag |
100 | | - gh release create "nightly" "./$APK_NAME" "./btl2capfix.zip" -p -t "Nightly Release" --notes-file "${{ steps.release-notes.outputs.notes_file }}" --generate-notes |
| 75 | + gh release create "${{ steps.tag.outputs.tag }}" \ |
| 76 | + artifacts/* \ |
| 77 | + -t "Nightly ${{ needs.build.outputs.short_sha }}" \ |
| 78 | + --notes "${{ steps.changelog.outputs.notes }}" \ |
| 79 | + --prerelease |
0 commit comments