Skip to content

fix(ci): skip publish verification when prebuilt is unavailable #34

fix(ci): skip publish verification when prebuilt is unavailable

fix(ci): skip publish verification when prebuilt is unavailable #34

Workflow file for this run

name: ci
on:
push:
tags: ["**"]
branches: [isolate-scope]
pull_request:
branches: [main]
workflow_dispatch:
permissions: write-all
jobs:
build:
name:
${{ matrix.config.variant }} ${{ matrix.config.target }} ${{
matrix.config.features }}
runs-on: ${{ matrix.config.os }}
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
# ===== Runner sizes reference =====
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners
# https://docs.github.com/en/actions/reference/runners/larger-runners
# https://docs.github.com/en/billing/reference/actions-runner-pricing
# macOS (free):
# macos-15 - arm64 (M1), 3 CPU, 7 GB RAM
# macos-15-intel - Intel x64, 4 CPU, 14 GB RAM
# macOS (paid):
# macos-15-large - Intel x64, 12 CPU, 30 GB RAM
# macos-15-xlarge - arm64 (M2), 5 CPU, 14 GB RAM
# Linux (free):
# ubuntu-22.04 - x64, 4 CPU, 16 GB RAM
# ubuntu-24.04 - x64, 4 CPU, 16 GB RAM
# ubuntu-22.04-arm - arm64, 4 CPU, 16 GB RAM
# ubuntu-24.04-arm - arm64, 4 CPU, 16 GB RAM
# Linux (paid):
# ubuntu-22.04-8core - x64, 8 CPU, 32 GB RAM
# ubuntu-22.04-arm-8core - arm64, 8 CPU, 32 GB RAM
# ubuntu-22.04-16core - x64, 16 CPU, 64 GB RAM
# ubuntu-22.04-arm-16core - arm64, 16 CPU, 64 GB RAM
# Windows (free):
# windows-2022 - x64, 4 CPU, 16 GB RAM
# windows-2025 - x64, 4 CPU, 16 GB RAM
# windows-11-arm - arm64, 4 CPU, 16 GB RAM
config:
# # ===== macOS ARM64 (main target: none, ptrcomp, sandbox) =====
# - os: macos-15-xlarge # use macos-15 for free (slower)
# target: aarch64-apple-darwin
# variant: debug
# features: none
# - os: macos-15
# target: aarch64-apple-darwin
# variant: release
# features: none
# - os: macos-15-xlarge # use macos-15 for free (may timeout)
# target: aarch64-apple-darwin
# variant: debug
# features: ptrcomp
- os: macos-15-xlarge
target: aarch64-apple-darwin
variant: release
features: ptrcomp
# - os: macos-15-xlarge # use macos-15 for free (may timeout)
# target: aarch64-apple-darwin
# variant: debug
# features: sandbox
# - os: macos-15 # use macos-15-xlarge for faster builds
# target: aarch64-apple-darwin
# variant: release
# features: sandbox
# ===== Linux x86_64 (main target: none, ptrcomp, sandbox) =====
# - os: ubuntu-22.04
# target: x86_64-unknown-linux-gnu
# variant: debug
# features: none
# - os: ubuntu-22.04
# target: x86_64-unknown-linux-gnu
# variant: release
# features: none
# - os: ubuntu-22.04
# target: x86_64-unknown-linux-gnu
# variant: debug
# features: ptrcomp
# - os: ubuntu-22.04
# target: x86_64-unknown-linux-gnu
# variant: release
# features: ptrcomp
# - os: ubuntu-22.04
# target: x86_64-unknown-linux-gnu
# variant: debug
# features: sandbox
# - os: ubuntu-22.04
# target: x86_64-unknown-linux-gnu
# variant: release
# features: sandbox
# # ===== Linux ARM64 cross-compile (main target: none, ptrcomp, sandbox) =====
# - os: ubuntu-22.04
# target: aarch64-unknown-linux-gnu
# variant: debug
# features: none
# - os: ubuntu-22.04
# target: aarch64-unknown-linux-gnu
# variant: release
# features: none
# - os: ubuntu-22.04
# target: aarch64-unknown-linux-gnu
# variant: debug
# features: ptrcomp
# - os: ubuntu-22.04
# target: aarch64-unknown-linux-gnu
# variant: release
# features: ptrcomp
# - os: ubuntu-22.04
# target: aarch64-unknown-linux-gnu
# variant: debug
# features: sandbox
# - os: ubuntu-22.04
# target: aarch64-unknown-linux-gnu
# variant: release
# features: sandbox
# # ===== macOS x86_64 (secondary: none only) =====
# - os: macos-15-large # use macos-15-intel for free (may timeout)
# target: x86_64-apple-darwin
# variant: debug
# features: none
# - os: macos-15-large # use macos-15-intel for free (slower)
# target: x86_64-apple-darwin
# variant: release
# features: none
# # ===== Windows x86_64 (secondary: none only, release only) =====
# - os: windows-2022
# target: x86_64-pc-windows-msvc
# variant: release
# features: none
# # ===== Windows ARM64 (cross-compile, release only) =====
# - os: windows-2022
# target: aarch64-pc-windows-msvc
# variant: release
# features: none
env:
V8_FROM_SOURCE: true
CARGO_VARIANT_FLAG:
${{ matrix.config.variant == 'release' && '--release' || '' }}
LIB_NAME:
${{ contains(matrix.config.target, 'windows') && 'rusty_v8' ||
'librusty_v8' }}
LIB_EXT: ${{ contains(matrix.config.target, 'windows') && 'lib' || 'a' }}
RUSTFLAGS: -D warnings
steps:
- name: Configure git
run: git config --global core.symlinks true
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 10
submodules: recursive
- name: Install rust
uses: dsherret/rust-toolchain-file@v1
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Install python
uses: actions/setup-python@v5
with:
python-version: 3.11.x
architecture: x64
- name: Install Windows ARM64 target
if: matrix.config.target == 'aarch64-pc-windows-msvc'
run: rustup target add aarch64-pc-windows-msvc
- name: Install cross compilation toolchain
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
rustup target add aarch64-unknown-linux-gnu
sudo apt update
sudo apt install -yq --no-install-suggests --no-install-recommends \
binfmt-support g++-10-aarch64-linux-gnu g++-10-multilib \
gcc-10-aarch64-linux-gnu libc6-arm64-cross qemu qemu-user \
qemu-user-binfmt
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 \
/lib/ld-linux-aarch64.so.1
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc-10" >> ${GITHUB_ENV}
echo "QEMU_LD_PREFIX=/usr/aarch64-linux-gnu" >> ${GITHUB_ENV}
- name: Write git_submodule_status.txt
run: git submodule status --recursive > git_submodule_status.txt
- name: Cache
uses: actions/cache@v5
with:
path: |-
target/sccache
target/*/.*
target/*/build
target/*/deps
key:
cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-${{
matrix.config.features }}-${{ hashFiles('Cargo.lock', 'build.rs',
'git_submodule_status.txt') }}
restore-keys:
cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-${{
matrix.config.features }}-
- name: Install and start sccache
shell: pwsh
env:
SCCACHE_DIR: ${{ github.workspace }}/target/sccache
SCCACHE_CACHE_SIZE: 256M
SCCACHE_IDLE_TIMEOUT: 0
run: |
$version = "v0.8.2"
$platform =
@{ "x86_64-apple-darwin" = "x86_64-apple-darwin"
"aarch64-apple-darwin" = "aarch64-apple-darwin"
"x86_64-unknown-linux-gnu" = "x86_64-unknown-linux-musl"
"aarch64-unknown-linux-gnu" = "x86_64-unknown-linux-musl"
"x86_64-pc-windows-msvc" = "x86_64-pc-windows-msvc"
"aarch64-pc-windows-msvc" = "x86_64-pc-windows-msvc"
}['${{ matrix.config.target }}']
$basename = "sccache-$version-$platform"
$url = "https://github.com/mozilla/sccache/releases/download/$version/$basename.tar.gz"
cd ~
curl -LO $url
tar -xzvf "$basename.tar.gz"
. $basename/sccache --start-server
echo "$(pwd)/$basename" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Clang
if: startsWith(matrix.config.os, 'ubuntu')
run: |
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main" | sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-jammy-19.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo dd of=/etc/apt/trusted.gpg.d/llvm-snapshot.gpg
sudo apt-get update
sudo apt-get -qq remove 'clang-*'
sudo apt-get install lld-19 clang-19 clang-tools-19 clang-tidy-19 clang-format-19 libclang-19-dev -y
echo "LIBCLANG_PATH=/usr/lib/llvm-19/lib" >> $GITHUB_ENV
- name: Set cargo feature flags
shell: bash
run: |
if [ "${{ matrix.config.features }}" = "sandbox" ]; then
echo "CARGO_FEATURE_FLAGS=--features v8_enable_sandbox" >> $GITHUB_ENV
echo "FEATURES_SUFFIX=_sandbox" >> $GITHUB_ENV
elif [ "${{ matrix.config.features }}" = "ptrcomp" ]; then
echo "CARGO_FEATURE_FLAGS=--features v8_enable_pointer_compression" >> $GITHUB_ENV
echo "FEATURES_SUFFIX=_ptrcomp" >> $GITHUB_ENV
else
echo "CARGO_FEATURE_FLAGS=" >> $GITHUB_ENV
echo "FEATURES_SUFFIX=" >> $GITHUB_ENV
fi
- name: Install Clang (Windows cross-compile)
if: matrix.config.target == 'aarch64-pc-windows-msvc'
run: python3 tools/clang/scripts/update.py
- name: Test
if: >-
matrix.config.target != 'aarch64-unknown-linux-gnu' &&
matrix.config.target != 'aarch64-pc-windows-msvc'
env:
SCCACHE_IDLE_TIMEOUT: 0
run:
cargo nextest run --all-targets --locked --target ${{
matrix.config.target }} ${{ env.CARGO_VARIANT_FLAG }} ${{
env.CARGO_FEATURE_FLAGS }}
- name: Build (cross-compile, no tests)
if: >-
matrix.config.target == 'aarch64-unknown-linux-gnu' ||
matrix.config.target == 'aarch64-pc-windows-msvc'
env:
SCCACHE_IDLE_TIMEOUT: 0
run:
cargo build --all-targets --locked --target ${{ matrix.config.target
}} ${{ env.CARGO_VARIANT_FLAG }} ${{ env.CARGO_FEATURE_FLAGS }}
- name: Clippy
run:
cargo clippy --all-targets --locked --target ${{ matrix.config.target
}} ${{ env.CARGO_VARIANT_FLAG }} ${{ env.CARGO_FEATURE_FLAGS }} -- -D
clippy::all
- name: Prepare binary publish
run: |
gzip -9c target/${{ matrix.config.target }}/${{ matrix.config.variant }}/gn_out/obj/${{ env.LIB_NAME }}.${{ env.LIB_EXT }} > target/${{ env.LIB_NAME }}${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
ls -l target/${{ env.LIB_NAME }}${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
cp target/${{ matrix.config.target }}/${{ matrix.config.variant }}/gn_out/src_binding.rs target/src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
ls -l target/src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
- name: Binary publish
uses: softprops/[email protected]
if: >-
github.repository == 'openworkers/rusty-v8' && startsWith(github.ref,
'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
target/${{ env.LIB_NAME }}${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
target/src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
- name: Upload CI artifacts
uses: actions/upload-artifact@v4
with:
name:
src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant
}}_${{ matrix.config.target }}.rs
path:
target/src_binding${{ env.FEATURES_SUFFIX }}_${{
matrix.config.variant }}_${{ matrix.config.target }}.rs
publish:
needs: build
runs-on: ubuntu-22.04
if:
github.repository == 'openworkers/rusty-v8' && startsWith(github.ref,
'refs/tags/v')
steps:
- name: Configure git
run: git config --global core.symlinks true
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 10
submodules: false
- name: Install rust
uses: dsherret/rust-toolchain-file@v1
- name: Install python
uses: actions/setup-python@v5
with:
python-version: 3.11.x
architecture: x64
- name: Download CI artifacts
uses: actions/download-artifact@v4
with:
path: gen
pattern: src_binding_*.rs
merge-multiple: true
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -vv --locked --allow-dirty --no-verify