forked from juewuy/ShellCrash
-
Notifications
You must be signed in to change notification settings - Fork 0
290 lines (271 loc) · 9.47 KB
/
update_singbox_core.yaml
File metadata and controls
290 lines (271 loc) · 9.47 KB
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
name: Build Sing-Box Core for ShellCrash
on:
workflow_dispatch:
inputs:
tag1:
description: 'project name of sing-box, such as SagerNet/sing-box'
required: true
type: string
tag2:
description: 'version of sing-box, such as v1.7.8'
required: true
type: string
tag3:
description: 'a new prerelease name (such as singbox_core_178) or only upload-artifact'
required: false
type: string
tag4:
description: 'git push as crashcore (such as singbox or singboxp) or only upload-artifact'
required: false
type: string
tag5:
description: 'build tags'
required: false
type: string
tag6:
description: 'ziptype(tar.gz|upx|gz)'
required: true
type: string
workflow_call:
inputs:
tag1:
required: true
type: string
tag2:
required: true
type: string
tag3:
required: false
type: string
tag4:
required: false
type: string
tag5:
required: false
type: string
tag6:
required: true
type: string
jobs:
go:
runs-on: ubuntu-latest
outputs:
version: ${{steps.go.outputs.version}}
steps:
- name: get latest go version
id: go
run: |
echo version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT
sing-box:
runs-on: ubuntu-latest
needs: go
env:
REPO: ${{ inputs.tag1 }}
TAGS: ${{ inputs.tag5 }}
outputs:
version: ${{steps.sing-box.outputs.version}}
tags: ${{steps.sing-box.outputs.tags}}
steps:
- uses: actions/checkout@v4.1.1
with:
repository: ${{ inputs.tag1 }}
ref: ${{ inputs.tag2 }}
fetch-depth: 0
- name: setup go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{needs.go.outputs.version}}
- name: get sing-box version
id: sing-box
run: |
git remote add sekai https://github.com/SagerNet/sing-box.git
git fetch --tags sekai
version=$(CGO_ENABLED=0 go run ./cmd/internal/read_tag)
[ -z "$version" ] && version=${{ inputs.tag2 }}
version=$(echo ${version%-*})
echo version=$version >> $GITHUB_OUTPUT
if [ -z "$TAGS" ];then
if [ "$REPO" = 'SagerNet/sing-box' ];then
echo tags=with_quic,with_utls,with_clash_api >> $GITHUB_OUTPUT
else
echo tags=with_quic,with_utls,with_clash_api,with_shadowsocksr >> $GITHUB_OUTPUT
fi
else
echo tags=$TAGS >> $GITHUB_OUTPUT
fi
cross:
strategy:
matrix:
include:
# linux
- name: linux-amd64
goos: linux
goarch: amd64
goamd64: v1
- name: linux-386
goos: linux
goarch: 386
- name: linux-arm64
goos: linux
goarch: arm64
- name: linux-armv5
goos: linux
goarch: arm
goarm: 5
- name: linux-armv7
goos: linux
goarch: arm
goarm: 7
- name: linux-mips-softfloat
goos: linux
goarch: mips
gomips: softfloat
- name: linux-mipsle-softfloat
goos: linux
goarch: mipsle
gomips: softfloat
- name: linux-mipsle-hardfloat
goos: linux
goarch: mipsle
gomips: hardfloat
fail-fast: false
runs-on: ubuntu-latest
needs:
- go
- sing-box
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOAMD64: ${{ matrix.goamd64 }}
GOARM: ${{ matrix.goarm }}
GOMIPS: ${{ matrix.gomips }}
CGO_ENABLED: 0
REPO: ${{ inputs.tag1 }}
TAGS: ${{needs.sing-box.outputs.tags}}
VERSION: ${{needs.sing-box.outputs.version}}
steps:
- name: Checkout sing-box
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
repository: ${{ inputs.tag1 }}
ref: ${{ inputs.tag2 }}
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{needs.go.outputs.version}}
- name: checkout sing repository
if: ${{ env.REPO == 'PuerNya/sing-box' }}
uses: actions/checkout@v4.1.1
with:
ref: building
path: sing
repository: PuerNya/sing
- name: build core
id: build
run: go build -v -trimpath -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=${VERSION}' -s -w -buildid=" -tags "${TAGS}" ./cmd/sing-box
- name: Upload file to workspace
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: sing-box
overwrite: true
push_to_git:
needs:
- cross
- sing-box
runs-on: ubuntu-latest
env:
RELEASE: ${{ inputs.tag3 }}
PUSHDIR: ${{ inputs.tag4 }}
ZIPTYPE: ${{ inputs.tag6 }}
VERSION: ${{needs.sing-box.outputs.version}}
steps:
- name: Checkout ShellCrash
uses: actions/checkout@v5
with:
repository: juewuy/ShellCrash
fetch-depth: 1
ref: update
- name: Download file from workspace
uses: actions/download-artifact@v4
with:
path: ./tmp
- name: Zip core by upx
if: env.ZIPTYPE == 'upx'
run: |
for upxv in 3.94 3.96 5.1.0;do
wget https://github.com/upx/upx/releases/download/v$upxv/upx-$upxv-amd64_linux.tar.xz
tar xf upx-$upxv-amd64_linux.tar.xz
done
for arch in amd64 armv5 armv7 arm64 386 mips-softfloat mipsle-hardfloat mipsle-softfloat;do
[ ! -f ./tmp/linux-${arch}/sing-box ] && continue
mv -f ./tmp/linux-${arch}/sing-box ./tmp/singbox-linux-${arch}.upx
chmod +x ./tmp/singbox-linux-${arch}.upx
case "${arch}" in
armv5|mips* )
./upx-3.94-amd64_linux/upx --no-lzma ./tmp/singbox-linux-${arch}.upx
;;
armv7|386)
./upx-3.96-amd64_linux/upx --no-lzma ./tmp/singbox-linux-${arch}.upx
;;
*)
./upx-5.1.0-amd64_linux/upx ./tmp/singbox-linux-${arch}.upx
;;
esac
done
rm -rf upx-*
- name: Zip core by tar
if: env.ZIPTYPE == 'tar.gz'
run: |
for arch in amd64 armv5 armv7 arm64 386 mips-softfloat mipsle-hardfloat mipsle-softfloat;do
[ ! -f ./tmp/linux-${arch}/sing-box ] && continue
mv -f ./tmp/linux-${arch}/sing-box ./tmp/CrashCore
chmod +x ./tmp/CrashCore
tar --no-same-owner -zcvf ./tmp/singbox-linux-${arch}.tar.gz -C ./tmp CrashCore
done
- name: Zip core by gz
if: env.ZIPTYPE == 'gz'
run: |
for arch in amd64 armv5 armv7 arm64 386 mips-softfloat mipsle-hardfloat mipsle-softfloat;do
[ ! -f ./tmp/linux-${arch}/sing-box ] && continue
mv -f ./tmp/linux-${arch}/sing-box ./tmp/singbox-linux-${arch}
chmod +x ./tmp/singbox-linux-${arch}
gzip ./tmp/singbox-linux-${arch}
done
- name: Commit and push
if: ${{ env.PUSHDIR != '' }}
run: |
[ "${{ inputs.tag1 }}" = SagerNet/sing-box ] && crashcore='singbox'
[ "${{ inputs.tag1 }}" = PuerNya/sing-box ] && crashcore='singboxp'
[ "${{ inputs.tag1 }}" = reF1nd/sing-box ] && crashcore='singboxr'
mkdir -p ./bin/${crashcore}
mv -f ./tmp/singbox-linux-* ./bin/${crashcore}/
rm -fr ./tmp
[ "${{ inputs.tag6 }}" = tar.gz ] && sed -i "s/${crashcore}_v=.*/${crashcore}_v=${VERSION}/" ./bin/version
git config --global user.email "github-actions[bot]@users.noreply.github.com" && git config --global user.name "github-actions[bot]"
git add . && git commit -m "更新${crashcore}内核至${VERSION}" || exit 0
git push
#刷新cdn缓存
sleep 60
find "bin/${crashcore}" -type f | while read -r file; do
curl -s "https://purge.jsdelivr.net/gh/juewuy/ShellClash@update/${file#bin/}" || true
done
curl -s https://purge.jsdelivr.net/gh/juewuy/ShellClash@update/bin/version || true
- name: Create Release and Upload Release Asset
if: ${{ env.RELEASE != '' && env.PUSHDIR == '' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ inputs.tag3 }}
name: ${{ inputs.tag3 }}
body: "The ${{env.VERSION}} version of ${{ inputs.tag1 }} \n这是${{ inputs.tag1 }}的${{env.VERSION}}版本内核文件\nhttps://github.com/${{ inputs.tag1 }}/releases \nOnly support for ShellCrash\n仅适配ShellCrash项目"
draft: false
prerelease: true
files: |
./tmp/singbox*.tar.gz
./tmp/version
- name: Cleanup Workflow
uses: Mattraks/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 2