1+ name : Release JGF
2+
3+ permissions : {}
4+
5+ on :
6+ workflow_dispatch :
7+ push :
8+ branches :
9+ - main
10+ paths :
11+ - npm/jgf/package.json
12+
13+ concurrency :
14+ group : ${{ github.workflow }}-${{ github.ref }}
15+ cancel-in-progress : true
16+
17+ jobs :
18+ check :
19+ name : Check version
20+ runs-on : ubuntu-latest
21+ outputs :
22+ version_changed : ${{ steps.version.outputs.changed }}
23+ version : ${{ steps.version.outputs.version }}
24+ steps :
25+ - uses : actions/checkout@v4
26+
27+ - name : Check version changes
28+ uses : EndBug/version-check@v2
29+ id : version
30+ with :
31+ static-checking : localIsNew
32+ file-url : https://unpkg.com/jgf@latest/package.json
33+ file-name : npm/jgf/package.json
34+
35+ - name : Print version
36+ if : steps.version.outputs.changed == 'true'
37+ env :
38+ NEW_VERSION : ${{ steps.version.outputs.version }}
39+ run : |
40+ echo "Version change found! New version: ${NEW_VERSION}"
41+
42+ build :
43+ needs : check
44+ if : needs.check.outputs.version_changed == 'true'
45+ strategy :
46+ matrix :
47+ include :
48+ - os : windows-latest
49+ target : x86_64-pc-windows-msvc
50+ code-target : win32-x64
51+
52+ - os : windows-latest
53+ target : aarch64-pc-windows-msvc
54+ code-target : win32-arm64
55+
56+ - os : ubuntu-latest
57+ target : x86_64-unknown-linux-gnu
58+ code-target : linux-x64-gnu
59+
60+ - os : ubuntu-latest
61+ target : aarch64-unknown-linux-gnu
62+ code-target : linux-arm64-gnu
63+
64+ - os : ubuntu-latest
65+ target : x86_64-unknown-linux-musl
66+ code-target : linux-x64-musl
67+
68+ - os : ubuntu-latest
69+ target : aarch64-unknown-linux-musl
70+ code-target : linux-arm64-musl
71+
72+ - os : macos-latest
73+ target : x86_64-apple-darwin
74+ code-target : darwin-x64
75+
76+ - os : macos-latest
77+ target : aarch64-apple-darwin
78+ code-target : darwin-arm64
79+
80+ name : Package ${{ matrix.code-target }}
81+ runs-on : ${{ matrix.os }}
82+ defaults :
83+ run :
84+ shell : bash
85+ env :
86+ JGF_VERSION : ${{ needs.check.outputs.version }}
87+ steps :
88+ - uses : actions/checkout@v4
89+
90+ - name : Install cross
91+ uses : taiki-e/install-action@v2
92+ with :
93+ tool : cross
94+
95+ - name : Rust Cache
96+ uses : Swatinem/rust-cache@v2
97+ with :
98+ shared-key : release-${{ matrix.target }}
99+
100+ - name : Add Rust Target
101+ run : rustup target add ${{ matrix.target }}
102+
103+ - name : Build
104+ shell : bash
105+ run : |
106+ cross build --release --bin jgf --target=${{ matrix.target }}
107+
108+ # The binaries are zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
109+ - name : Archive Binaries
110+ if : runner.os == 'Windows'
111+ run : |
112+ JGF_BIN_NAME=jgf-${{ matrix.code-target }}
113+ mv target/${{ matrix.target }}/release/jgf.exe $JGF_BIN_NAME.exe
114+ 7z a $JGF_BIN_NAME.zip $JGF_BIN_NAME.exe
115+
116+ # The binaries are zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
117+ - name : Archive Binaries
118+ if : runner.os != 'Windows'
119+ run : |
120+ JGF_BIN_NAME=jgf-${{ matrix.code-target }}
121+ mv target/${{ matrix.target }}/release/jgf $JGF_BIN_NAME
122+ tar czf $JGF_BIN_NAME.tar.gz $JGF_BIN_NAME
123+
124+ - name : Upload Binary
125+ uses : actions/upload-artifact@v4
126+ with :
127+ if-no-files-found : error
128+ name : binaries-${{ matrix.code-target }}
129+ path : |
130+ *.zip
131+ *.tar.gz
132+
133+ publish :
134+ name : Publish
135+ needs : [check, build]
136+ runs-on : ubuntu-latest
137+ permissions :
138+ contents : write # for creating GitHub release
139+ id-token : write # for npm provenance
140+ steps :
141+ - uses : actions/checkout@v4
142+ with :
143+ fetch-depth : 0 # for changelog
144+
145+ - uses : actions/download-artifact@v4
146+ with :
147+ merge-multiple : true
148+
149+ - name : Unzip
150+ run : |
151+ find . -name "*.zip" -exec unzip -qq {} \;
152+
153+ - name : Untar
154+ run : |
155+ find . -name "*.tar.gz" -exec tar xf {} \;
156+
157+ - uses : actions/setup-node@v4
158+ with :
159+ node-version : ' 20'
160+ registry-url : ' https://registry.npmjs.org'
161+
162+ - name : Generate npm packages
163+ run : |
164+ node npm/jgf/scripts/generate-packages.mjs
165+ cat npm/jgf/package.json
166+ for package in npm/jgf*; do cat $package/package.json ; echo ; done
167+
168+ - name : Publish npm packages as latest
169+ # NOTE: The trailing slash on $package/ changes it to publishing the directory
170+ run : |
171+ for package in npm/jgf*
172+ do
173+ npm publish $package/ --provenance --access public
174+ echo '----'
175+ done
176+ env :
177+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
178+
179+ - name : Create GitHub Release
180+ uses : softprops/action-gh-release@v2
181+ with :
182+ draft : false
183+ files : jgf-*
184+ name : jgf v${{ needs.check.outputs.version }}
185+ tag_name : v${{ needs.check.outputs.version }}
186+ fail_on_unmatched_files : true
187+ target_commitish : ${{ github.sha }}
188+
189+ - name : Wait 3 minutes for smoke test
190+ run : sleep 180s
191+
192+ smoke :
193+ needs : [check, publish]
194+ strategy :
195+ matrix :
196+ include :
197+ - os : windows-latest
198+ - os : ubuntu-latest
199+ - os : ubuntu-latest
200+ container : node:18-alpine # musl
201+ - os : macos-latest
202+ name : Smoke Test ${{ matrix.os }} ${{ matrix.container }}
203+ runs-on : ${{ matrix.os }}
204+ container : ${{ matrix.container }}
205+ steps :
206+ - name : Test
207+ env :
208+ JGF_VERSION : ${{ needs.check.outputs.version}}
209+ run : |
210+ npx jgf@${JGF_VERSION} --version
0 commit comments