-
Notifications
You must be signed in to change notification settings - Fork 4
179 lines (173 loc) · 6.77 KB
/
main.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
170
171
172
173
174
175
176
177
178
179
name: CI
env:
TZ: Asia/Shanghai
on:
push:
paths-ignore:
- '/readme/*'
- '**/README.md'
- '.github/workflows/*'
- '!.github/workflows/main.yml'
pull_request:
paths-ignore:
- '/readme/*'
- '**/README.md'
- '.github/workflows/*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: init custom env
run: |
set -a
BUILD_NAME="${GITHUB_REPOSITORY#*/}"
if [[ ${GITHUB_REF} == refs/tags* ]]
then
CREATE_RELEASE="true"
BUILD_VERSION=${GITHUB_REF#refs/tags/}
RELEASE_BODY=$(./latest-changelog.sh $BUILD_VERSION |sed '1s/[,,]$//;1s/^\(.*\)$/### \1\n/')
if [[ -z "$RELEASE_BODY" ]]
then
RELEASE_BODY='### ${{ github.event.head_commit.message }}'
TG_CHANGELOG="$(echo "$RELEASE_BODY"|sed -n "s/### \(.*\)/\1/p" |sed -n '{;=;p}' | sed "N;s/\n/. /g")"
else
TG_CHANGELOG=$(./latest-changelog.sh $BUILD_VERSION |sed -n '{;=;p}' | sed "N;s/\n/. /g")
fi
elif [[ ${GITHUB_REF} == refs/pull* ]]
then
CREATE_RELEASE="false"
num=${GITHUB_REF#refs/pull/}
num=${num%/merge}
BUILD_VERSION=pr-${num}-"$(date +'%Y%m%d%H%M%S')"
else
CREATE_RELEASE="false"
BUILD_VERSION="$(date +'%Y%m%d%H%M%S')"
RELEASE_BODY=$(echo '${{ toJson(github.event.commits) }}' |jq -r 'map("### "+.message)|join("\n\n------\n")')
TG_CHANGELOG="$(echo "$RELEASE_BODY"|sed -n "s/### \(.*\)/\1/p" |sed -n '{;=;p}' | sed "N;s/\n/. /g")"
VERSION_PREFIX='内测版-'
fi
BUILD_NAME_WITH_VERSION="$BUILD_NAME-$BUILD_VERSION"
echo BUILD_NAME="$BUILD_NAME" >> .custom_env
echo BUILD_VERSION="$BUILD_VERSION" >> .custom_env
echo BUILD_NAME_WITH_VERSION="$BUILD_NAME_WITH_VERSION" >> .custom_env
echo CREATE_RELEASE="$CREATE_RELEASE" >> .custom_env
if test -n "$RELEASE_BODY"
then
echo 'RELEASE_BODY<<EOF' >> .custom_env
echo "$RELEASE_BODY" >> .custom_env
echo 'EOF' >> .custom_env
echo 'UPDATE_BODY<<EOF' >> .custom_env
envsubst < template-update.md >> .custom_env
echo >> .custom_env
echo 'EOF' >> .custom_env
fi
if [[ "$CREATE_RELEASE" == "true" && -n "${{ secrets.XPOSED_UPLOAD_TOKEN }}" && -n "${{ secrets.XPOSED_UPLOAD_REPO }}" ]]
then
echo CREATE_XPOSED_RELEASE="true" >> .custom_env
fi
if [[ "$CREATE_RELEASE" == "true" && -n "${{ secrets.TELEGRAM_TO }}" && -n "${{ secrets.TELEGRAM_TOKEN }}" ]]
then
echo SEND_TELEGRAM="true" >> .custom_env
fi
cat .custom_env
cat .custom_env >> $GITHUB_ENV
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Build with Gradle
run: |
./gradlew :hook:assembleRelease
- uses: AoEiuV020/sign-android-release@v2
name: Sign hook APK
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
if: ${{ env.SIGNING_KEY != '' }}
with:
releaseDirectory: build/.hook/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Build with Gradle
run: |
find ./build/.hook/outputs/apk/release -name '*.apk' -exec mv {} $BUILD_NAME_WITH_VERSION-hook.apk \;
- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: build
path: ${{ env.BUILD_NAME_WITH_VERSION }}*.apk
- name: create release
if: ${{ env.CREATE_RELEASE == 'true' }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.BUILD_VERSION }}
release_name: ${{ env.BUILD_VERSION }}
body: ${{ env.RELEASE_BODY }}
draft: true
prerelease: ${{ env.PRE_RELEASE == 'true' }}
- name: Upload hook
if: ${{ env.CREATE_RELEASE == 'true' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.BUILD_NAME_WITH_VERSION }}-hook.apk
asset_name: ${{ env.BUILD_NAME_WITH_VERSION }}-hook.apk
asset_content_type: application/zip
- name: public release
if: ${{ env.CREATE_RELEASE == 'true' }}
uses: AoEiuV020/publish-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
- name: create release
if: ${{ env.CREATE_XPOSED_RELEASE == 'true' }}
id: xposed_create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.XPOSED_UPLOAD_TOKEN }}
with:
owner: Xposed-Modules-Repo
repo: ${{ secrets.XPOSED_UPLOAD_REPO }}
commitish: main
tag_name: ${{ env.BUILD_VERSION }}
release_name: ${{ env.BUILD_VERSION }}
body: ${{ env.RELEASE_BODY }}
draft: true
prerelease: ${{ env.PRE_RELEASE == 'true' }}
- name: Upload hook
if: ${{ env.CREATE_XPOSED_RELEASE == 'true' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.XPOSED_UPLOAD_TOKEN }}
with:
upload_url: ${{ steps.xposed_create_release.outputs.upload_url }}
asset_path: ${{ env.BUILD_NAME_WITH_VERSION }}-hook.apk
asset_name: ${{ env.BUILD_NAME_WITH_VERSION }}-hook.apk
asset_content_type: application/zip
- name: public release
if: ${{ env.CREATE_XPOSED_RELEASE == 'true' }}
uses: AoEiuV020/publish-release@master
env:
GITHUB_TOKEN: ${{ secrets.XPOSED_UPLOAD_TOKEN }}
with:
owner: Xposed-Modules-Repo
repo: ${{ secrets.XPOSED_UPLOAD_REPO }}
release_id: ${{ steps.xposed_create_release.outputs.id }}
- name: Send commit to telegram
if: ${{ env.SEND_TELEGRAM == 'true' }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
disable_web_page_preview: true
message: ${{ env.UPDATE_BODY }}
document: ${{ env.BUILD_NAME_WITH_VERSION }}-hook.apk