-
Notifications
You must be signed in to change notification settings - Fork 722
247 lines (230 loc) · 7.69 KB
/
build.yaml
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
name: build
on:
push:
tags:
- 'v*'
jobs:
changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout
if: ${{ !contains(github.ref, '+') }}
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: refs/heads/main
- name: Generate
if: ${{ !contains(github.ref, '+') }}
run: |
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
preTag=$(grep -oP '^## \K.*' CHANGELOG.md | head -n 1)
currentTag=""
for ((i = 0; i <= ${#tags[@]}; i++)); do
if (( i < ${#tags[@]} )); then
tag=${tags[$i]}
else
tag=""
fi
if [ -n "$currentTag" ]; then
if [ "$(echo -e "$currentTag\n$preTag" | sort -V | head -n 1)" == "$currentTag" ]; then
break
fi
fi
if [ -n "$currentTag" ]; then
echo "## $currentTag" >> NEW_CHANGELOG.md
echo "" >> NEW_CHANGELOG.md
if [ -n "$tag" ]; then
git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> NEW_CHANGELOG.md
else
git log --pretty=format:"%B" "$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> NEW_CHANGELOG.md
fi
echo "" >> NEW_CHANGELOG.md
fi
currentTag=$tag
done
cat CHANGELOG.md >> NEW_CHANGELOG.md
cat NEW_CHANGELOG.md > CHANGELOG.md
- name: Commit
if: ${{ !contains(github.ref, '+') }}
run: |
git add CHANGELOG.md
if ! git diff --cached --quiet; then
echo "Commit pushing"
git config --local user.email "[email protected]"
git config --local user.name "chen08209"
git commit -m "Update changelog"
git push
if [ $? -eq 0 ]; then
echo "Push succeeded"
else
echo "Push failed"
exit 1
fi
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: [ changelog ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# - platform: android
# os: ubuntu-latest
# - platform: windows
# os: windows-latest
# arch: amd64
- platform: linux
os: ubuntu-latest
arch: amd64
- platform: linux
os: ubuntu-latest
arch: arm64
# - platform: macos
# os: macos-13
# arch: amd64
# - platform: macos
# os: macos-latest
# arch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup JAVA
if: startsWith(matrix.platform,'android')
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Setup NDK
if: startsWith(matrix.platform,'android')
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26b
add-to-path: true
link-to-sdk: true
- name: Setup Android Signing
if: startsWith(matrix.platform,'android')
run: |
echo "${{ secrets.KEYSTORE }}" | base64 --decode > android/app/keystore.jks
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/local.properties
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/local.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/local.properties
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
cache-dependency-path: |
core/go.sum
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.x'
channel: 'stable'
cache: true
- name: Get Flutter Dependency
run: flutter pub get
- name: Setup
run: dart setup.dart ${{ matrix.platform }} ${{ matrix.arch && format('--arch {0}', matrix.arch) }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.platform }}${{ matrix.arch && format('-{0}', matrix.arch) }}
path: ./dist
overwrite: true
# upload:
# permissions: write-all
# needs: [ build ]
# runs-on: ubuntu-latest
# services:
# telegram-bot-api:
# image: aiogram/telegram-bot-api:latest
# env:
# TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
# TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
# ports:
# - 8081:8081
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Download
# uses: actions/download-artifact@v4
# with:
# path: ./dist/
# pattern: artifact-*
# merge-multiple: true
#
# - name: Generate release.md
# run: |
# tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
# preTag=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "")
# currentTag=""
# for ((i = 0; i <= ${#tags[@]}; i++)); do
# if (( i < ${#tags[@]} )); then
# tag=${tags[$i]}
# else
# tag=""
# fi
# if [ -n "$currentTag" ]; then
# if [ "$(echo -e "$currentTag\n$preTag" | sort -V | head -n 1)" == "$currentTag" ]; then
# break
# fi
# fi
# if [ -n "$currentTag" ]; then
# if [ -n "$tag" ]; then
# git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
# else
# git log --pretty=format:"%B" "$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
# fi
# echo "" >> release.md
# fi
# currentTag=$tag
# done
#
# - name: Push to telegram
# env:
# TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
# TAG: ${{ github.ref_name }}
# run: |
# python -m pip install --upgrade pip
# pip install requests
# python release.py
#
# - name: Patch release.md
# run: |
# version=$(echo "${{ github.ref_name }}" | sed 's/^v//')
# sed "s|VERSION|$version|g" ./.github/release_template.md >> release.md
#
# - name: Release
# if: ${{ !contains(github.ref, '+') }}
# uses: softprops/action-gh-release@v2
# with:
# files: ./dist/*
# body_path: './release.md'
#
# - name: Create Fdroid Source Dir
# if: ${{ !contains(github.ref, '+') }}
# run: |
# mkdir -p ./tmp
# cp ./dist/*android-arm64-v8a* ./tmp/ || true
# echo "Files copied successfully"
#
# - name: Push to fdroid repo
# if: ${{ !contains(github.ref, '+') }}
# uses: cpina/[email protected]
# env:
# SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
# with:
# source-directory: ./tmp/
# destination-github-username: chen08209
# destination-repository-name: FlClash-fdroid-repo
# user-name: 'github-actions[bot]'
# user-email: 'github-actions[bot]@users.noreply.github.com'
# target-branch: action-pr
# commit-message: Update from ${{ github.ref_name }}
# target-directory: /tmp/