-
Notifications
You must be signed in to change notification settings - Fork 520
169 lines (140 loc) · 4.85 KB
/
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
name: build
on:
push:
tags-ignore:
- '!v*.*.*'
jobs:
build-clients-macOS:
runs-on: macos-latest
strategy:
matrix:
go-version: [ 1.18.1 ]
steps:
- uses: actions/checkout@v3
- name: Set up golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Build clients
run: |
export COMMIT=`git rev-parse HEAD`
export GOMOD=`pwd`/go.mod
export CGO_ENABLED=1
go mod tidy
go mod download
mkdir ./built
export GOOS=darwin
export GOARCH=arm64
go build -ldflags "-s -w -X 'Spark/client/config.Commit=$COMMIT'" -o ./built/darwin_arm64 Spark/client
export GOARCH=amd64
go build -ldflags "-s -w -X 'Spark/client/config.Commit=$COMMIT'" -o ./built/darwin_amd64 Spark/client
- name: Upload prebuilt client (darwin_arm64)
uses: actions/upload-artifact@v3
with:
name: darwin_arm64
path: ./built/darwin_arm64
- name: Upload prebuilt client (darwin_amd64)
uses: actions/upload-artifact@v3
with:
name: darwin_amd64
path: ./built/darwin_amd64
build-others:
needs: [ build-clients-macOS ]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x ]
go-version: [ 1.18.1 ]
steps:
- uses: actions/checkout@v3
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Set up golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Install statik
run: |
export PATH=$PATH:~/go/bin/
go install github.com/rakyll/statik
- name: Get artifact from previous job (darwin_arm64)
uses: actions/download-artifact@v3
with:
name: darwin_arm64
path: ./built
- name: Get artifact from previous job (darwin_amd64)
uses: actions/download-artifact@v3
with:
name: darwin_amd64
path: ./built
- name: Build and pack static resources
run: |
export COMMIT=`git rev-parse HEAD`
export VERSION=`git describe --tags | sed 's/^v//'`
sed -i "s/\$COMMIT/$COMMIT/g" ./web/src/config/version.json
sed -i "s/\$VERSION/$VERSION/g" ./web/src/config/version.json
cd ./web
npm install
npm run build-prod
statik -m -src="./dist" -f -dest="../server/embed" -p web -ns web
cd ..
- name: Set up go dependencies
run: |
export GOMOD=`pwd`/go.mod
export CGO_ENABLED=0
go mod tidy
go mod download
- name: Build clients and servers
run: |
chmod +x ./scripts/build.client.sh
./scripts/build.client.sh
mkdir ./releases
chmod +x ./scripts/build.server.sh
./scripts/build.server.sh
- name: Prepare release note
run: |
export REF_NAME=`git describe --tags`
node ./scripts/release.js $REF_NAME
- name: Pack releases
run: |
mv ./built ./releases/built
cd ./releases
sudo apt install zip tar pigz -y
tar -czpf server_darwin_arm64.tar.gz server_darwin_arm64 ./built
tar -czpf server_darwin_amd64.tar.gz server_darwin_amd64 ./built
tar -czpf server_linux_arm.tar.gz server_linux_arm ./built
tar -czpf server_linux_i386.tar.gz server_linux_i386 ./built
tar -czpf server_linux_arm64.tar.gz server_linux_arm64 ./built
tar -czpf server_linux_amd64.tar.gz server_linux_amd64 ./built
zip -r -9 -q server_windows_i386.zip server_windows_i386.exe ./built
zip -r -9 -q server_windows_arm64.zip server_windows_arm64.exe ./built
zip -r -9 -q server_windows_amd64.zip server_windows_amd64.exe ./built
zip -r -9 -q frontend_assets.zip ../web/dist/*
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md
files: |
releases/server_darwin_arm64.tar.gz
releases/server_darwin_amd64.tar.gz
releases/server_linux_arm.tar.gz
releases/server_linux_i386.tar.gz
releases/server_linux_arm64.tar.gz
releases/server_linux_amd64.tar.gz
releases/server_windows_i386.zip
releases/server_windows_arm64.zip
releases/server_windows_amd64.zip
releases/frontend_assets.zip
- name: Clean up
uses: geekyeggo/delete-artifact@v1
with:
name: |
darwin_arm64
darwin_amd64
- name: Update version info
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
curl -X POST -H "Authorization: $RELEASE_TOKEN" --retry 10 -m 60 -o /dev/null https://1248.ink/spark/release > /dev/null 2>&1