-
Notifications
You must be signed in to change notification settings - Fork 1
314 lines (297 loc) · 10.8 KB
/
vercel-pkg.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: Build portable binaries
on: [push]
jobs:
build_x64_executables:
runs-on: ubuntu-20.04
strategy:
matrix:
pkg_target_without_node:
- linuxstatic-x64
- linux-x64
- mac-x64
- alpine-x64
- win-x64
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-node@v4
with:
node-version: '18'
- run: npm ci
- run: |
set -xeu
npm run build
./node_modules/.bin/pkg --out-path=rich-piping-server-${{ matrix.pkg_target_without_node }} --targets=node18-${{ matrix.pkg_target_without_node }} ./
- name: tar.gz or zip
run: |
set -xeu
if [ "${{ matrix.pkg_target_without_node }}" = "win-x64" ]; then
zip -r rich-piping-server-${{ matrix.pkg_target_without_node }}.zip ./rich-piping-server-${{ matrix.pkg_target_without_node }}
else
tar czvf rich-piping-server-${{ matrix.pkg_target_without_node }}.tar.gz ./rich-piping-server-${{ matrix.pkg_target_without_node }}
fi
- uses: actions/upload-artifact@v3
with:
name: build_x64
path: |
rich-piping-server-*.tar.gz
rich-piping-server-*.zip
build_arm_executables:
# Only run with tags because ARM builds are slow
if: startsWith( github.ref, 'refs/tags/')
runs-on: ubuntu-20.04
strategy:
matrix:
pkg_target_without_node:
- linuxstatic-arm64
- linuxstatic-armv7
- linux-arm64
- mac-arm64
- alpine-arm64
- win-arm64
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- run: |
set -xeu
docker run --rm -i -v $PWD:/app --platform=linux/arm64/v8 node:20 bash << 'EOF'
set -xeu
# Install ldid for macos-arm64 signing
curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus2/ldid_linux_aarch64
chmod +x ldid_linux_aarch64
mv ./ldid_linux_aarch64 /usr/local/bin/ldid
cd /app
npm ci
npm run build
./node_modules/.bin/pkg --out-path=rich-piping-server-${{ matrix.pkg_target_without_node }} --targets=node18-${{ matrix.pkg_target_without_node }} ./
EOF
- name: tar.gz or zip
run: |
set -xeu
if [ "${{ matrix.pkg_target_without_node }}" = "win-arm64" ]; then
zip -r rich-piping-server-${{ matrix.pkg_target_without_node }}.zip ./rich-piping-server-${{ matrix.pkg_target_without_node }}
else
tar czvf rich-piping-server-${{ matrix.pkg_target_without_node }}.tar.gz ./rich-piping-server-${{ matrix.pkg_target_without_node }}
fi
- uses: actions/upload-artifact@v3
with:
name: build_arm
path: |
rich-piping-server-*.tar.gz
rich-piping-server-*.zip
linux_operational_test:
runs-on: ubuntu-20.04
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive tar.gz
run: tar xvf rich-piping-server-linuxstatic-x64.tar.gz
- name: Operational test
run: |
set -xeu
cat <<EOF > "config.yaml"
allowPaths:
- /0s6twklxkrcfs1u
- type: regexp
value: "/[abcd]+"
basicAuthUsers:
- username: user1
password: pass1234
rejection: nginx-down
EOF
# Run a server in background
./rich-piping-server-linuxstatic-x64/rich-piping-server --http-port=8080 --config-path=./config.yaml &> ./rich-piping-server.log &
# Get server PID
server_pid=$!
# Wait for server running
sleep 1
# Create a file to send
echo 'hello, world' > /tmp/hello.txt
# Send and wait for a receiver
curl -u user1:pass1234 -T /tmp/hello.txt localhost:8080/0s6twklxkrcfs1u &
# Get data as a file
curl -u user1:pass1234 localhost:8080/0s6twklxkrcfs1u > /tmp/download.txt
# Print downloaded file
cat /tmp/download.txt
# Test the equality
diff /tmp/hello.txt /tmp/download.txt
# Print server's log
cat ./rich-piping-server.log
# Stop the server
kill $server_pid
alpine_operational_test:
runs-on: ubuntu-20.04
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive tar.gz
run: tar xvf rich-piping-server-alpine-x64.tar.gz
- name: Operational test
run: |
docker run --rm -i -v $PWD:/app alpine:3.14 /bin/sh << EOF
set -xeu
apk add curl
cat <<EOF2 > "config.yaml"
allowPaths:
- /0s6twklxkrcfs1u
- type: regexp
value: "/[abcd]+"
basicAuthUsers:
- username: user1
password: pass1234
rejection: nginx-down
EOF2
# Run a server in background
/app/rich-piping-server-alpine-x64/rich-piping-server --http-port=8080 --config-path=./config.yaml &> ./rich-piping-server.log &
# Wait for server running
sleep 1
# Create a file to send
echo 'hello, world' > /tmp/hello.txt
# Send and wait for a receiver
curl -u user1:pass1234 -T /tmp/hello.txt localhost:8080/0s6twklxkrcfs1u &
# Get data as a file
curl -u user1:pass1234 localhost:8080/0s6twklxkrcfs1u > /tmp/download.txt
# Print downloaded file
cat /tmp/download.txt
# Test the equality
diff /tmp/hello.txt /tmp/download.txt
# Print server's log
cat ./rich-piping-server.log
EOF
macos_operational_test:
runs-on: macos-12
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive tar.gz
run: tar xvf rich-piping-server-mac-x64.tar.gz
- name: Operational test
run: |
set -xeu
cat <<EOF > "config.yaml"
allowPaths:
- /0s6twklxkrcfs1u
- type: regexp
value: "/[abcd]+"
basicAuthUsers:
- username: user1
password: pass1234
rejection: nginx-down
EOF
# Run a server in background
./rich-piping-server-mac-x64/rich-piping-server --http-port=8080 --config-path=./config.yaml &> ./rich-piping-server.log &
# Get server PID
server_pid=$!
# Wait for server running
sleep 1
# Create a file to send
echo 'hello, world' > /tmp/hello.txt
# Send and wait for a receiver
curl -u user1:pass1234 -T /tmp/hello.txt localhost:8080/0s6twklxkrcfs1u &
# Get data as a file
curl -u user1:pass1234 localhost:8080/0s6twklxkrcfs1u> /tmp/download.txt
# Print downloaded file
cat /tmp/download.txt
# Test the equality
diff /tmp/hello.txt /tmp/download.txt
# Print server's log
cat ./rich-piping-server.log
# Stop the server
kill $server_pid
windows_operational_test:
runs-on: windows-2022
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive zip
run: unzip rich-piping-server-win-x64.zip
- name: Create certificates
run: |
mkdir ssl_certs
cd ssl_certs
openssl genrsa 2048 > server.key
openssl req -new -key server.key -subj "/C=JP" > server.csr
cat server.csr | openssl x509 -req -days 3650 -signkey server.key > server.crt
- name: Operational test
run: |
echo @'
allowPaths:
- /0s6twklxkrcfs1u
- type: regexp
value: "/[abcd]+"
basicAuthUsers:
- username: user1
password: pass1234
rejection: nginx-down
'@ > .\config.yaml
cat ./config.yaml
# Run a server in background
$args = @("--http-port=8080", "--config-path=.\config.yaml", "--enable-https", "--https-port=8443", "--key-path=.\ssl_certs\server.key", "--crt-path=.\ssl_certs\server.crt")
$server_pid = Start-Process -PassThru -FilePath .\rich-piping-server-win-x64\rich-piping-server.exe -ArgumentList $args | foreach { $_.Id }
# Wait for server running
sleep 2
# Create a file to send
echo 'hello, world' > C:\Temp\hello.txt
# Send and wait for a receiver
curl -u user1:pass1234 -T C:\Temp\hello.txt localhost:8080/0s6twklxkrcfs1u &
# Get data as a file
curl -u user1:pass1234 localhost:8080/0s6twklxkrcfs1u > C:\Temp\download.txt
# Print downloaded file
cat C:\Temp\download.txt
# Test the equality
diff C:\Temp\hello.txt C:\Temp\download.txt
# Send and wait for a receiver
curl -u user1:pass1234 -kT C:\Temp\hello.txt https://localhost:8443/0s6twklxkrcfs1u &
# Get data as a file
curl -u user1:pass1234 -k https://localhost:8443/0s6twklxkrcfs1u > C:\Temp\download_https.txt
# Print downloaded file
cat C:\Temp\download_https.txt
# Test the equality
diff C:\Temp\hello.txt C:\Temp\download_https.txt
# Stop the server
kill $server_pid
release_executables:
if: startsWith( github.ref, 'refs/tags/')
needs:
- linux_operational_test
- alpine_operational_test
- macos_operational_test
- windows_operational_test
- build_arm_executables
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- uses: actions/download-artifact@v3
with:
name: build_arm
path: .
- run: |
set -xeu
mkdir ./publish_dir
mv rich-piping-server-* ./publish_dir
# Show and create checksums
(cd publish_dir && sha256sum * | tee /dev/stderr > sha256sums.txt)
TAG=$(echo $GITHUB_REF | cut -d / -f 3)
VERSION=$TAG
REPO=$(echo $GITHUB_REPOSITORY | cut -d / -f 2)
curl -L https://github.com/tcnksm/ghr/releases/download/v0.14.0/ghr_v0.14.0_linux_amd64.tar.gz | tar xzf -
./ghr_v0.14.0_linux_amd64/ghr -t ${{ secrets.GITHUB_TOKEN }} -u ${GITHUB_ACTOR} -r ${REPO} -c ${GITHUB_SHA} -delete -n ${VERSION} ${VERSION} ./publish_dir