-
Notifications
You must be signed in to change notification settings - Fork 56
281 lines (236 loc) · 8.93 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
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
name: CI
on:
push:
branches: [ master ]
tags: "*.*.*"
pull_request:
branches: [ master ]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
fail-fast: false
matrix:
# Stay on the oldest Ubuntu version that's still supported by Github Actions
# to avoid glibc incompatibilities as far as possible.
os: [
macos-13, # x64
macos-14, # ARM
ubuntu-20.04,
windows-latest,
]
# syntax explanation:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
include:
- os: macos-13
artifact-folder: darwin
- os: macos-14
artifact-folder: darwinarm64
- os: ubuntu-20.04
artifact-folder: linux
- os: windows-latest
artifact-folder: win32
runs-on: ${{matrix.os}}
steps:
# needed for Windows testing
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v4
- name: Cache OCaml's opam
uses: actions/cache@v4
with:
path: ~/.opam
key: ${{matrix.os}}-rescript-vscode-v4
- name: Use OCaml
uses: ocaml/setup-ocaml@v2
if: matrix.os != 'windows-latest'
with:
ocaml-compiler: 5.1.1
opam-pin: false
opam-depext: false
- name: Use OCaml (Windows)
uses: ocaml/setup-ocaml@v2
if: matrix.os == 'windows-latest'
with:
ocaml-compiler: ocaml-variants.5.1.1+options,ocaml-option-mingw
opam-pin: false
opam-depext: false
opam-repositories: |
windows-5.0: https://github.com/dra27/opam-repository.git#windows-5.0
sunset: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
default: https://github.com/ocaml/opam-repository.git
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: opam install dune cppo
- run: npm run compile
- run: npm run bundle
# These 2 runs (or just the second?) are for when you have opam dependencies. We don't.
# Don't add deps. But if you ever do, un-comment these and add an .opam file.
# - run: opam pin add rescript-editor-analysis.dev . --no-action
# - run: opam install . --deps-only --with-doc --with-test
- name: Build
run: opam exec -- make
- name: Test
run: opam exec -- make test
# Also avoids artifacts upload permission loss:
# https://github.com/actions/upload-artifact/tree/ee69f02b3dfdecd58bb31b4d133da38ba6fe3700#permission-loss
- name: Compress files
run: |
mkdir ${{matrix.artifact-folder}}
mv rescript-editor-analysis.exe ${{matrix.artifact-folder}}
mv rescript-tools.exe ${{matrix.artifact-folder}}
tar -cvf binary.tar ${{matrix.artifact-folder}}
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.os}}
path: binary.tar
package:
needs: test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run compile
- name: Download MacOS binary
uses: actions/download-artifact@v4
with:
name: macos-13
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Download MacOS ARM binary
uses: actions/download-artifact@v4
with:
name: macos-14
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Download Linux binary
uses: actions/download-artifact@v4
with:
name: ubuntu-20.04
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Download Windows binary
uses: actions/download-artifact@v4
with:
name: windows-latest
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Cleanup tar file
run: rm binary.tar
working-directory: binaries
- name: Move binaries to folders
run: |
declare -a platforms=("darwin" "darwinarm64" "linux" "win32")
for platform in "${platforms[@]}"; do
mkdir server/analysis_binaries/"$platform"
mv binaries/"$platform"/rescript-editor-analysis.exe server/analysis_binaries/"$platform"
done
for platform in "${platforms[@]}"; do
mkdir tools/binaries/"$platform"
mv binaries/"$platform"/rescript-tools.exe tools/binaries/"$platform"
done
- name: Store short commit SHA for filename
id: vars
env:
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: echo "sha_short=${COMMIT_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Store tag name
id: tag_name
if: startsWith(github.ref, 'refs/tags/')
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Increment pre-release version
if: github.ref == 'refs/heads/master'
id: increment_pre_release
run: |
JSON=$(npx vsce show chenglou92.rescript-vscode --json)
NEW_VERSION=$(echo $JSON | jq -r '.versions | .[0] | .["version"]')
node .github/workflows/bump-version.js ${NEW_VERSION}
- name: Package Extension
if: github.ref != 'refs/heads/master'
run: npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
- name: Package Extension pre-release version
if: github.ref == 'refs/heads/master'
run: npx vsce package -o rescript-vscode-latest-master.vsix ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
- name: Package Extension release version
if: startsWith(github.ref, 'refs/tags/')
run: npx vsce package -o rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
- uses: actions/upload-artifact@v4
if: github.ref != 'refs/heads/master'
with:
name: rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
path: rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
- uses: actions/upload-artifact@v4
if: github.ref == 'refs/heads/master'
with:
name: rescript-vscode-latest-master.vsix
path: rescript-vscode-latest-master.vsix
- uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/')
with:
name: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
path: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
- name: Publish latest master to GitHub
if: github.ref == 'refs/heads/master'
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest-master"
prerelease: true
title: "Latest master"
files: rescript-vscode-latest-master.vsix
- name: Publish release version to GitHub
if: startsWith(github.ref, 'refs/tags/')
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
title: ${{ steps.tag_name.outputs.tag }}
files: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
- name: Publish extension as pre-release
if: github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'publish tools')
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --pre-release ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
- name: Publish extension as release
if: startsWith(github.ref, 'refs/tags/')
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
- name: Publish LSP as pre-release to NPM
if: github.ref == 'refs/heads/master'
working-directory: server
run: |
npm version preminor --preid next-$(git rev-parse --short HEAD)
npm publish --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish LSP to NPM
if: startsWith(github.ref, 'refs/tags/')
working-directory: server
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build @rescript/tools package
working-directory: tools
run: |
npm ci
npm run build
- name: Publish @rescript/tools package
if: ${{ startsWith(github.event.head_commit.message, 'publish tools') && (github.ref == 'refs/heads/master') }}
working-directory: tools
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}