-
Notifications
You must be signed in to change notification settings - Fork 16
309 lines (299 loc) · 10.8 KB
/
release.yaml
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
name: shiroa::release
on:
release:
types: [created]
workflow_dispatch:
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
SCCACHE_GHA_ENABLED: 'true'
RUSTC_WRAPPER: 'sccache'
jobs:
build-frontend-packages:
name: build (Frontend packages)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Yarn
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install` command
dir: 'frontend'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed
- name: Build JavaScript packages
uses: borales/actions-yarn@v4
with:
cmd: build
dir: 'frontend'
- uses: actions/upload-artifact@v3
with:
name: typst-ts-dist
path: frontend/node_modules/@myriaddreamin
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: shiroa-dist
path: frontend/dist
if-no-files-found: error
build:
strategy:
matrix:
include:
- os: windows-latest
rust-target: x86_64-pc-windows-msvc
platform: win32
arch: x64
- os: windows-latest
rust-target: i686-pc-windows-msvc
platform: win32
arch: ia32
- os: windows-latest
rust-target: aarch64-pc-windows-msvc
platform: win32
arch: arm64
- os: ubuntu-latest
rust-target: x86_64-unknown-linux-gnu
platform: linux
arch: x64
- os: ubuntu-latest
rust-target: aarch64-unknown-linux-gnu
platform: linux
arch: arm64
- os: ubuntu-latest
rust-target: arm-unknown-linux-gnueabihf
platform: linux
arch: armhf
- os: macos-11
rust-target: x86_64-apple-darwin
platform: darwin
arch: x64
- os: macos-11
rust-target: aarch64-apple-darwin
platform: darwin
arch: arm64
name: build (${{ matrix.rust-target }})
runs-on: ${{ matrix.os }}
env:
target: ${{ matrix.platform }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust-target }}
- name: Install AArch64 target toolchain
if: matrix.rust-target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update -y
sudo apt-get install gcc-aarch64-linux-gnu
- name: Install ARM target toolchain
if: matrix.rust-target == 'arm-unknown-linux-gnueabihf'
run: |
sudo apt-get update -y
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Install Yarn
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install` command
dir: 'frontend'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed
- name: Build JavaScript packages
uses: borales/actions-yarn@v4
with:
cmd: build
dir: 'frontend'
- name: Run Native Build
shell: pwsh
run: |
cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin shiroa
cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin shiroa
- uses: actions/upload-artifact@v3
with:
name: shiroa-${{ env.target }}
path: target/${{ matrix.rust-target }}/release-stripped/shiroa*
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: shiroa-${{ env.target }}-relwithdebuginfo
path: target/${{ matrix.rust-target }}/release/shiroa*
if-no-files-found: error
build_linux_riscv64:
strategy:
matrix:
include:
- os: ubuntu-latest
rust-target: riscv64gc-unknown-linux-gnu
platform: linux
arch: riscv64
name: build (${{ matrix.rust-target }})
needs: [build-frontend-packages]
runs-on: ${{ matrix.os }}
env:
target: ${{ matrix.platform }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/download-artifact@v2
with:
path: artifacts
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.rust-target }}
- name: Build cross image
run: |
docker build -t shiroa/riscv64 ${GITHUB_WORKSPACE}/.github/cross-linux-riscv64/
env:
CROSS_DOCKER_IN_DOCKER: true
- name: Run Cross Build
run: |
mkdir -p frontend/node_modules
cp -r artifacts/typst-ts-dist frontend/node_modules/@myriaddreamin
cp -r artifacts/shiroa-dist frontend/dist
docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project shiroa/riscv64:latest cargo build --manifest-path cli/Cargo.toml --release --target ${CARGO_TARGET} --bin shiroa
docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project shiroa/riscv64:latest cargo build --manifest-path cli/Cargo.toml --profile release-stripped --target ${CARGO_TARGET} --bin shiroa
env:
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: ${{ matrix.rust-target }}
PKG_CONFIG_PATH: /usr/lib/riscv64-linux-gnu/pkgconfig
PKG_CONFIG_ALLOW_CROSS: true
- uses: actions/upload-artifact@v3
with:
name: shiroa-${{ env.target }}
path: target/${{ matrix.rust-target }}/release-stripped/shiroa*
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: shiroa-${{ env.target }}-relwithdebuginfo
path: target/${{ matrix.rust-target }}/release/shiroa*
if-no-files-found: error
build_alpine:
name: build (x86_64-unknown-linux-musl)
runs-on: ubuntu-latest
container:
image: rust:alpine
volumes:
- /usr/local/cargo/registry:/usr/local/cargo/registry
env:
target: alpine-x64
RUST_TARGET: x86_64-unknown-linux-musl
RUSTFLAGS: '-C link-arg=-fuse-ld=lld -C target-feature=-crt-static'
steps:
- name: Install dependencies
run: apk add --no-cache git clang lld musl-dev npm
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Configure git
run: |
git config --global --add safe.directory $PWD
- name: Install Yarn
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install` command
dir: 'frontend'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed
- name: Build JavaScript packages
uses: borales/actions-yarn@v4
with:
cmd: build
dir: 'frontend'
- name: build binaries
run: |
cargo build --release --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin shiroa
cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin shiroa
- uses: actions/upload-artifact@v3
with:
name: shiroa-${{ env.target }}
path: target/${{ env.RUST_TARGET }}/release-stripped/shiroa*
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: shiroa-${{ env.target }}-relwithdebuginfo
path: target/${{ env.RUST_TARGET }}/release/shiroa*
if-no-files-found: error
release:
runs-on: ubuntu-latest
needs: [build, build_linux_riscv64, build_alpine]
if: success() && startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v2
with:
path: artifacts
- name: Display structure of downloaded files
run: find artifacts
- run: |
set -ex
mkdir -p gh-release/
pack_release() {
target=$2
src=shiroa-$1
name=shiroa-$target
mkdir -p tmp/$name
rm -f artifacts/$src/*.d
rm -f artifacts/$src/*.pdb
mkdir -p release/$name/bin
cp artifacts/$src-relwithdebuginfo/shiroa* "release/$name/bin/"
cp -r CHANGELOG release/$name/
cp -r github-pages/docs release/$name/
cp README.md \
LICENSE \
CHANGELOG.md \
release/$name/
chmod +x release/$name/bin/shiroa*
tar czvf gh-release/$name-relwithdebuginfo.tar.gz -C release $name
mkdir -p release-stripped/$name/bin
cp artifacts/$src/shiroa* "release-stripped/$name/bin/"
cp -r CHANGELOG release-stripped/$name/
cp -r github-pages/docs release-stripped/$name/
cp README.md \
LICENSE \
CHANGELOG.md \
release-stripped/$name/
chmod +x release-stripped/$name/bin/shiroa*
tar czvf gh-release/$name.tar.gz -C release-stripped $name
}
pack_release win32-x64 x86_64-pc-windows-msvc
pack_release win32-ia32 i686-pc-windows-msvc
pack_release win32-arm64 aarch64-pc-windows-msvc
pack_release linux-x64 x86_64-unknown-linux-gnu
pack_release linux-arm64 aarch64-unknown-linux-gnu
pack_release linux-armhf arm-unknown-linux-gnueabihf
pack_release linux-riscv64 riscv64gc-unknown-linux-gnu
pack_release darwin-x64 x86_64-apple-darwin
pack_release darwin-arm64 aarch64-apple-darwin
pack_release alpine-x64 alpine-x64
pack_release alpine-x64 x86_64-unknown-linux-musl
- name: Display structure of releasing files
run: find gh-release
- uses: actions/upload-artifact@v3
with:
name: gh-release
path: gh-release
- uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: 'gh-release/*'
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true