Skip to content

Commit abc6aa2

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

5 files changed

Lines changed: 155 additions & 189 deletions

File tree

.github/workflows/_prebuild-v8.yml

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