Skip to content

Commit b921b71

Browse files
committed
Update deps in CI, move common scripts to reusable action
1 parent 71c8035 commit b921b71

File tree

5 files changed

+136
-189
lines changed

5 files changed

+136
-189
lines changed

.github/workflows/_prebuild-v8.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: prebuild v8
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
runner:
7+
type: string
8+
target:
9+
type: string
10+
build_type:
11+
type: string
12+
lp_cache:
13+
type: string
14+
default: '.lp-cache'
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
build:
21+
runs-on: ${{ inputs.runner }}
22+
steps:
23+
- name: Parse target
24+
shell: bash
25+
run: |
26+
echo "OS=$(echo "${{ inputs.target }}" | cut -d- -f2)" >> "$GITHUB_ENV"
27+
echo "ARCH=$(echo "${{ inputs.target }}" | cut -d- -f1)" >> "$GITHUB_ENV"
28+
29+
- uses: mlugg/setup-zig@v2.2.1
30+
with:
31+
cache-key: ${{ inputs.target }}
32+
33+
- uses: actions/checkout@v6.0.2
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Read V8 version from build.zig
38+
shell: bash
39+
run: echo "V8_REVISION=$(sed -n 's/^const V8_VERSION.*"\(.*\)".*/\1/p' build.zig)" >> "$GITHUB_ENV"
40+
41+
- uses: actions/setup-python@v6.2.0
42+
if: contains(inputs.target, 'macos') || contains(inputs.target, 'ios')
43+
with:
44+
python-version: '3.13'
45+
46+
- name: Install dependencies (Linux x86_64)
47+
if: contains(inputs.target, 'linux')
48+
shell: bash
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get install -yq libglib2.0-dev lld
52+
53+
- name: Install dependencies (Linux aarch64)
54+
if: contains(inputs.target, 'aarch64-linux')
55+
shell: bash
56+
run: |
57+
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh
58+
sudo ./llvm.sh 21
59+
sudo ln -nsf /usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins-aarch64.a /usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins.a
60+
sudo ln -nsf /usr/lib/llvm-21/lib/clang/21/lib/linux/ /usr/lib/llvm-21/lib/clang/21/lib/aarch64-unknown-linux-gnu
61+
62+
- shell: bash
63+
run: zig env
64+
65+
- name: Build V8
66+
shell: bash
67+
run: |
68+
if [ "${{ inputs.build_type }}" = "debug" ]; then
69+
zig build -Dtarget="${{ inputs.target }}" -Doptimize=Debug -Dis_tsan=true -Dv8_enable_sandbox=true build-v8
70+
else
71+
zig build -Dtarget="${{ inputs.target }}" -Doptimize=ReleaseSafe build-v8
72+
fi
73+
74+
- name: Find v8 library
75+
shell: bash
76+
run: |
77+
DST="${{ env.ARCH }}"
78+
if [ "${{ inputs.build_type }}" = "debug" ]; then
79+
DST="${DST}_debug"
80+
fi
81+
if [ "${{ env.OS }}" = "ios" ]; then
82+
DST="simulator_${DST}"
83+
fi
84+
mv "${{ inputs.lp_cache }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/${{ inputs.build_type }}/obj/zig/libc_v8.a" "libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_$DST.a"
85+
86+
- name: Upload the build
87+
if: startsWith(github.ref, 'refs/tags/')
88+
uses: ncipollo/release-action@v1
89+
with:
90+
allowUpdates: true
91+
artifacts: libc_v8_*.a

.github/workflows/build-release.yml

Lines changed: 33 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -2,205 +2,53 @@ name: build-release
22

33
on:
44
push:
5-
tags:
6-
- "**"
5+
tags: ["**"]
6+
77
# Allows you to run this workflow manually from the Actions tab
88
workflow_dispatch:
99

1010
permissions:
1111
contents: write
1212

13-
env:
14-
ZIG_VERSION: 0.15.1
15-
V8_REVISION: 14.0.365.4
16-
LP_CACHE: ".lp-cache"
17-
1813
jobs:
1914
build-x86_64-linux:
20-
env:
21-
OS: linux
22-
ARCH: x86_64
23-
24-
runs-on: ubuntu-22.04
25-
steps:
26-
- uses: mlugg/setup-zig@v2.0.5
27-
with:
28-
version: ${{ env.ZIG_VERSION }}
29-
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}
30-
31-
- uses: actions/checkout@v4
32-
with:
33-
submodules: recursive
34-
fetch-depth: 0
35-
36-
- run: zig env
37-
38-
- run: |
39-
sudo apt-get update
40-
sudo apt-get install -yq libglib2.0-dev
41-
42-
- run: zig build -Doptimize=ReleaseSafe build-v8
43-
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
44-
45-
- name: Upload the build
46-
uses: ncipollo/release-action@v1
47-
with:
48-
allowUpdates: true
49-
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
15+
uses: ./.github/workflows/_prebuild-v8.yml
16+
with:
17+
runner: ubuntu-24.04
18+
target: x86_64-linux
19+
build_type: release
5020

5121
build-x86_64-linux-debug:
52-
env:
53-
OS: linux
54-
ARCH: x86_64
55-
56-
runs-on: ubuntu-22.04
57-
steps:
58-
- uses: mlugg/setup-zig@v2.0.5
59-
with:
60-
version: ${{ env.ZIG_VERSION }}
61-
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}
62-
63-
- uses: actions/checkout@v4
64-
with:
65-
submodules: recursive
66-
fetch-depth: 0
67-
68-
- run: zig env
69-
70-
- run: |
71-
sudo apt-get update
72-
sudo apt-get install -yq libglib2.0-dev
73-
74-
- run: zig build -Doptimize=Debug -Dis_tsan=true -Dv8_enable_sandbox=true build-v8
75-
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/debug/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}_debug.a
76-
77-
- name: Upload the build
78-
uses: ncipollo/release-action@v1
79-
with:
80-
allowUpdates: true
81-
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}_debug.a
82-
83-
build-aarch64-macos:
84-
env:
85-
OS: macos
86-
ARCH: aarch64
87-
88-
runs-on: macos-latest
89-
steps:
90-
- uses: mlugg/setup-zig@v2
91-
with:
92-
version: ${{ env.ZIG_VERSION }}
93-
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}
94-
95-
- uses: actions/setup-python@v5
96-
with:
97-
python-version: '3.11'
98-
99-
- uses: actions/checkout@v4
100-
with:
101-
submodules: recursive
102-
fetch-depth: 0
103-
104-
- run: zig build -Doptimize=ReleaseSafe build-v8
105-
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
106-
107-
- name: Upload the build
108-
uses: ncipollo/release-action@v1
109-
with:
110-
allowUpdates: true
111-
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
22+
uses: ./.github/workflows/_prebuild-v8.yml
23+
with:
24+
runner: ubuntu-24.04
25+
target: x86_64-linux
26+
build_type: debug
11227

11328
build-arm64-linux:
114-
env:
115-
OS: linux
116-
ARCH: aarch64
117-
118-
runs-on: ubuntu-22.04-arm
119-
steps:
120-
- uses: mlugg/setup-zig@v2
121-
with:
122-
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}
123-
version: ${{ env.ZIG_VERSION }}
124-
125-
- uses: actions/checkout@v4
126-
with:
127-
submodules: recursive
128-
fetch-depth: 0
29+
uses: ./.github/workflows/_prebuild-v8.yml
30+
with:
31+
runner: ubuntu-24.04-arm
32+
target: aarch64-linux
33+
build_type: release
12934

130-
- run: |
131-
sudo apt-get update
132-
sudo apt-get install -yq libglib2.0-dev lld
133-
wget https://apt.llvm.org/llvm.sh
134-
chmod +x llvm.sh
135-
sudo ./llvm.sh 21
136-
sudo ln -nsf /usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins-aarch64.a /usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins.a && \
137-
sudo ln -nsf /usr/lib/llvm-21/lib/clang/21/lib/linux/ /usr/lib/llvm-21/lib/clang/21/lib/aarch64-unknown-linux-gnu
138-
139-
- run: zig build -Doptimize=ReleaseSafe build-v8
140-
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
141-
142-
- name: Upload the build
143-
uses: ncipollo/release-action@v1
144-
with:
145-
allowUpdates: true
146-
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
35+
build-aarch64-macos:
36+
uses: ./.github/workflows/_prebuild-v8.yml
37+
with:
38+
runner: macos-26
39+
target: aarch64-macos
40+
build_type: release
14741

14842
build-x86_64-macos:
149-
env:
150-
OS: macos
151-
ARCH: x86_64
152-
153-
runs-on: macos-15-large
154-
steps:
155-
- uses: mlugg/setup-zig@v2
156-
with:
157-
version: ${{ env.ZIG_VERSION }}
158-
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}
159-
160-
- uses: actions/setup-python@v5
161-
with:
162-
python-version: '3.11'
163-
164-
- uses: actions/checkout@v4
165-
with:
166-
submodules: recursive
167-
fetch-depth: 0
168-
169-
- run: zig build -Doptimize=ReleaseSafe build-v8
170-
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
171-
172-
- name: Upload the build
173-
uses: ncipollo/release-action@v1
174-
with:
175-
allowUpdates: true
176-
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
43+
uses: ./.github/workflows/_prebuild-v8.yml
44+
with:
45+
runner: macos-26-intel
46+
target: x86_64-macos
47+
build_type: release
17748

17849
build-aarch64-ios:
179-
env:
180-
OS: ios
181-
ARCH: aarch64
182-
TARGET_ENVIRONMENT: simulator
183-
184-
runs-on: macos-latest
185-
steps:
186-
- uses: mlugg/setup-zig@v2
187-
with:
188-
version: ${{ env.ZIG_VERSION }}
189-
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}
190-
- uses: actions/setup-python@v5
191-
with:
192-
python-version: '3.11'
193-
194-
- uses: actions/checkout@v4
195-
with:
196-
submodules: recursive
197-
fetch-depth: 0
198-
199-
- run: zig build -Doptimize=ReleaseSafe build-v8
200-
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/macos/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.TARGET_ENVIRONMENT }}_${{ env.ARCH }}.a
201-
202-
- name: Upload the build
203-
uses: ncipollo/release-action@v1
204-
with:
205-
allowUpdates: true
206-
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.TARGET_ENVIRONMENT }}_${{ env.ARCH }}.a
50+
uses: ./.github/workflows/_prebuild-v8.yml
51+
with:
52+
runner: macos-26
53+
target: aarch64-ios-simulator
54+
build_type: release

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This dockerfile is used to build v8.
2-
ARG ZIG_DOCKER_VERSION=0.15.1
2+
ARG ZIG_DOCKER_VERSION=0.15.2
33
FROM ghcr.io/lightpanda-io/zig:${ZIG_DOCKER_VERSION} as build
44

55
ARG OS=linux

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Builds V8 from official source and provides C bindings and a Zig API. This would
55
V8 is the JS/WASM runtime that powers Google Chrome and Microsoft Edge.
66

77
## System Requirements
8-
- Zig compiler (0.15.1). Clone and build https://github.com/ziglang/zig.
8+
- Zig compiler (0.15.2). Clone and build https://github.com/ziglang/zig.
99
- Python 3 (2.7 seems to work as well)
1010
- unzip (`apt install unzip`)
1111
- rsync (`apt install rsync`)

build.zig.zon

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
.{
22
.name = .v8,
3-
.paths = .{""},
43
.version = "0.0.0",
5-
.fingerprint = 0x10be7411eb47d7c5,
4+
.fingerprint = 0x10be7411eb47d7c5, // Changing this has security and trust implications.
5+
.minimum_zig_version = "0.15.2",
66
.dependencies = .{
77
.depot_tools = .{
88
.url = "https://chromium.googlesource.com/chromium/tools/depot_tools.git/+archive/4ce8ba39a3488397a2d1494f167020f21de502f3.tar.gz",
99
.hash = "N-V-__8AABDOXwDW4TLrTiydikRCN2ym9hJI1GKGR09ZLBvY",
1010
},
1111
},
12+
.paths = .{
13+
"src/",
14+
"build-tools/",
15+
"README",
16+
"LICENSE",
17+
"build.zig",
18+
"build.zig.zon",
19+
},
1220
}

0 commit comments

Comments
 (0)