Skip to content

Commit d0f6d7e

Browse files
committed
Build static linux binaries
1 parent 3b5824b commit d0f6d7e

File tree

1 file changed

+66
-19
lines changed

1 file changed

+66
-19
lines changed

.github/workflows/ci.yml

+66-19
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,56 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
test:
15+
# Build statically linked Linux binaries in an Alpine-based Docker container
16+
# See https://ocamlpro.com/blog/2021_09_02_generating_static_and_portable_executables_with_ocaml
17+
# for more info.
18+
# The container already comes with all required tools pre-installed
19+
# (see https://github.com/rescript-lang/docker-rescript-ci-build/blob/main/Dockerfile).
20+
build-linux:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [ubuntu-latest, buildjet-2vcpu-ubuntu-2204-arm]
25+
# syntax explanation:
26+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
27+
include:
28+
- os: ubuntu-latest
29+
artifact-folder: linux
30+
- os: buildjet-2vcpu-ubuntu-2204-arm
31+
artifact-folder: linuxarm64
32+
33+
runs-on: ${{matrix.os}}
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Build
40+
uses: docker://ghcr.io/rescript-lang/rescript-ci-build:alpine-3.19-ocaml-5.1.1-01
41+
with:
42+
args: opam exec -- make
43+
44+
# Also avoids artifacts upload permission loss:
45+
# https://github.com/actions/upload-artifact/tree/ee69f02b3dfdecd58bb31b4d133da38ba6fe3700#permission-loss
46+
- name: Compress files
47+
run: |
48+
mkdir ${{matrix.artifact-folder}}
49+
mv rescript-editor-analysis.exe rescript-tools.exe ${{matrix.artifact-folder}}
50+
tar -cvf binary.tar ${{matrix.artifact-folder}}
51+
52+
- name: "Upload artifacts"
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{matrix.artifact-folder}}
56+
path: binary.tar
57+
58+
build:
1659
strategy:
1760
fail-fast: false
1861
matrix:
19-
# Stay on the oldest Ubuntu version that's still supported by Github Actions
20-
# to avoid glibc incompatibilities as far as possible.
2162
os: [
2263
macos-13, # x64
2364
macos-14, # ARM
24-
ubuntu-20.04,
2565
windows-latest,
2666
]
2767
# syntax explanation:
@@ -31,8 +71,6 @@ jobs:
3171
artifact-folder: darwin
3272
- os: macos-14
3373
artifact-folder: darwinarm64
34-
- os: ubuntu-20.04
35-
artifact-folder: linux
3674
- os: windows-latest
3775
artifact-folder: win32
3876

@@ -100,17 +138,18 @@ jobs:
100138
- name: Compress files
101139
run: |
102140
mkdir ${{matrix.artifact-folder}}
103-
mv rescript-editor-analysis.exe ${{matrix.artifact-folder}}
104-
mv rescript-tools.exe ${{matrix.artifact-folder}}
141+
mv rescript-editor-analysis.exe rescript-tools.exe ${{matrix.artifact-folder}}
105142
tar -cvf binary.tar ${{matrix.artifact-folder}}
106143
107144
- uses: actions/upload-artifact@v4
108145
with:
109-
name: ${{matrix.os}}
146+
name: ${{matrix.artifact-folder}}
110147
path: binary.tar
111148

112149
package:
113-
needs: test
150+
needs:
151+
- build
152+
- build-linux
114153
runs-on: ubuntu-20.04
115154

116155
steps:
@@ -125,34 +164,42 @@ jobs:
125164
- run: npm ci
126165
- run: npm run compile
127166

128-
- name: Download MacOS binary
167+
- name: Download MacOS binaries
168+
uses: actions/download-artifact@v4
169+
with:
170+
name: darwin
171+
path: binaries
172+
- run: tar -xvf binary.tar
173+
working-directory: binaries
174+
175+
- name: Download MacOS ARM binaries
129176
uses: actions/download-artifact@v4
130177
with:
131-
name: macos-13
178+
name: darwinarm64
132179
path: binaries
133180
- run: tar -xvf binary.tar
134181
working-directory: binaries
135182

136-
- name: Download MacOS ARM binary
183+
- name: Download Linux binaries
137184
uses: actions/download-artifact@v4
138185
with:
139-
name: macos-14
186+
name: linux
140187
path: binaries
141188
- run: tar -xvf binary.tar
142189
working-directory: binaries
143190

144-
- name: Download Linux binary
191+
- name: Download Linux ARM binaries
145192
uses: actions/download-artifact@v4
146193
with:
147-
name: ubuntu-20.04
194+
name: linuxarm64
148195
path: binaries
149196
- run: tar -xvf binary.tar
150197
working-directory: binaries
151198

152-
- name: Download Windows binary
199+
- name: Download Windows binaries
153200
uses: actions/download-artifact@v4
154201
with:
155-
name: windows-latest
202+
name: win32
156203
path: binaries
157204
- run: tar -xvf binary.tar
158205
working-directory: binaries
@@ -163,7 +210,7 @@ jobs:
163210

164211
- name: Move binaries to folders
165212
run: |
166-
declare -a platforms=("darwin" "darwinarm64" "linux" "win32")
213+
declare -a platforms=("darwin" "darwinarm64" "linux" "linuxarm64" "win32")
167214
168215
for platform in "${platforms[@]}"; do
169216
mkdir server/analysis_binaries/"$platform"

0 commit comments

Comments
 (0)