-
Notifications
You must be signed in to change notification settings - Fork 118
146 lines (121 loc) · 5.02 KB
/
ci-draft-release.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
name: Release app
on:
push:
branches:
- main
jobs:
check_wrapper:
name: Validate Gradle Wrapper
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/[email protected]
build:
name: Build app
needs: check_wrapper
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Setup Android SDK
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
- name: Write google-services.json
uses: DamianReeves/[email protected]
with:
path: app/google-services.json
contents: ${{ secrets.GOOGLE_SERVICE_JSON }}
write-mode: overwrite # optional, default is preserve
- name: Build app
uses: eskatos/gradle-command-action@v3
with:
arguments: assembleStandardRelease
- name: Sign APK
id: sign_app
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: app/build/outputs/apk/standard/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Get previous release
id: last_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Prepare build
run: |
set -e
current_sha=$(git rev-parse --short HEAD)
echo "CURRENT_SHA=$current_sha"
echo "CURRENT_SHA=$current_sha" >> $GITHUB_ENV
prev_release_sha=$(git rev-list -n 1 ${{ steps.last_release.outputs.release }})
echo "PREV_RELEASE_SHA=$prev_release_sha"
echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_ENV
echo "Url to compare: https://api.github.com/repos/nekomangaorg/neko/compare/$prev_release_sha...$current_sha"
echo "COMMIT_LOGS<<{delimiter}
$(curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/nekomangaorg/neko/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: Prep build artifacts for release
run: |
set -e
mv app/build/outputs/apk/standard/release/Neko-standard-universal-release-unsigned-signed.apk neko-universal.apk
sha=`sha256sum neko-universal.apk | awk '{ print $1 }'`
echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_ENV
echo "| Universal | $sha" >> CurrentChangeLog.MD
cp app/build/outputs/apk/standard/release/Neko-standard-arm64-v8a-release-unsigned-signed.apk neko-arm64-v8a.apk
sha=`sha256sum neko-arm64-v8a.apk | awk '{ print $1 }'`
echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/Neko-standard-armeabi-v7a-release-unsigned-signed.apk neko-armeabi-v7a.apk
sha=`sha256sum neko-armeabi-v7a.apk | awk '{ print $1 }'`
echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/Neko-standard-x86-release-unsigned-signed.apk neko-x86.apk
sha=`sha256sum neko-x86.apk | awk '{ print $1 }'`
echo "APK_X86_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/Neko-standard-x86_64-release-unsigned-signed.apk neko-x86_64.apk
sha=`sha256sum neko-x86_64.apk | awk '{ print $1 }'`
echo "APK_X86_64_SHA=$sha" >> $GITHUB_ENV
- name: Delete release draft
uses: hugo19941994/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
body: |
## 🥳 New
## 🏗️ Changes
## 🐜 Fixes
## 🛠️ Other
${{ env.COMMIT_LOGS }}
| 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 }}
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
replacesArtifacts: true
tag: "latest"
artifacts: "*.apk"