-
Notifications
You must be signed in to change notification settings - Fork 20
161 lines (132 loc) · 6.68 KB
/
build_preview.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
name: Preview Builder
on:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build preview app
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare build
run: |
set -e
git fetch --tags
prev_release_sha=$(git log --oneline --decorate --tags --no-walk --pretty='%C(auto)%h' | head -n 1)
echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_ENV
current_sha=$(git log -1 --pretty='%C(auto)%h' | head -n 1)
echo "CURRENT_SHA=$current_sha" >> $GITHUB_ENV
echo "COMMIT_LOGS<<{delimiter}
$(curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/komikku-app/komikku/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 CHANGELOG
run: |
changelog="$(git log ${{ env.PREV_RELEASE_SHA }}..${{ env.CURRENT_SHA }} --pretty=format:'{{changelogtext}}%s (@%an){{!changelogtext}}')"
changelog="${changelog//$'%'/%25}"
changelog="${changelog//$'\n'/}"
changelog="${changelog//$'\r'/}"
changelog="${changelog//$'<'/}"
changelog="${changelog//$'>'/}"
changelog="${changelog//$'&'/}"
changelog="$(echo $changelog | sed -e 's/{{changelogtext}}/<changelogtext>/g')"
changelog="$(echo $changelog | sed -e 's/{{!changelogtext}}/<\/changelogtext>/g')"
changelog="<?xml version=\"1.0\" encoding=\"utf-8\"?><changelog bulletedList=\"true\"><changelogversion versionName=\"${{ github.run_number }}\" changeDate=\"\">$changelog</changelogversion></changelog>"
echo "CHANGELOG=$changelog" >> $GITHUB_ENV
- name: Setup Android SDK
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- name: Set up gradle
uses: gradle/actions/setup-gradle@v3
- name: Write Version.kt
uses: DamianReeves/[email protected]
with:
path: app/src/main/java/exh/Version.kt
contents: 'package exh const val syDebugVersion: String = "${{ github.run_number }}"'
write-mode: overwrite
- name: Write changelog_debug.xml
uses: DamianReeves/[email protected]
with:
path: app/src/main/res/raw/changelog_debug.xml
contents: "${{ env.CHANGELOG }}"
write-mode: overwrite
- name: Write google-services.json
uses: DamianReeves/[email protected]
with:
path: app/google-services.json
contents: ${{ secrets.GOOGLE_SERVICES_TEXT }}
write-mode: overwrite
- name: Build app
if: ${{ ! startsWith(github.ref, 'refs/tags/') && github.repository == 'komikku-app/komikku' }}
run: ./gradlew assembleStandardRelease testStandardReleaseUnitTest --stacktrace
- name: Sign Android Release
if: ${{ ! startsWith(github.ref, 'refs/tags/') && github.repository == 'komikku-app/komikku' }}
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: app/build/outputs/apk/standard/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Clean up build artifacts
if: ${{ ! startsWith(github.ref, 'refs/tags/') && github.repository == 'komikku-app/komikku' }}
run: |
set -e
mv app/build/outputs/apk/standard/release/app-standard-universal-release-unsigned-signed.apk Komikku-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned-signed.apk Komikku-arm64-v8a-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-arm64-v8a-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-armeabi-v7a-release-unsigned-signed.apk Komikku-armeabi-v7a-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-armeabi-v7a-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-x86-release-unsigned-signed.apk Komikku-x86-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-x86-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_X86_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-x86_64-release-unsigned-signed.apk Komikku-x86_64-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-x86_64-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_X86_64_SHA=$sha" >> $GITHUB_ENV
- name: Create release
if: ${{ ! startsWith(github.ref, 'refs/tags/') && github.repository == 'komikku-app/komikku' }}
uses: softprops/action-gh-release@v1
with:
tag_name: pre-release-${{ github.run_number }}
name: Komikku Preview Build ${{ github.run_number }}
body: |
### Commits
https://github.com/komikku-app/komikku/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: |
Komikku-pre-${{ github.run_number }}.apk
Komikku-arm64-v8a-pre-${{ github.run_number }}.apk
Komikku-armeabi-v7a-pre-${{ github.run_number }}.apk
Komikku-x86-pre-${{ github.run_number }}.apk
Komikku-x86_64-pre-${{ github.run_number }}.apk
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}