Skip to content

Commit 36da42a

Browse files
committed
Build for Mac
1 parent 2af378d commit 36da42a

1 file changed

Lines changed: 9 additions & 315 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 315 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [master]
6-
tags: "*.*.*"
5+
branches: [master, rewatch-lsp]
76
pull_request:
87
branches: [master]
98

@@ -13,334 +12,29 @@ concurrency:
1312

1413
jobs:
1514
build:
16-
strategy:
17-
fail-fast: false
18-
matrix:
19-
os: [
20-
macos-15-intel, # x64
21-
macos-15, # ARM
22-
ubuntu-24.04, # x64
23-
ubuntu-24.04-arm, # ARM
24-
windows-latest,
25-
]
26-
# syntax explanation:
27-
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
28-
include:
29-
- os: macos-15-intel
30-
ocaml-compiler: 5.2.1
31-
dune-profile: release
32-
artifact-folder: darwin
33-
- os: macos-15
34-
ocaml-compiler: 5.2.1
35-
dune-profile: release
36-
artifact-folder: darwinarm64
37-
- os: ubuntu-24.04
38-
ocaml-compiler: ocaml-variants.5.2.1+options,ocaml-option-static
39-
dune-profile: static
40-
artifact-folder: linux
41-
- os: ubuntu-24.04-arm
42-
ocaml-compiler: ocaml-variants.5.2.1+options,ocaml-option-static
43-
dune-profile: static
44-
artifact-folder: linuxarm64
45-
- os: windows-latest
46-
ocaml-compiler: 5.2.1
47-
dune-profile: release
48-
artifact-folder: win32
49-
50-
runs-on: ${{matrix.os}}
15+
runs-on: macos-15
5116

5217
steps:
53-
# needed for Windows testing
54-
- name: Set git to use LF
55-
run: |
56-
git config --global core.autocrlf false
57-
git config --global core.eol lf
58-
5918
- uses: actions/checkout@v4
6019

61-
- name: Cache OCaml's opam
62-
uses: actions/cache@v4
63-
with:
64-
path: ~/.opam
65-
key: ${{matrix.os}}-rescript-vscode-v5
66-
67-
- name: Use OCaml
68-
uses: ocaml/setup-ocaml@v3
69-
with:
70-
ocaml-compiler: ${{matrix.ocaml-compiler}}
71-
opam-pin: false
72-
73-
- name: Use Node.js
74-
uses: actions/setup-node@v4
75-
with:
76-
node-version: 20
77-
registry-url: "https://registry.npmjs.org"
78-
79-
- run: npm ci
80-
- run: npm install --include=optional
81-
- run: opam install dune cppo
82-
- run: npm run compile
83-
- run: npm run bundle
84-
85-
# These 2 runs (or just the second?) are for when you have opam dependencies. We don't.
86-
# Don't add deps. But if you ever do, un-comment these and add an .opam file.
87-
# - run: opam pin add rescript-editor-analysis.dev . --no-action
88-
# - run: opam install . --deps-only --with-doc --with-test
89-
90-
- name: Set dune profile according to platform
91-
run: echo "DUNE_PROFILE=${{ matrix.dune-profile }}" >> $GITHUB_ENV
92-
93-
- name: Install ocamlformat
94-
run: opam install ocamlformat.0.27.0
95-
96-
- name: Format check
97-
run: opam exec -- make checkformat
98-
99-
- name: Build
100-
run: opam exec -- make
101-
102-
- name: Test
103-
run: opam exec -- make test
104-
105-
- name: Strip binaries
106-
if: matrix.os != 'windows-latest'
107-
run: strip rescript-editor-analysis.exe rescript-tools.exe
108-
109-
# Also avoids artifacts upload permission loss:
110-
# https://github.com/actions/upload-artifact/tree/ee69f02b3dfdecd58bb31b4d133da38ba6fe3700#permission-loss
111-
- name: Compress files
112-
run: |
113-
mkdir ${{matrix.artifact-folder}}
114-
mv rescript-editor-analysis.exe ${{matrix.artifact-folder}}
115-
mv rescript-tools.exe ${{matrix.artifact-folder}}
116-
tar -cvf binary.tar ${{matrix.artifact-folder}}
117-
118-
- name: Upload binaries
119-
uses: actions/upload-artifact@v4
120-
with:
121-
name: ${{matrix.artifact-folder}}
122-
path: binary.tar
123-
124-
- name: Upload platform bindings
125-
if: always()
126-
uses: actions/upload-artifact@v4
127-
with:
128-
name: bindings-${{matrix.artifact-folder}}
129-
path: node_modules/@oxc-parser/
130-
retention-days: 1
131-
132-
package:
133-
needs:
134-
- build
135-
runs-on: ubuntu-24.04
136-
137-
steps:
138-
- uses: actions/checkout@v4
139-
140-
- name: Use Node.js
141-
uses: actions/setup-node@v4
142-
with:
143-
node-version: 20
144-
registry-url: "https://registry.npmjs.org"
145-
146-
- run: npm ci
147-
- run: npm install --include=optional
148-
- run: npm run compile
149-
150-
- name: Download MacOS binaries
151-
uses: actions/download-artifact@v4
152-
with:
153-
name: darwin
154-
path: binaries
155-
- run: tar -xvf binary.tar
156-
working-directory: binaries
157-
158-
- name: Download MacOS ARM binaries
159-
uses: actions/download-artifact@v4
160-
with:
161-
name: darwinarm64
162-
path: binaries
163-
- run: tar -xvf binary.tar
164-
working-directory: binaries
165-
166-
- name: Download Linux binaries
167-
uses: actions/download-artifact@v4
168-
with:
169-
name: linux
170-
path: binaries
171-
- run: tar -xvf binary.tar
172-
working-directory: binaries
173-
174-
- name: Download Linux ARM binaries
175-
uses: actions/download-artifact@v4
176-
with:
177-
name: linuxarm64
178-
path: binaries
179-
- run: tar -xvf binary.tar
180-
working-directory: binaries
181-
182-
- name: Download Windows binaries
183-
uses: actions/download-artifact@v4
184-
with:
185-
name: win32
186-
path: binaries
187-
- run: tar -xvf binary.tar
188-
working-directory: binaries
189-
190-
- name: Cleanup tar file
191-
run: rm binary.tar
192-
working-directory: binaries
193-
194-
- name: Download platform bindings from all platforms
195-
uses: actions/download-artifact@v4
196-
with:
197-
pattern: bindings-*
198-
path: bindings
199-
merge-multiple: true
200-
201-
- name: Move binaries to folders
202-
run: |
203-
declare -a platforms=("darwin" "darwinarm64" "linux" "linuxarm64" "win32")
204-
205-
for platform in "${platforms[@]}"; do
206-
mkdir server/analysis_binaries/"$platform"
207-
mv binaries/"$platform"/rescript-editor-analysis.exe server/analysis_binaries/"$platform"
208-
done
209-
210-
for platform in "${platforms[@]}"; do
211-
mkdir tools/binaries/"$platform"
212-
mv binaries/"$platform"/rescript-tools.exe tools/binaries/"$platform"
213-
done
20+
- name: Setup Bun
21+
uses: oven-sh/setup-bun@v2
21422

215-
- name: Merge platform bindings into node_modules
216-
run: |
217-
mkdir -p node_modules/@oxc-parser
218-
# Copy all bindings from downloaded artifacts
219-
if [ -d "bindings" ]; then
220-
find bindings -type d -name "binding-*" -exec cp -r {} node_modules/@oxc-parser/ \;
221-
fi
222-
# Ensure we have the Linux binding from current platform
223-
npm install --include=optional || true
23+
- run: bun install
24+
- run: bun run compile
25+
- run: bun run bundle
26+
- run: make checkformat
22427

22528
- name: Store short commit SHA for filename
22629
id: vars
22730
env:
22831
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
22932
run: echo "sha_short=${COMMIT_SHA:0:7}" >> $GITHUB_OUTPUT
23033

231-
- name: Store tag name
232-
id: tag_name
233-
if: startsWith(github.ref, 'refs/tags/')
234-
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
235-
236-
- name: Increment pre-release version
237-
if: github.ref == 'refs/heads/master'
238-
id: increment_pre_release
239-
run: |
240-
JSON=$(npx vsce show chenglou92.rescript-vscode --json)
241-
NEW_VERSION=$(echo $JSON | jq -r '.versions | .[0] | .["version"]')
242-
node .github/workflows/bump-version.js ${NEW_VERSION}
243-
24434
- name: Package Extension
245-
if: github.ref != 'refs/heads/master'
246-
run: npx vsce package --no-yarn -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
247-
248-
- name: Package Extension pre-release version
249-
if: github.ref == 'refs/heads/master'
250-
run: npx vsce package --no-yarn -o rescript-vscode-latest-master.vsix ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
251-
252-
- name: Package Extension release version
253-
if: startsWith(github.ref, 'refs/tags/')
254-
run: npx vsce package --no-yarn -o rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
255-
256-
- name: Verify Package Contents
257-
run: npm run verify-package
35+
run: bunx vsce package --no-yarn -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
25836

25937
- uses: actions/upload-artifact@v4
260-
if: github.ref != 'refs/heads/master'
26138
with:
26239
name: rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
26340
path: rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
264-
265-
- uses: actions/upload-artifact@v4
266-
if: github.ref == 'refs/heads/master'
267-
with:
268-
name: rescript-vscode-latest-master.vsix
269-
path: rescript-vscode-latest-master.vsix
270-
271-
- uses: actions/upload-artifact@v4
272-
if: startsWith(github.ref, 'refs/tags/')
273-
with:
274-
name: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
275-
path: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
276-
277-
- name: Move latest-master tag to current commit
278-
if: github.ref == 'refs/heads/master'
279-
run: |
280-
git tag -d latest-master || true
281-
git push origin --delete latest-master || true
282-
git tag latest-master
283-
git push origin latest-master
284-
285-
- name: Publish latest master to GitHub
286-
if: github.ref == 'refs/heads/master'
287-
uses: softprops/action-gh-release@v2
288-
with:
289-
token: "${{ secrets.GITHUB_TOKEN }}"
290-
tag_name: "latest-master"
291-
prerelease: true
292-
generate_release_notes: true
293-
name: "Latest master"
294-
files: rescript-vscode-latest-master.vsix
295-
296-
- name: Generate release notes from changelog
297-
if: startsWith(github.ref, 'refs/tags/')
298-
run: |
299-
sed -e "/^## ${{ steps.tag_name.outputs.tag }}/,/^## / ! d" CHANGELOG.md | head -n -2 > RELEASE.md
300-
301-
- name: Publish release version to GitHub
302-
if: startsWith(github.ref, 'refs/tags/')
303-
uses: softprops/action-gh-release@v2
304-
with:
305-
token: "${{ secrets.GITHUB_TOKEN }}"
306-
prerelease: false
307-
body_path: RELEASE.md
308-
name: ${{ steps.tag_name.outputs.tag }}
309-
files: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
310-
311-
- name: Publish extension as pre-release
312-
if: github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'publish tools')
313-
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --pre-release ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
314-
315-
- name: Publish extension as release
316-
if: startsWith(github.ref, 'refs/tags/')
317-
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
318-
319-
- name: Publish LSP as pre-release to NPM
320-
if: github.ref == 'refs/heads/master'
321-
working-directory: server
322-
run: |
323-
npm version preminor --preid next-$(git rev-parse --short HEAD)
324-
npm publish --access public --tag next
325-
env:
326-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
327-
328-
- name: Publish LSP to NPM
329-
if: startsWith(github.ref, 'refs/tags/')
330-
working-directory: server
331-
run: npm publish --access public
332-
env:
333-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
334-
335-
- name: Build @rescript/tools package
336-
working-directory: tools
337-
run: |
338-
npm ci
339-
npm run build
340-
341-
- name: Publish @rescript/tools package
342-
if: ${{ startsWith(github.event.head_commit.message, 'publish tools') && (github.ref == 'refs/heads/master') }}
343-
working-directory: tools
344-
run: npm publish --access public
345-
env:
346-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)