-
Notifications
You must be signed in to change notification settings - Fork 20
125 lines (108 loc) · 3.44 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
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [
macos-13, # x64
macos-14, # ARM
ubuntu-latest,
windows-latest,
]
target: [rescript]
# syntax explanation:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
include:
- os: ubuntu-latest
target: ocaml.4.08
ocaml-compiler: 4.08.x
build: opam exec -- dune build
- os: ubuntu-latest
target: ocaml.4.14
ocaml-compiler: 4.14.x
build: opam exec -- dune build
- os: ubuntu-latest
target: ocaml.5.0
ocaml-compiler: 5.0.x
build: opam exec -- dune build
- os: ubuntu-latest
target: ocaml.5.1
ocaml-compiler: 5.1.x
build: opam exec -- dune build
- os: ubuntu-latest
target: ocaml.5.2
ocaml-compiler: 5.2.x
build: opam exec -- dune build
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}}-reanalyze-v2
- name: Use OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{matrix.ocaml-compiler}}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci
- run: opam install dune cppo
- name: Build
run: ${{matrix.build}}
- name: Test
if: matrix.target == 'rescript'
run: ${{matrix.test}}
# Also avoids artifacts upload permission loss:
# https://github.com/actions/upload-artifact/tree/ee69f02b3dfdecd58bb31b4d133da38ba6fe3700#permission-loss
- name: Compress files
if: matrix.target == 'rescript'
run: |
mkdir ${{matrix.artifact-folder}}
cp _build/default/src/Reanalyze.exe reanalyze.exe
tar -cvf binary.tar reanalyze.exe
- uses: actions/upload-artifact@v4
if: matrix.target == 'rescript'
with:
name: ${{matrix.os}}
path: binary.tar
npm_pack:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: download binaries
uses: actions/download-artifact@v4
- name: Pack reanalyze
run: |
# Put the built artifacts in the appropriate package folder
tar xf macos-13/binary.tar -C dist/vendor-darwin
tar xf macos-14/binary.tar -C dist/vendor-darwinarm64
tar xf ubuntu-latest/binary.tar -C dist/vendor-linux
tar xf windows-latest/binary.tar -C dist/vendor-win32
# Add the correct package.json / README / etc to dist
node scripts/prepare_release.js
# Pack everything up
cd dist
npm pack
cd ..
mv dist/reanalyze-*.tgz reanalyze-npm.tgz
- name: upload reanalyze-npm.tgz
uses: actions/upload-artifact@v4
with:
name: reanalyze-npm.tgz
path: reanalyze-npm.tgz