-
Notifications
You must be signed in to change notification settings - Fork 9
272 lines (242 loc) · 10.2 KB
/
update-adguardhome.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
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Update AdGuard Home
on:
workflow_dispatch:
schedule:
- cron: "0 17 * * *"
push:
branches:
- main
paths-ignore:
- "README.md"
- ".github/workflows/delete-old-workflows.yml"
- ".github/workflows/update-dashboard.yml"
- ".github/workflows/update-mihomo.yml"
- ".github/workflows/update-singbox.yml"
jobs:
go:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.go.outputs.version }}
steps:
- name: Get `Go` latest version
id: go
run: |
echo version=$(curl -sSL https://api.github.com/repos/actions/go-versions/releases/latest | jq -r '.tag_name | split("-")[0]') >> $GITHUB_OUTPUT
node:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.node.outputs.version }}
steps:
- name: Get `Node` latest version (LTS)
id: node
run: |
echo version=$(curl -sSL https://nodejs.org/dist/index.json | jq -r 'map(select(.lts != false)) | .[0].version') >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.release.outputs.release_version }}
release_time: ${{ steps.release.outputs.release_time }}
steps:
- name: Checkout `beta-v0.107`
uses: actions/checkout@v4
with:
repository: AdguardTeam/AdGuardHome
ref: beta-v0.107
fetch-depth: 0
- name: Get `AdGuard Home Release` version and time
id: release
run: |
release_version=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest | jq -r '.tag_name')
echo "release_version=$release_version" >> $GITHUB_OUTPUT
release_time=$(git log -1 --format=%cd --date=format:'%Y-%m-%d' ${release_version})
echo "release_time=$release_time" >> $GITHUB_OUTPUT
release_cross:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Linux
- { name: linux_amd64, goos: linux, goarch: amd64, goamd64: v1 }
- { name: linux_armv5, goos: linux, goarch: arm, goarm: 5 }
- { name: linux_armv6, goos: linux, goarch: arm, goarm: 6 }
- { name: linux_armv7, goos: linux, goarch: arm, goarm: 7 }
- { name: linux_arm64, goos: linux, goarch: arm64 }
- { name: linux_mips_softfloat, goos: linux, goarch: mips, gomips: softfloat }
- { name: linux_mipsle_softfloat, goos: linux, goarch: mipsle, gomips: softfloat }
# Windows
- { name: windows_amd64, goos: windows, goarch: amd64, goamd64: v1 }
- { name: windows_arm64, goos: windows, goarch: arm64 }
fail-fast: false
needs:
- go
- node
- release
env:
release_VERSION: ${{ needs.release.outputs.release_version }}
steps:
- name: Checkout `beta-v0.107`
uses: actions/checkout@v4
with:
repository: AdguardTeam/AdGuardHome
ref: beta-v0.107
- name: Setup `Go`
uses: actions/setup-go@v5
with:
go-version: ${{ needs.go.outputs.version }}
- name: Adapt `Go` version
run: |
go get go@${{ needs.go.outputs.version }}
go mod tidy
- name: Setup `Node`
uses: actions/setup-node@v4
with:
node-version: ${{ needs.node.outputs.version }}
- name: Setup `Snapcraft`
run: |
sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft
- name: Build `AdGuard Home Release`
id: build
run: |
make SIGN=0 VERBOSE=1 ARCH=${{ matrix.goarch }} OS=${{ matrix.goos }} CHANNEL=release VERSION=${{ env.release_VERSION }} GOTOOLCHAIN=local build-release
- name: Upload files to workspace
uses: actions/upload-artifact@v4
with:
name: AdGuardHome_release_${{ matrix.name }}
path: '**/AdGuardHome/AdGuardHome*'
compression-level: 9
beta:
runs-on: ubuntu-latest
outputs:
beta_version: ${{ steps.beta.outputs.beta_version }}
beta_time: ${{ steps.beta.outputs.beta_time }}
steps:
- name: Checkout `beta-v0.108`
uses: actions/checkout@v4
with:
repository: AdguardTeam/AdGuardHome
ref: beta-v0.108
fetch-depth: 0
- name: Get `AdGuard Home Beta` version and time
id: beta
run: |
beta_version=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases | jq -r '[.[] | select(.tag_name | test("b"))][0].tag_name')
echo "beta_version=$beta_version" >> $GITHUB_OUTPUT
beta_time=$(git log -1 --format=%cd --date=format:'%Y-%m-%d' ${beta_version})
echo "beta_time=$beta_time" >> $GITHUB_OUTPUT
beta_cross:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Linux
- { name: linux_amd64, goos: linux, goarch: amd64, goamd64: v1 }
- { name: linux_armv5, goos: linux, goarch: arm, goarm: 5 }
- { name: linux_armv6, goos: linux, goarch: arm, goarm: 6 }
- { name: linux_armv7, goos: linux, goarch: arm, goarm: 7 }
- { name: linux_arm64, goos: linux, goarch: arm64 }
- { name: linux_mips_softfloat, goos: linux, goarch: mips, gomips: softfloat }
- { name: linux_mipsle_softfloat, goos: linux, goarch: mipsle, gomips: softfloat }
# Windows
- { name: windows_amd64, goos: windows, goarch: amd64, goamd64: v1 }
- { name: windows_arm64, goos: windows, goarch: arm64 }
fail-fast: false
needs:
- go
- node
- beta
env:
beta_VERSION: ${{ needs.beta.outputs.beta_version }}
steps:
- name: Checkout `beta-v0.108`
uses: actions/checkout@v4
with:
repository: AdguardTeam/AdGuardHome
ref: beta-v0.108
- name: Setup `Go`
uses: actions/setup-go@v5
with:
go-version: ${{ needs.go.outputs.version }}
- name: Adapt `Go` version
run: |
go get go@${{ needs.go.outputs.version }}
go mod tidy
- name: Setup `Node`
uses: actions/setup-node@v4
with:
node-version: ${{ needs.node.outputs.version }}
- name: Setup `Snapcraft`
run: |
sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft
- name: Build `AdGuard Home Beta`
id: build
run: |
make SIGN=0 VERBOSE=1 ARCH=${{ matrix.goarch }} OS=${{ matrix.goos }} CHANNEL=beta VERSION=${{ env.beta_VERSION }} GOTOOLCHAIN=local build-release
- name: Upload files to workspace
uses: actions/upload-artifact@v4
with:
name: AdGuardHome_beta_${{ matrix.name }}
path: '**/AdGuardHome/AdGuardHome*'
compression-level: 9
push_adguardhome:
needs:
- release_cross
- release
- beta_cross
- beta
runs-on: ubuntu-latest
env:
release_VERSION: ${{ needs.release.outputs.release_version }}
release_TIME: ${{ needs.release.outputs.release_time }}
beta_VERSION: ${{ needs.beta.outputs.beta_version }}
beta_TIME: ${{ needs.beta.outputs.beta_time }}
steps:
- name: Clone Repository
uses: actions/checkout@main
- name: Download files from workspace
uses: actions/download-artifact@v4
with:
path: ./tmp-AdGuardHome/
- name: Batch move and rename `AdGuard Home` files
run: |
mkdir -p ./tmp-AdGuardHome/compress/
archs=(amd64 armv5 armv6 armv7 arm64 mips_softfloat mipsle_softfloat)
new_name=(amd64 armv5 armv6 armv7 armv8 mips_softfloat mipsle_softfloat)
for ((i = 0; i < 7; i++)); do
mv -f "./tmp-AdGuardHome/AdGuardHome_release_linux_${archs[i]}/dist/AdGuardHome_linux_${archs[i]//v/_}/AdGuardHome/AdGuardHome" "./tmp-AdGuardHome/compress/AdGuardHome_release_linux_${new_name[i]}"
mv -f "./tmp-AdGuardHome/AdGuardHome_beta_linux_${archs[i]}/dist/AdGuardHome_linux_${archs[i]//v/_}/AdGuardHome/AdGuardHome" "./tmp-AdGuardHome/compress/AdGuardHome_beta_linux_${new_name[i]}"
done
chmod +x ./tmp-AdGuardHome/compress/*
- name: Setup `upx` and compress `AdGuard Home` files
uses: crazy-max/ghaction-upx@v3
with:
version: latest
files: ./tmp-AdGuardHome/compress/*
- name: Move `AdGuard Home` files
run: |
mkdir -p ./AdGuardHome/
mv -f ./tmp-AdGuardHome/compress/* ./AdGuardHome/
# `Release` for Windows
mv -f ./tmp-AdGuardHome/AdGuardHome_release_windows_amd64/dist/AdGuardHome_windows_amd64/AdGuardHome/AdGuardHome.exe ./AdGuardHome/AdGuardHome_release_windows_amd64.exe
mv -f ./tmp-AdGuardHome/AdGuardHome_release_windows_arm64/dist/AdGuardHome_windows_arm64/AdGuardHome/AdGuardHome.exe ./AdGuardHome/AdGuardHome_release_windows_arm64.exe
# `Beta` for Windows
mv -f ./tmp-AdGuardHome/AdGuardHome_beta_windows_amd64/dist/AdGuardHome_windows_amd64/AdGuardHome/AdGuardHome.exe ./AdGuardHome/AdGuardHome_beta_windows_amd64.exe
mv -f ./tmp-AdGuardHome/AdGuardHome_beta_windows_arm64/dist/AdGuardHome_windows_arm64/AdGuardHome/AdGuardHome.exe ./AdGuardHome/AdGuardHome_beta_windows_arm64.exe
rm -rf ./tmp*
- name: Release and upload `AdGuardHome` assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
release_name: AdGuardHome
tag: AdGuardHome
overwrite: true
body: |
更新 [AdGuard Home Release 版](https://github.com/AdguardTeam/AdGuardHome/tree/beta-v0.107)至 ${{ env.release_VERSION }},发布于 ${{ env.release_TIME }}
更新 [AdGuard Home Beta 版](https://github.com/AdguardTeam/AdGuardHome/tree/beta-v0.108)至 ${{ env.beta_VERSION }},发布于 ${{ env.beta_TIME }}
file_glob: true
file: ./AdGuardHome/*
- name: Purge jsDelivr CDN
run: |
cd ./AdGuardHome/ || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@AdGuardHome/${file}"
done