Skip to content

Commit 484ec8b

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

File tree

4 files changed

+81
-18
lines changed

4 files changed

+81
-18
lines changed

.github/workflows/ci.yml

+69-18
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,59 @@ 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+
env:
42+
DUNE_PROFILE: static
43+
with:
44+
args: opam exec -- make
45+
46+
# Also avoids artifacts upload permission loss:
47+
# https://github.com/actions/upload-artifact/tree/ee69f02b3dfdecd58bb31b4d133da38ba6fe3700#permission-loss
48+
- name: Compress files
49+
run: |
50+
mkdir ${{matrix.artifact-folder}}
51+
mv rescript-editor-analysis.exe ${{matrix.artifact-folder}}
52+
mv rescript-tools.exe ${{matrix.artifact-folder}}
53+
tar -cvf binary.tar ${{matrix.artifact-folder}}
54+
55+
- name: "Upload artifacts"
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: ${{matrix.artifact-folder}}
59+
path: binary.tar
60+
61+
build:
1662
strategy:
1763
fail-fast: false
1864
matrix:
19-
# Stay on the oldest Ubuntu version that's still supported by Github Actions
20-
# to avoid glibc incompatibilities as far as possible.
2165
os: [
2266
macos-13, # x64
2367
macos-14, # ARM
24-
ubuntu-20.04,
2568
windows-latest,
2669
]
2770
# syntax explanation:
@@ -31,8 +74,6 @@ jobs:
3174
artifact-folder: darwin
3275
- os: macos-14
3376
artifact-folder: darwinarm64
34-
- os: ubuntu-20.04
35-
artifact-folder: linux
3677
- os: windows-latest
3778
artifact-folder: win32
3879

@@ -106,12 +147,14 @@ jobs:
106147
107148
- uses: actions/upload-artifact@v4
108149
with:
109-
name: ${{matrix.os}}
150+
name: ${{matrix.artifact-folder}}
110151
path: binary.tar
111152

112153
package:
113-
needs: test
114-
runs-on: ubuntu-20.04
154+
needs:
155+
- build
156+
- build-linux
157+
runs-on: ubuntu-latest
115158

116159
steps:
117160
- uses: actions/checkout@v4
@@ -125,34 +168,42 @@ jobs:
125168
- run: npm ci
126169
- run: npm run compile
127170

128-
- name: Download MacOS binary
171+
- name: Download MacOS binaries
172+
uses: actions/download-artifact@v4
173+
with:
174+
name: darwin
175+
path: binaries
176+
- run: tar -xvf binary.tar
177+
working-directory: binaries
178+
179+
- name: Download MacOS ARM binaries
129180
uses: actions/download-artifact@v4
130181
with:
131-
name: macos-13
182+
name: darwinarm64
132183
path: binaries
133184
- run: tar -xvf binary.tar
134185
working-directory: binaries
135186

136-
- name: Download MacOS ARM binary
187+
- name: Download Linux binaries
137188
uses: actions/download-artifact@v4
138189
with:
139-
name: macos-14
190+
name: linux
140191
path: binaries
141192
- run: tar -xvf binary.tar
142193
working-directory: binaries
143194

144-
- name: Download Linux binary
195+
- name: Download Linux ARM binaries
145196
uses: actions/download-artifact@v4
146197
with:
147-
name: ubuntu-20.04
198+
name: linuxarm64
148199
path: binaries
149200
- run: tar -xvf binary.tar
150201
working-directory: binaries
151202

152-
- name: Download Windows binary
203+
- name: Download Windows binaries
153204
uses: actions/download-artifact@v4
154205
with:
155-
name: windows-latest
206+
name: win32
156207
path: binaries
157208
- run: tar -xvf binary.tar
158209
working-directory: binaries
@@ -163,7 +214,7 @@ jobs:
163214

164215
- name: Move binaries to folders
165216
run: |
166-
declare -a platforms=("darwin" "darwinarm64" "linux" "win32")
217+
declare -a platforms=("darwin" "darwinarm64" "linux" "linuxarm64" "win32")
167218
168219
for platform in "${platforms[@]}"; do
169220
mkdir server/analysis_binaries/"$platform"

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#### :rocket: New Feature
2626

2727
- Add support for the rewatch build system for incremental compilation. https://github.com/rescript-lang/rescript-vscode/pull/965
28+
- Add support for Linux ARM64
29+
- Statically linked Linux binaries
2830

2931
## 1.50.0
3032

analysis/bin/dune

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
(env
2+
(static
3+
(flags
4+
(:standard -ccopt -static))))
5+
16
(executable
27
(public_name rescript-editor-analysis)
38
(package analysis)

tools/bin/dune

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
(env
2+
(static
3+
(flags
4+
(:standard -ccopt -static))))
5+
16
(executable
27
(public_name rescript-tools)
38
(package tools)

0 commit comments

Comments
 (0)