forked from daeuniverse/daed
-
Notifications
You must be signed in to change notification settings - Fork 1
269 lines (237 loc) · 8.2 KB
/
pr-build.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
name: PR Build (Preview)
run-name: '#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }} @${{ github.event.pull_request.head.ref }}:${{ github.event.pull_request.head.sha }}'
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- '**/*.md'
- README.md
jobs:
context:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
instantiate-check-runs:
runs-on: ubuntu-latest
strategy:
matrix:
id: ["checkout-full-src", "build-web", "build-bundle", "build-passed"]
steps:
- name: Instantiate required check runs
uses: daeuniverse/ci-seed-jobs/core/daed/instantiate-check-runs@master
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
id: "dae-bot[bot]/${{ matrix.id }}"
checkout-full-src:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Download wing vendor
run: |
git submodule update --init --recursive
export GOMODCACHE="${PWD}"/go-mod
go mod download -modcacherw
cd dae-core && go mod download -modcacherw && cd ..
find "$GOMODCACHE" -maxdepth 1 ! -name "cache" ! -name "go-mod" -exec rm -rf {} \;
sed -i 's/#export GOMODCACHE=$(PWD)\/go-mod/export GOMODCACHE=$(PWD)\/go-mod/' Makefile
working-directory: wing
- name: Create full source ZIP archive and Signature
run: |
zip -9vr daed-full-src.zip .
FILE=./daed-full-src.zip
DGST=$FILE.dgst
md5sum $FILE >>$DGST
shasum -a 1 $FILE >>$DGST
shasum -a 256 $FILE >>$DGST
shasum -a 512 $FILE >>$DGST
- name: Upload artifact - full source
uses: actions/upload-artifact@v3
with:
name: daed-full-src.zip
path: daed-full-src.zip
- name: Report result
uses: daeuniverse/ci-seed-jobs/core/daed/report-check-run@master
if: always()
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
id: "dae-bot[bot]/checkout-full-src"
build-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: latest
- name: Build
run: |
pnpm install
pnpm build
- name: Upload artifact - web
uses: actions/upload-artifact@v3
with:
name: web
path: dist
- name: Report result
uses: daeuniverse/ci-seed-jobs/core/daed/report-check-run@master
if: always()
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
id: "dae-bot[bot]/build-web"
build-bundle:
needs: build-web
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [arm64, 386, riscv64, mips64, mips64le, mipsle, mips]
include:
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7
# BEGIN Linux AMD64 v1 v2 v3
- goos: linux
goarch: amd64
goamd64: v1
- goos: linux
goarch: amd64
goamd64: v2
- goos: linux
goarch: amd64
goamd64: v3
# END Linux AMD64 v1 v2 v3
# BEGIN Linux mips
- goos: linux
goarch: mips64
cgo_enabled: 1
cc: mips64-linux-gnuabi64-gcc
- goos: linux
goarch: mips64le
cgo_enabled: 1
cc: mips64el-linux-gnuabi64-gcc
- goos: linux
goarch: mipsle
cgo_enabled: 1
cc: mipsel-linux-gnu-gcc
- goos: linux
goarch: mips
cgo_enabled: 1
cc: mips-linux-gnu-gcc
# END Linux mips
fail-fast: false
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
GOAMD64: ${{ matrix.goamd64 }}
CGO_ENABLED: ${{ matrix.cgo_enabled || 0 }}
CC: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get the version
id: get_version
env:
REF: ${{ github.ref }}
run: |
if [[ "$REF" == "refs/tags/v"* ]]; then
tag=${REF##*/}
version=${tag}
package_version="${tag:1}"
else
date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
count=$(git rev-list --count HEAD)
commit=$(git rev-parse --short HEAD)
version="unstable-$date.r${count}.$commit"
package_version="$date.r${count}.$commit"
fi
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$package_version" >> $GITHUB_OUTPUT
echo "PACKAGE_VERSION=$package_version" >> $GITHUB_ENV
- name: Get the filename
id: get_filename
run: |
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOAMD64\"].friendlyName" -r < install/friendly-filenames.json)
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
echo "BUNDLE_NAME=daed-$_NAME" >> $GITHUB_OUTPUT
- name: Install mips build dependencies
if: ${{ startsWith(matrix.goarch, 'mips') }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-mips64-linux-gnuabi64 gcc-mips64el-linux-gnuabi64 gcc-mips-linux-gnu gcc-mipsel-linux-gnu
- name: Download artifact - web
uses: actions/download-artifact@v3
with:
name: web
path: dist/
- name: make
run: |
mkdir -p ./bundled/
export VERSION=${{ steps.get_version.outputs.VERSION }}
export GOFLAGS="-trimpath -modcacherw"
export OUTPUT=bundled/${{ steps.get_filename.outputs.BUNDLE_NAME }}
make
cp ./install/daed.service ./bundled/
curl -L -o ./bundled/geoip.dat https://github.com/v2rayA/dist-v2ray-rules-dat/raw/master/geoip.dat
curl -L -o ./bundled/geosite.dat https://github.com/v2rayA/dist-v2ray-rules-dat/raw/master/geosite.dat
- name: Smoking test
if: matrix.goarch == 'amd64' && matrix.goamd64 == 'v1'
run: ./bundled/${{ steps.get_filename.outputs.BUNDLE_NAME }} --version
- name: Create binary ZIP archive and Signature
run: |
pushd bundled || exit 1
zip -9vr ../${{ steps.get_filename.outputs.BUNDLE_NAME }}.zip .
popd || exit 1
FILE=./${{ steps.get_filename.outputs.BUNDLE_NAME }}.zip
DGST=$FILE.dgst
md5sum $FILE >>$DGST
shasum -a 1 $FILE >>$DGST
shasum -a 256 $FILE >>$DGST
shasum -a 512 $FILE >>$DGST
- name: Upload artifact - bundle
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_filename.outputs.BUNDLE_NAME }}
path: bundled/*
- name: Report result
uses: daeuniverse/ci-seed-jobs/core/daed/report-check-run@master
if: always()
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
id: "dae-bot[bot]/build-bundle"
conclusion:
if: always()
needs: [build-bundle]
runs-on: ubuntu-latest
steps:
- name: Report workflow run result
uses: daeuniverse/ci-seed-jobs/core/daed/report-workflow-run@master
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
id: "dae-bot[bot]/build-passed"
conclusion: ${{ needs.build-bundle.result }}