-
Notifications
You must be signed in to change notification settings - Fork 420
197 lines (189 loc) · 6.22 KB
/
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
name: pkg
on:
push:
tags:
- "v*.*.*"
jobs:
build_x64_executables:
runs-on: ubuntu-18.04
strategy:
matrix:
pkg_target_without_node:
- mac-x64
- win-x64
- linuxstatic-x64
- linux-x64
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
node-version: '14'
- run: npm ci
- run: |
set -xeu
npm run build
./node_modules/.bin/pkg --out-path=hosts-server-pkg-${{ matrix.pkg_target_without_node }} --targets=node16-${{ matrix.pkg_target_without_node }} .
- name: tar.gz or zip
run: |
set -xeu
if [ "${{ matrix.pkg_target_without_node }}" = "win-x64" ]; then
zip -r hosts-server-pkg-${{ matrix.pkg_target_without_node }}.zip ./hosts-server-pkg-${{ matrix.pkg_target_without_node }}
else
tar czvf hosts-server-pkg-${{ matrix.pkg_target_without_node }}.tar.gz ./hosts-server-pkg-${{ matrix.pkg_target_without_node }}
fi
- uses: actions/upload-artifact@v3
with:
name: build_x64
path: |
hosts-server-pkg-*.tar.gz
hosts-server-pkg-*.zip
build_arm_executables:
runs-on: ubuntu-18.04
strategy:
matrix:
pkg_target_without_node:
- mac-arm64
- win-arm64
- linuxstatic-arm64
- linuxstatic-armv7
- linux-arm64
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- run: |
set -xeu
# NOTE: node:16 image causes an error "glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] { ..."
docker run --rm -i -v $PWD:/app --platform=linux/arm64/v8 node:14 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=hosts-server-pkg-${{ matrix.pkg_target_without_node }} --targets=node16-${{ 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 hosts-server-pkg-${{ matrix.pkg_target_without_node }}.zip ./hosts-server-pkg-${{ matrix.pkg_target_without_node }}
else
tar czvf hosts-server-pkg-${{ matrix.pkg_target_without_node }}.tar.gz ./hosts-server-pkg-${{ matrix.pkg_target_without_node }}
fi
- uses: actions/upload-artifact@v3
with:
name: build_arm
path: |
hosts-server-pkg-*.tar.gz
hosts-server-pkg-*.zip
macos_operational_test:
runs-on: macos-10.15
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive tar.gz
run: tar xvf hosts-server-pkg-mac-x64.tar.gz
- name: Operational test
run: |
set -xeu
# Run a server in background
./hosts-server-pkg-mac-x64/hosts-server --port=8080 &> ./hosts-server.log &
# Get server PID
server_pid=$!
# Wait for server running
sleep 10
# Get data as a file
curl localhost:8080 > /tmp/hosts.txt
# Print downloaded file
cat /tmp/hosts.txt
# Print server's log
cat ./hosts-server.log
# Stop the server
kill $server_pid
windows_operational_test:
runs-on: windows-2019
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive zip
run: unzip hosts-server-pkg-win-x64.zip
- name: Operational test
run: |
# Run a server in background
$args = @("--port=8080")
$server_pid = Start-Process -PassThru -FilePath .\hosts-server-pkg-win-x64\hosts-server.exe -ArgumentList $args | foreach { $_.Id }
# Wait for server running
sleep 10
# Get data as a file
curl localhost:8080 > C:\Temp\hosts.txt
# Print downloaded file
cat C:\Temp\hosts.txt
# Stop the server
kill $server_pid
linux_operational_test:
runs-on: ubuntu-18.04
needs: build_x64_executables
steps:
- uses: actions/download-artifact@v3
with:
name: build_x64
path: .
- name: Unarchive tar.gz
run: tar xvf hosts-server-pkg-linuxstatic-x64.tar.gz
- name: Operational test
run: |
set -xeu
# Run a server in background
./hosts-server-pkg-linuxstatic-x64/hosts-server --port=8080 &> ./hosts-server.log &
# Get server PID
server_pid=$!
# Wait for server running
sleep 10
# Get data as a file
curl localhost:8080 > /tmp/hosts.txt
# Print downloaded file
cat /tmp/hosts.txt
# Print server's log
cat ./hosts-server.log
# Stop the server
kill $server_pid
release_executables:
if: startsWith( github.ref, 'refs/tags/')
needs:
- macos_operational_test
- windows_operational_test
- linux_operational_test
- build_arm_executables
runs-on: ubuntu-18.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 hosts-server-pkg-* ./publish_dir
# Show and create checksums
(cd publish_dir && sha256sum * | tee /dev/stderr > sha256sums.txt)
# create release
- name: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: "publish_dir/**"
env:
GITHUB_TOKEN: ${{ secrets.COMMIT_TOKEN }}