Skip to content

Commit aabbc90

Browse files
committed
ci: release nightly builds on all changes
1 parent 0ee7056 commit aabbc90

1 file changed

Lines changed: 47 additions & 68 deletions

File tree

.github/workflows/ci-android.yml

Lines changed: 47 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,79 @@
1-
name: Build APK and root module (and create nightly release)
1+
name: Android CI
22

33
on:
44
push:
55
branches:
66
- '*'
77
paths:
88
- '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
209
workflow_call:
2110

2211
jobs:
23-
build-debug-apk:
12+
build:
2413
runs-on: ubuntu-latest
14+
outputs:
15+
short_sha: ${{ steps.vars.outputs.short_sha }}
2516
steps:
2617
- uses: actions/checkout@v4
2718
with:
2819
submodules: true
2920
- uses: actions/setup-java@v4
3021
with:
31-
distribution: 'zulu'
22+
distribution: zulu
3223
java-version: 21
3324
- 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
3637
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
3941
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:
4346
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
4648
permissions:
4749
contents: write
4850
steps:
4951
- uses: actions/checkout@v4
5052
- 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
6957
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
7461
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)")
9066
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:
9773
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9874
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

Comments
 (0)