-
Notifications
You must be signed in to change notification settings - Fork 4
122 lines (98 loc) · 3.19 KB
/
ci.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
name: CI
on:
push:
branches:
- main
- next
tags:
- '**'
pull_request:
workflow_dispatch:
jobs:
check:
name: Check files
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- if: startsWith(github.ref, 'refs/tags/')
name: Check install link
run: |
if ! grep "npm install https://github.com/MaxOhn/rosu-pp-js/releases/download/${{ github.ref_name }}/rosu_pp_js_nodejs.tar.gz" README.md; then
echo "Did not find install link in readme: 'npm install https://github.com/MaxOhn/rosu-pp-js/releases/download/${{ github.ref_name }}/rosu_pp_js_nodejs.tar.gz'"
exit 1
fi
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build
run: wasm-pack build --target nodejs --out-dir pkg
- name: Check .d.ts file
run: |
if ! cmp --silent pkg/rosu_pp_js.d.ts rosu_pp_js.d.ts; then
echo ".d.ts file is not up to date"
cmp --print-bytes pkg/rosu_pp_js.d.ts rosu_pp_js.d.ts
cat pkg/rosu_pp_js.d.ts
exit 1
fi
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target: [bundler, nodejs, web]
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- if: ${{ matrix.target != 'nodejs' }}
name: Optimize for size
run: echo "opt-level = \"z\"" >> Cargo.toml
- name: Build & zip
run: |
wasm-pack build --release --target ${{ matrix.target }} --out-dir pkg
ls -ghG pkg
tar -czvf rosu_pp_js_${{ matrix.target }}.tar.gz -C pkg .
- name: Upload tarballs
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: rosu_pp_js_${{ matrix.target }}
path: rosu_pp_js_${{ matrix.target }}.tar.gz
release:
name: Release
needs: [check, build]
if: success() && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Get artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: tars
- name: Upload to github release
uses: softprops/action-gh-release@v2
with:
files: tars/*.tar.gz
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Extract nodejs tarball
run: |
mkdir extracted
tar -xzvf ./tars/rosu_pp_js_nodejs.tar.gz -C ./extracted
- name: Publish
uses: JS-DevTools/npm-publish@v3
with:
package: ./extracted
token: ${{ secrets.NPM_TOKEN }}