forked from aniyomiorg/aniyomi-preview
-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (144 loc) · 6.2 KB
/
build_app.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
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
name: Build job
permissions:
contents: write
on:
# Every week at 23:00 UTC
schedule:
- cron: '0 23 * * 6'
# Manual triggers
workflow_dispatch:
inputs:
git-ref:
description: Git Ref (Optional)
required: false
dry-run:
description: Creates a draft release
required: false
jobs:
build-app:
runs-on: ubuntu-latest
steps:
- name: Clone Repository (Latest)
uses: actions/checkout@v4
with:
repository: 'aniyomiorg/aniyomi'
fetch-depth: 0
if: github.event.inputs.git-ref == ''
- name: Clone Repository (Custom Ref)
uses: actions/checkout@v4
if: github.event.inputs.git-ref != ''
with:
repository: 'aniyomiorg/aniyomi'
fetch-depth: 0
ref: ${{ github.event.inputs.git-ref }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- name: Get previous release
id: last_release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
exclude_types: "draft|prerelease"
view_top: 1
- name: Prepare build
run: |
set -e
commit_count=$(git rev-list --count HEAD)
echo "COMMIT_COUNT=$commit_count" >> $GITHUB_ENV
current_sha=$(git rev-parse HEAD)
echo "CURRENT_SHA=$current_sha" >> $GITHUB_ENV
prev_commit_count=$(echo "${{ steps.last_release.outputs.tag_name }}" | sed -e "s/^r//")
commit_count_diff=$(expr $commit_count - $prev_commit_count)
[ $commit_count_diff != 0 ] || exit 1
commit_count_diff_plus_one=$(expr $commit_count_diff + 1)
prev_release_sha=$(git log --topo-order -n $commit_count_diff_plus_one --skip $commit_count_diff --max-count 1 --pretty=format:"%H")
echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_ENV
echo "COMMIT_LOGS<<{delimiter}
$(curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/aniyomiorg/aniyomi/compare/$prev_release_sha...$current_sha" \
| jq '[.commits[]|{message:(.commit.message | split("\n")), username:.author.login}]' \
| jq -r '.[]|"- \(.message | first) (@\(.username))"')
{delimiter}" >> $GITHUB_ENV
- name: Set ACRA properties
env:
acraUri: ${{ secrets.ACRA_URI }}
acraLogin: ${{ secrets.ACRA_LOGIN }}
acraPassword: ${{ secrets.ACRA_PASSWORD }}
run: |
echo "ACRA_URI=$acraUri" >> acra.properties
echo "ACRA_LOGIN=$acraLogin" >> acra.properties
echo "ACRA_PASSWORD=$acraPassword" >> acra.properties
- name: Build APK
uses: gradle/gradle-command-action@v2
with:
arguments: assembleStandardPreview
- name: Sign APK
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: app/build/outputs/apk/standard/preview
signingKeyBase64: ${{ secrets.DEBUG_KEYSTORE }}
alias: androiddebugkey
keyStorePassword: android
env:
BUILD_TOOLS_VERSION: "34.0.0"
- name: Upload Proguard mapping file
uses: actions/upload-artifact@v3
with:
name: mapping.txt
path: app/build/outputs/mapping/standardPreview/mapping.txt
- name: Clean up build artifacts
run: |
set -e
cp app/build/outputs/apk/standard/preview/app-standard-universal-preview-signed.apk aniyomi-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum aniyomi-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/preview/app-standard-arm64-v8a-preview-signed.apk aniyomi-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum aniyomi-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/preview/app-standard-armeabi-v7a-preview-signed.apk aniyomi-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum aniyomi-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/preview/app-standard-x86-preview-signed.apk aniyomi-x86-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum aniyomi-x86-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_X86_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/preview/app-standard-x86_64-preview-signed.apk aniyomi-x86_64-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum aniyomi-x86_64-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_X86_64_SHA=$sha" >> $GITHUB_ENV
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: r${{ env.COMMIT_COUNT }}
name: Aniyomi Preview r${{ env.COMMIT_COUNT }}
body: |
### Commits
https://github.com/aniyomiorg/aniyomi/compare/${{ env.PREV_RELEASE_SHA }}...${{ env.CURRENT_SHA }}
${{ env.COMMIT_LOGS }}
---
### Checksums
| Variant | SHA-256 |
| ------- | ------- |
| Universal | ${{ env.APK_UNIVERSAL_SHA }}
| arm64-v8a | ${{ env.APK_ARM64_V8A_SHA }}
| armeabi-v7a | ${{ env.APK_ARMEABI_V7A_SHA }}
| x86 | ${{ env.APK_X86_SHA }}
| x86_64 | ${{ env.APK_X86_64_SHA }} |
files: |
aniyomi-r${{ env.COMMIT_COUNT }}.apk
aniyomi-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk
aniyomi-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk
aniyomi-x86-r${{ env.COMMIT_COUNT }}.apk
aniyomi-x86_64-r${{ env.COMMIT_COUNT }}.apk
draft: ${{ github.event.inputs.dry-run != '' }}
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prune old releases
uses: dev-drprasad/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
keep_latest: 28
delete_tags: true