-
Notifications
You must be signed in to change notification settings - Fork 8
106 lines (92 loc) · 3.99 KB
/
nightly.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Nightly APK Build
on:
schedule:
- cron: "0 * * * *" # runs every 1 hour
workflow_dispatch:
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check for new commits
id: check_commits
run: |
LATEST_NIGHTLY=$(gh release list --exclude-drafts --limit 1 | awk 'tolower($0) ~ /nightly/ {print $1}' | cut -d'-' -f1)
LATEST_COMMIT=$(git rev-parse --short HEAD)
echo "Latest nightly: $LATEST_NIGHTLY"
echo "Current commit: $LATEST_COMMIT"
if [ "$LATEST_NIGHTLY" = "$LATEST_COMMIT" ]; then
echo "No new commits since last nightly build"
echo "skip_build=true" >> $GITHUB_OUTPUT
else
echo "New commits found, building new nightly"
echo "skip_build=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Setup Node.js
if: steps.check_commits.outputs.skip_build != 'true'
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Setup Java
if: steps.check_commits.outputs.skip_build != 'true'
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Install Dependencies
if: steps.check_commits.outputs.skip_build != 'true'
run: npm install
- name: Decode Keystore
if: steps.check_commits.outputs.skip_build != 'true'
run: |
echo "${{ secrets.KEYSTORE }}" | base64 --decode > android/app/keystore.jks
mkdir android/app/app
echo "${{ secrets.KEYSTORE }}" | base64 --decode > android/app/app/keystore.jks
- name: Create local.properties
if: steps.check_commits.outputs.skip_build != 'true'
env:
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
echo "$LOCAL_PROPERTIES" > android/gradle.local.properties
LATEST_NIGHTLY=$(gh release list --exclude-drafts --limit 1 | awk 'tolower($0) ~ /nightly/ {print $1}' | cut -d'-' -f1)
CHANGELOG=$(git log ${LATEST_NIGHTLY}..HEAD --pretty=format:"<strong>%h</strong> %s{NEWLINE}" | tr '\n' '\\n')
echo "CHANGELOG=$CHANGELOG" >> android/gradle.local.properties
- name: Build Android APK
if: steps.check_commits.outputs.skip_build != 'true'
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASS }}
KEY_PASSWORD: ${{ secrets.KEYSTORE_PASS }}
run: |
npm run build:android:nightly
- name: Delete Previous Nightly Releases
if: steps.check_commits.outputs.skip_build != 'true'
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
echo "Listing and deleting previous nightly releases"
for tag in $(gh release list --exclude-drafts --limit 100 | awk 'tolower($0) ~ /nightly/ {print $1}'); do
echo "Deleting release: $tag"
gh release delete "$tag" -y
done
- name: Create Nightly Release
if: steps.check_commits.outputs.skip_build != 'true'
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
COMMIT_ID=$(git rev-parse --short HEAD)
RELEASE_TAG="${COMMIT_ID}-nightly"
RELEASE_NAME="${COMMIT_ID}-nightly"
ORIGINAL_APK="android/app/build/outputs/apk/nightly/release/app-nightly-release.apk"
RENAMED_APK="GrooveLauncher_${RELEASE_TAG}.apk"
cp "$ORIGINAL_APK" "$RENAMED_APK"
echo "Creating release with tag $RELEASE_TAG"
gh release create "$RELEASE_TAG" "$RENAMED_APK" \
--title "$RELEASE_NAME" \
--notes "Nightly build for $(date)\n\n$(git log ${LATEST_NIGHTLY}..HEAD --pretty=format:"**%h** %s\n" | tr '\n' '\\n')" \
--prerelease