forked from timschneeb/RootlessJamesDSP
-
Notifications
You must be signed in to change notification settings - Fork 0
264 lines (223 loc) · 9.31 KB
/
build.yml
File metadata and controls
264 lines (223 loc) · 9.31 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: Build signed app
on:
pull_request:
branches:
- master
push:
branches:
- master
tags:
- v*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build:
name: Build app
runs-on: ubuntu-latest
strategy:
matrix:
flavor: [Rootless, Root]
steps:
- id: flavor
uses: ASzc/change-string-case-action@v5
with:
string: ${{ matrix.flavor }}
- name: Install packages
run: |
sudo apt update
sudo apt install rename
- name: Clone repo
uses: actions/checkout@v4
with:
submodules: true
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- name: Build release app
if: startsWith(github.ref, 'refs/tags/')
uses: gradle/gradle-command-action@v2
with:
arguments: assemble${{ matrix.flavor }}FullRelease
- name: Build preview app
if: "!startsWith(github.ref, 'refs/tags/')"
uses: gradle/gradle-command-action@v2
with:
arguments: assemble${{ matrix.flavor }}FullPreview
- name: Declare preview build type
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
set -x
echo "BUILD_TYPE=preview" >> $GITHUB_ENV
- name: Declare release build type
if: startsWith(github.ref, 'refs/tags/')
run: |
set -x
echo "BUILD_TYPE=release" >> $GITHUB_ENV
- name: Get tag name
if: startsWith(github.ref, 'refs/tags/')
run: |
set -x
echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Sign APKs
uses: ilharp/sign-android-release@v1.0.4
with:
buildToolsVersion: 35.0.0
releaseDir: app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}
signingKey: ${{ secrets.SIGNING_KEYSTORE }}
keyAlias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Rename build artifacts
run: |
set -e
ls -l app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}
rename -v 's/-unsigned-signed//g' app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*.apk
rm -f app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*unsigned*.apk || true
ls -l app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}
- name: Upload build artifact (universal)
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.flavor }}JamesDSP-universal-preview_apk"
path: app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*universal-${{ env.BUILD_TYPE }}-signed.apk
- name: Upload build artifact (x86)
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.flavor }}JamesDSP-x86-preview_apk"
path: app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*x86-${{ env.BUILD_TYPE }}-signed.apk
- name: Upload build artifact (x86_64)
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.flavor }}JamesDSP-x86_64-preview_apk"
path: app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*x86_64-${{ env.BUILD_TYPE }}-signed.apk
- name: Upload build artifact (armeabi-v7a)
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.flavor }}JamesDSP-armeabi-v7a-preview_apk"
path: app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*armeabi-v7a-${{ env.BUILD_TYPE }}-signed.apk
- name: Upload build artifact (arm64-v8a)
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.flavor }}JamesDSP-arm64-v8a-preview_apk"
path: app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*arm64-v8a-${{ env.BUILD_TYPE }}-signed.apk
- name: Deploy root flavor APKs to the server
if: ${{ steps.flavor.outputs.lowercase == 'root' && startsWith(github.ref, 'refs/tags/') && github.repository == 'timschneeb/RootlessJamesDSP' }}
uses: wlixcc/SFTP-Deploy-Action@v1.2.4
with:
username: 'tim'
server: 'srv1.timschneeberger.me'
ssh_private_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
local_path: "app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*universal-${{ env.BUILD_TYPE }}-signed.apk"
remote_path: '/srv/http/nightly.timschneeberger.me/jamesdsp-rootfull'
sftpArgs: '-o ConnectTimeout=5'
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION_TAG }}
name: RootlessJamesDSP ${{ env.VERSION_TAG }}
files: |
app/build/outputs/apk/${{ steps.flavor.outputs.lowercase }}Full/${{ env.BUILD_TYPE }}/*-signed.apk
overwrite_files: true
draft: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
finalize_release_notes:
name: Finalize release notes
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Ensure required CLI tools
run: |
set -euo pipefail
need_apt_update=0
if ! command -v gh >/dev/null 2>&1; then
need_apt_update=1
fi
if ! command -v jq >/dev/null 2>&1; then
need_apt_update=1
fi
if [ "$need_apt_update" -eq 1 ]; then
sudo apt-get update
fi
command -v gh >/dev/null 2>&1 || sudo apt-get install -y gh
command -v jq >/dev/null 2>&1 || sudo apt-get install -y jq
- name: Build downloads table from release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${GITHUB_REF#refs/tags/}"
gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json assets > assets.json
{
echo "> Note: The root version is unmaintained and does not have feature parity with the rootless version."
echo
echo "## Downloads"
echo
echo "| Variant | Architecture | Download |"
echo "| --- | --- | --- |"
variant_label="RootlessJamesDSP"
for arch in universal arm64-v8a armeabi-v7a x86_64 x86; do
asset_name="$(jq -r --arg arch "$arch" '.assets[] | select(.name | test("-rootless-full-" + $arch + "-release-signed\\.apk$")) | .name' assets.json | head -n 1)"
if [ -n "$asset_name" ] && [ "$asset_name" != "null" ]; then
download_url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}/${asset_name}"
echo "| ${variant_label} | ${arch} | [Download](${download_url}) |"
else
echo "| ${variant_label} | ${arch} | N/A |"
fi
done
} > release_downloads.md
- name: Build flat changelog from commits
run: |
set -euo pipefail
TAG="${GITHUB_REF#refs/tags/}"
PREV_TAG="$(git for-each-ref --sort=-creatordate --format='%(refname:short)' refs/tags | awk -v cur="$TAG" '$0 != cur { print; exit }')"
if [ -n "$PREV_TAG" ]; then
RANGE="${PREV_TAG}..${TAG}"
else
RANGE="$TAG"
fi
{
echo "## Changelog"
echo
if [ -n "$PREV_TAG" ]; then
echo "_Changes since ${PREV_TAG}_"
echo
fi
commit_count="$(git log --no-merges --oneline "$RANGE" | wc -l | tr -d '[:space:]')"
if [ "$commit_count" -eq 0 ]; then
echo "- No commit entries found."
else
git log --no-merges --pretty=format:'- %s ([`%h`](https://github.com/'"$GITHUB_REPOSITORY"'/commit/%H))' "$RANGE"
echo
fi
if [ -n "$PREV_TAG" ]; then
echo
echo "**Full Changelog**: https://github.com/${GITHUB_REPOSITORY}/compare/${PREV_TAG}...${TAG}"
fi
} > release_changelog.md
- name: Compose release notes
run: |
set -euo pipefail
cat release_downloads.md > release_notes.md
printf '\n' >> release_notes.md
cat release_changelog.md >> release_notes.md
- name: Update Release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${GITHUB_REF#refs/tags/}"
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --notes-file release_notes.md