Commit 64430788 authored by JJ Kasper's avatar JJ Kasper

lock swc binaries version

parent c92233ba
......@@ -70,328 +70,328 @@ jobs:
key: ${{ github.sha }}-${{ github.run_number }}
# Build binaries for publishing
build-native:
defaults:
run:
shell: bash -leo pipefail {0}
strategy:
fail-fast: false
matrix:
settings:
- host:
- 'self-hosted'
- 'macos'
- 'arm64'
target: 'x86_64-apple-darwin'
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" && corepack enable
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --remote-cache-timeout 90 --summarize -- --target x86_64-apple-darwin --release
strip -x packages/next-swc/native/next-swc.*.node
- host:
- 'self-hosted'
- 'macos'
- 'arm64'
target: 'aarch64-apple-darwin'
build: |
export CC=$(xcrun -f clang);
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" && corepack enable
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --remote-cache-timeout 90 --summarize -- --target aarch64-apple-darwin
strip -x packages/next-swc/native/next-swc.*.node
- host:
- 'self-hosted'
- 'windows'
- 'x64'
build: |
corepack enable
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --remote-cache-timeout 90 --summarize -- --target x86_64-pc-windows-msvc
target: 'x86_64-pc-windows-msvc'
- host:
- 'self-hosted'
- 'windows'
- 'x64'
build: |
corepack enable
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
pnpm dlx turbo@${TURBO_VERSION} run build-native-no-plugin -vvv --remote-cache-timeout 90 --summarize -- --release --target i686-pc-windows-msvc
target: 'i686-pc-windows-msvc'
- host:
- 'self-hosted'
- 'windows'
- 'x64'
target: 'aarch64-pc-windows-msvc'
build: |
corepack enable
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
pnpm dlx turbo@${TURBO_VERSION} run build-native-no-plugin-woa-release -vvv --remote-cache-timeout 90 --summarize -- --target aarch64-pc-windows-msvc
- host:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
target: 'x86_64-unknown-linux-gnu'
# [NOTE] If you want to update / modify build steps, check these things:
# - We use docker images to pin the glibc version to link against,
# even if host target is identical to the container image (i.e host: x64-linux, image: x64-linux)
# - After build `objdump -T` prints out the glibc version next-swc is linked against,
# to ensure it did not change unexpectedly if docker image, or other dependency changed
# - zig linker with portable glibc is avoided as it has known issues with static tls + node.js + multi threaded
# environment.
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-x64
build: >-
set -e &&
apt update &&
apt install -y pkg-config xz-utils dav1d libdav1d-dev &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add x86_64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
unset CC_x86_64_unknown_linux_gnu && unset CC &&
cd packages/next-swc && npm run build-native-release -- --target x86_64-unknown-linux-gnu &&
strip native/next-swc.*.node &&
objdump -T native/next-swc.*.node | grep GLIBC_
- host:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
target: 'x86_64-unknown-linux-musl'
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-alpine
build: >-
set -e &&
apk update &&
apk add --no-cache libc6-compat pkgconfig dav1d libdav1d dav1d-dev &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add x86_64-unknown-linux-musl &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
cd packages/next-swc && npm run build-native-release -- --target x86_64-unknown-linux-musl &&
strip native/next-swc.*.node
- host:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
target: 'aarch64-unknown-linux-gnu'
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-aarch64
build: >-
set -e &&
apt update &&
apt install -y pkg-config xz-utils dav1d libdav1d-dev &&
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add aarch64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
cd packages/next-swc && npm run build-native-release -- --target aarch64-unknown-linux-gnu --features plugin,rustls-tls,tracing/release_max_level_info &&
llvm-strip -x native/next-swc.*.node &&
objdump -T native/next-swc.*.node | grep GLIBC_
- host:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
target: 'aarch64-unknown-linux-musl'
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-alpine
build: >-
set -e &&
apk update &&
apk add --no-cache libc6-compat pkgconfig dav1d libdav1d dav1d-dev &&
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add aarch64-unknown-linux-musl &&
cd packages/next-swc && npm run build-native-release -- --target aarch64-unknown-linux-musl &&
llvm-strip -x native/next-swc.*.node
name: stable - ${{ matrix.settings.target }} - node@16
runs-on: ${{ matrix.settings.host }}
timeout-minutes: 30
steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
if: ${{ matrix.settings.host == 'ubuntu-latest' }}
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
if: ${{ matrix.settings.host == 'ubuntu-latest' }}
- name: tune windows network
run: Disable-NetAdapterChecksumOffload -Name * -TcpIPv4 -UdpIPv4 -TcpIPv6 -UdpIPv6
if: ${{ matrix.settings.host == 'windows-latest' }}
- name: tune mac network
run: sudo sysctl -w net.link.generic.system.hwcksum_tx=0 && sudo sysctl -w net.link.generic.system.hwcksum_rx=0
if: ${{ matrix.settings.host == 'macos-latest' }}
# we use checkout here instead of the build cache since
# it can fail to restore in different OS'
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
with:
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true
- run: corepack enable
- name: Install Rust
uses: ./.github/actions/setup-rust
with:
targets: ${{ matrix.settings.target }}
skip-install: ${{ matrix.settings.docker }}
- name: normalize versions
run: node scripts/normalize-version-bump.js
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
- name: Cache on ${{ github.ref_name }}
uses: ijjk/rust-cache@turbo-cache-v1.0.7
with:
save-if: 'true'
cache-provider: 'turbo'
shared-key: build-${{ matrix.settings.target }}-${{ hashFiles('.cargo/config.toml') }}
# we only need custom caching for docker builds
# as they are on an older Node.js version and have
# issues with turbo caching
- name: pull build cache
if: ${{ matrix.settings.docker }}
run: npm i -g turbo@${{ env.TURBO_VERSION }} && node ./scripts/pull-turbo-cache.js ${{ matrix.settings.target }}
- name: check build exists
if: ${{ matrix.settings.docker }}
run: if [ -f packages/next-swc/native/next-swc.*.node ]; then echo "BUILD_EXISTS=yes" >> $GITHUB_OUTPUT; else echo "BUILD_EXISTS=no" >> $GITHUB_OUTPUT; fi
id: build-exists
- name: Build in docker
if: ${{ matrix.settings.docker && steps.build-exists.outputs.BUILD_EXISTS == 'no' }}
run: docker run -v "/var/run/docker.sock":"/var/run/docker.sock" -e RUST_TOOLCHAIN -e RUST_BACKTRACE -e NAPI_CLI_VERSION -e CARGO_TERM_COLOR -e CARGO_INCREMENTAL -e CARGO_PROFILE_RELEASE_LTO -e CARGO_REGISTRIES_CRATES_IO_PROTOCOL -e TURBO_API -e TURBO_TEAM -e TURBO_TOKEN -e TURBO_VERSION -e TURBO_REMOTE_ONLY -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build --entrypoint=bash ${{ matrix.settings.docker }} -c "${{ matrix.settings.build }}"
- name: cache build
if: ${{ matrix.settings.docker && steps.build-exists.outputs.BUILD_EXISTS == 'no' }}
run: pnpm dlx turbo@${TURBO_VERSION} run cache-build-native --force -- ${{ matrix.settings.target }}
- name: 'Build'
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
- name: 'check build cache status'
id: check-did-build
run: if [[ ! -z $(ls packages/next-swc/native) ]]; then echo "DID_BUILD=yup" >> $GITHUB_OUTPUT; fi
# Trying to upload metrics for the Turbopack to datadog's CI pipeline execution
- name: 'Collect turbopack build metrics'
id: check-turbopack-bytesize
if: ${{ steps.check-did-build.outputs.DID_BUILD == 'yup' }}
continue-on-error: true
run: |
mkdir -p ./turbopack-bin-size
shopt -s nullglob
for filename in packages/next-swc/native/next-swc.*.node; do
# Strip out filename to extract target triple
export FILENAME=$(basename ${filename})
export FILENAME=${FILENAME#*.}
export FILENAME=${FILENAME%.node}
export BYTESIZE=$(wc -c < $filename | xargs)
echo "Reporting $FILENAME:$BYTESIZE for Turbopack bytesize"
echo "turbopack.bytesize.$FILENAME:$BYTESIZE" > ./turbopack-bin-size/${{ matrix.settings.target }}
done
# - name: Upload turbopack bytesize artifact
# if: ${{ steps.check-did-build.outputs.DID_BUILD == 'yup' }}
# uses: actions/upload-artifact@v4
# with:
# name: turbopack-bytesize
# path: turbopack-bin-size/*
- name: Upload swc artifact
uses: actions/upload-artifact@v4
with:
name: next-swc-binaries-${{ matrix.settings.target }}
path: packages/next-swc/native/next-swc.*.node
# - name: Upload turbo summary artifact
# uses: actions/upload-artifact@v4
# with:
# name: turbo run summary
# path: .turbo/runs
build-wasm:
strategy:
matrix:
target: [web, nodejs]
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true
- run: corepack enable
- name: Install Rust
uses: ./.github/actions/setup-rust
with:
targets: wasm32-unknown-unknown
- run: npm i -g turbo@${{ env.TURBO_VERSION }}
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: normalize versions
run: node scripts/normalize-version-bump.js
- name: Build
run: pnpm dlx turbo@${TURBO_VERSION} run build-wasm -vvv --remote-cache-timeout 90 --summarize -- --target ${{ matrix.target }} --features tracing/release_max_level_info
- name: Add target to folder name
run: '[[ -d "packages/next-swc/crates/wasm/pkg" ]] && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-${{ matrix.target }} || ls packages/next-swc/crates/wasm'
# - name: Upload turbo summary artifact
# uses: actions/upload-artifact@v4
# with:
# name: pnpm dlx turbo@${TURBO_VERSION} run summary
# path: .turbo/runs
- name: Upload swc artifact
uses: actions/upload-artifact@v4
with:
name: wasm-binaries-${{ matrix.target }}
path: packages/next-swc/crates/wasm/pkg-*
# build-native:
# defaults:
# run:
# shell: bash -leo pipefail {0}
# strategy:
# fail-fast: false
# matrix:
# settings:
# - host:
# - 'self-hosted'
# - 'macos'
# - 'arm64'
# target: 'x86_64-apple-darwin'
# build: |
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" && corepack enable
# pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --remote-cache-timeout 90 --summarize -- --target x86_64-apple-darwin --release
# strip -x packages/next-swc/native/next-swc.*.node
# - host:
# - 'self-hosted'
# - 'macos'
# - 'arm64'
# target: 'aarch64-apple-darwin'
# build: |
# export CC=$(xcrun -f clang);
# export CXX=$(xcrun -f clang++);
# SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
# export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" && corepack enable
# pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --remote-cache-timeout 90 --summarize -- --target aarch64-apple-darwin
# strip -x packages/next-swc/native/next-swc.*.node
# - host:
# - 'self-hosted'
# - 'windows'
# - 'x64'
# build: |
# corepack enable
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
# pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --remote-cache-timeout 90 --summarize -- --target x86_64-pc-windows-msvc
# target: 'x86_64-pc-windows-msvc'
# - host:
# - 'self-hosted'
# - 'windows'
# - 'x64'
# build: |
# corepack enable
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
# pnpm dlx turbo@${TURBO_VERSION} run build-native-no-plugin -vvv --remote-cache-timeout 90 --summarize -- --release --target i686-pc-windows-msvc
# target: 'i686-pc-windows-msvc'
# - host:
# - 'self-hosted'
# - 'windows'
# - 'x64'
# target: 'aarch64-pc-windows-msvc'
# build: |
# corepack enable
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
# pnpm dlx turbo@${TURBO_VERSION} run build-native-no-plugin-woa-release -vvv --remote-cache-timeout 90 --summarize -- --target aarch64-pc-windows-msvc
# - host:
# - 'self-hosted'
# - 'linux'
# - 'x64'
# - 'metal'
# target: 'x86_64-unknown-linux-gnu'
# # [NOTE] If you want to update / modify build steps, check these things:
# # - We use docker images to pin the glibc version to link against,
# # even if host target is identical to the container image (i.e host: x64-linux, image: x64-linux)
# # - After build `objdump -T` prints out the glibc version next-swc is linked against,
# # to ensure it did not change unexpectedly if docker image, or other dependency changed
# # - zig linker with portable glibc is avoided as it has known issues with static tls + node.js + multi threaded
# # environment.
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-x64
# build: >-
# set -e &&
# apt update &&
# apt install -y pkg-config xz-utils dav1d libdav1d-dev &&
# rustup toolchain install "${RUST_TOOLCHAIN}" &&
# rustup default "${RUST_TOOLCHAIN}" &&
# rustup target add x86_64-unknown-linux-gnu &&
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
# unset CC_x86_64_unknown_linux_gnu && unset CC &&
# cd packages/next-swc && npm run build-native-release -- --target x86_64-unknown-linux-gnu &&
# strip native/next-swc.*.node &&
# objdump -T native/next-swc.*.node | grep GLIBC_
# - host:
# - 'self-hosted'
# - 'linux'
# - 'x64'
# - 'metal'
# target: 'x86_64-unknown-linux-musl'
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-alpine
# build: >-
# set -e &&
# apk update &&
# apk add --no-cache libc6-compat pkgconfig dav1d libdav1d dav1d-dev &&
# rustup toolchain install "${RUST_TOOLCHAIN}" &&
# rustup default "${RUST_TOOLCHAIN}" &&
# rustup target add x86_64-unknown-linux-musl &&
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
# cd packages/next-swc && npm run build-native-release -- --target x86_64-unknown-linux-musl &&
# strip native/next-swc.*.node
# - host:
# - 'self-hosted'
# - 'linux'
# - 'x64'
# - 'metal'
# target: 'aarch64-unknown-linux-gnu'
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-aarch64
# build: >-
# set -e &&
# apt update &&
# apt install -y pkg-config xz-utils dav1d libdav1d-dev &&
# export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
# rustup toolchain install "${RUST_TOOLCHAIN}" &&
# rustup default "${RUST_TOOLCHAIN}" &&
# rustup target add aarch64-unknown-linux-gnu &&
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
# export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
# cd packages/next-swc && npm run build-native-release -- --target aarch64-unknown-linux-gnu --features plugin,rustls-tls,tracing/release_max_level_info &&
# llvm-strip -x native/next-swc.*.node &&
# objdump -T native/next-swc.*.node | grep GLIBC_
# - host:
# - 'self-hosted'
# - 'linux'
# - 'x64'
# - 'metal'
# target: 'aarch64-unknown-linux-musl'
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-alpine
# build: >-
# set -e &&
# apk update &&
# apk add --no-cache libc6-compat pkgconfig dav1d libdav1d dav1d-dev &&
# export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
# npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
# rustup toolchain install "${RUST_TOOLCHAIN}" &&
# rustup default "${RUST_TOOLCHAIN}" &&
# rustup target add aarch64-unknown-linux-musl &&
# cd packages/next-swc && npm run build-native-release -- --target aarch64-unknown-linux-musl &&
# llvm-strip -x native/next-swc.*.node
# name: stable - ${{ matrix.settings.target }} - node@16
# runs-on: ${{ matrix.settings.host }}
# timeout-minutes: 30
# steps:
# # https://github.com/actions/virtual-environments/issues/1187
# - name: tune linux network
# run: sudo ethtool -K eth0 tx off rx off
# if: ${{ matrix.settings.host == 'ubuntu-latest' }}
# - name: tune linux network
# run: sudo ethtool -K eth0 tx off rx off
# if: ${{ matrix.settings.host == 'ubuntu-latest' }}
# - name: tune windows network
# run: Disable-NetAdapterChecksumOffload -Name * -TcpIPv4 -UdpIPv4 -TcpIPv6 -UdpIPv6
# if: ${{ matrix.settings.host == 'windows-latest' }}
# - name: tune mac network
# run: sudo sysctl -w net.link.generic.system.hwcksum_tx=0 && sudo sysctl -w net.link.generic.system.hwcksum_rx=0
# if: ${{ matrix.settings.host == 'macos-latest' }}
# # we use checkout here instead of the build cache since
# # it can fail to restore in different OS'
# - uses: actions/checkout@v4
# - name: Setup node
# uses: actions/setup-node@v4
# if: ${{ !matrix.settings.docker }}
# with:
# node-version: ${{ env.NODE_LTS_VERSION }}
# check-latest: true
# - run: corepack enable
# - name: Install Rust
# uses: ./.github/actions/setup-rust
# with:
# targets: ${{ matrix.settings.target }}
# skip-install: ${{ matrix.settings.docker }}
# - name: normalize versions
# run: node scripts/normalize-version-bump.js
# - name: Setup toolchain
# run: ${{ matrix.settings.setup }}
# if: ${{ matrix.settings.setup }}
# - name: Cache on ${{ github.ref_name }}
# uses: ijjk/rust-cache@turbo-cache-v1.0.7
# with:
# save-if: 'true'
# cache-provider: 'turbo'
# shared-key: build-${{ matrix.settings.target }}-${{ hashFiles('.cargo/config.toml') }}
# # we only need custom caching for docker builds
# # as they are on an older Node.js version and have
# # issues with turbo caching
# - name: pull build cache
# if: ${{ matrix.settings.docker }}
# run: npm i -g turbo@${{ env.TURBO_VERSION }} && node ./scripts/pull-turbo-cache.js ${{ matrix.settings.target }}
# - name: check build exists
# if: ${{ matrix.settings.docker }}
# run: if [ -f packages/next-swc/native/next-swc.*.node ]; then echo "BUILD_EXISTS=yes" >> $GITHUB_OUTPUT; else echo "BUILD_EXISTS=no" >> $GITHUB_OUTPUT; fi
# id: build-exists
# - name: Build in docker
# if: ${{ matrix.settings.docker && steps.build-exists.outputs.BUILD_EXISTS == 'no' }}
# run: docker run -v "/var/run/docker.sock":"/var/run/docker.sock" -e RUST_TOOLCHAIN -e RUST_BACKTRACE -e NAPI_CLI_VERSION -e CARGO_TERM_COLOR -e CARGO_INCREMENTAL -e CARGO_PROFILE_RELEASE_LTO -e CARGO_REGISTRIES_CRATES_IO_PROTOCOL -e TURBO_API -e TURBO_TEAM -e TURBO_TOKEN -e TURBO_VERSION -e TURBO_REMOTE_ONLY -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build --entrypoint=bash ${{ matrix.settings.docker }} -c "${{ matrix.settings.build }}"
# - name: cache build
# if: ${{ matrix.settings.docker && steps.build-exists.outputs.BUILD_EXISTS == 'no' }}
# run: pnpm dlx turbo@${TURBO_VERSION} run cache-build-native --force -- ${{ matrix.settings.target }}
# - name: 'Build'
# run: ${{ matrix.settings.build }}
# if: ${{ !matrix.settings.docker }}
# - name: 'check build cache status'
# id: check-did-build
# run: if [[ ! -z $(ls packages/next-swc/native) ]]; then echo "DID_BUILD=yup" >> $GITHUB_OUTPUT; fi
# # Trying to upload metrics for the Turbopack to datadog's CI pipeline execution
# - name: 'Collect turbopack build metrics'
# id: check-turbopack-bytesize
# if: ${{ steps.check-did-build.outputs.DID_BUILD == 'yup' }}
# continue-on-error: true
# run: |
# mkdir -p ./turbopack-bin-size
# shopt -s nullglob
# for filename in packages/next-swc/native/next-swc.*.node; do
# # Strip out filename to extract target triple
# export FILENAME=$(basename ${filename})
# export FILENAME=${FILENAME#*.}
# export FILENAME=${FILENAME%.node}
# export BYTESIZE=$(wc -c < $filename | xargs)
# echo "Reporting $FILENAME:$BYTESIZE for Turbopack bytesize"
# echo "turbopack.bytesize.$FILENAME:$BYTESIZE" > ./turbopack-bin-size/${{ matrix.settings.target }}
# done
# # - name: Upload turbopack bytesize artifact
# # if: ${{ steps.check-did-build.outputs.DID_BUILD == 'yup' }}
# # uses: actions/upload-artifact@v4
# # with:
# # name: turbopack-bytesize
# # path: turbopack-bin-size/*
# - name: Upload swc artifact
# uses: actions/upload-artifact@v4
# with:
# name: next-swc-binaries-${{ matrix.settings.target }}
# path: packages/next-swc/native/next-swc.*.node
# # - name: Upload turbo summary artifact
# # uses: actions/upload-artifact@v4
# # with:
# # name: turbo run summary
# # path: .turbo/runs
# build-wasm:
# strategy:
# matrix:
# target: [web, nodejs]
# runs-on:
# - 'self-hosted'
# - 'linux'
# - 'x64'
# - 'metal'
# steps:
# - uses: actions/checkout@v4
# - name: Setup node
# uses: actions/setup-node@v4
# with:
# node-version: ${{ env.NODE_LTS_VERSION }}
# check-latest: true
# - run: corepack enable
# - name: Install Rust
# uses: ./.github/actions/setup-rust
# with:
# targets: wasm32-unknown-unknown
# - run: npm i -g turbo@${{ env.TURBO_VERSION }}
# - name: Install wasm-pack
# run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# - name: normalize versions
# run: node scripts/normalize-version-bump.js
# - name: Build
# run: pnpm dlx turbo@${TURBO_VERSION} run build-wasm -vvv --remote-cache-timeout 90 --summarize -- --target ${{ matrix.target }} --features tracing/release_max_level_info
# - name: Add target to folder name
# run: '[[ -d "packages/next-swc/crates/wasm/pkg" ]] && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-${{ matrix.target }} || ls packages/next-swc/crates/wasm'
# # - name: Upload turbo summary artifact
# # uses: actions/upload-artifact@v4
# # with:
# # name: pnpm dlx turbo@${TURBO_VERSION} run summary
# # path: .turbo/runs
# - name: Upload swc artifact
# uses: actions/upload-artifact@v4
# with:
# name: wasm-binaries-${{ matrix.target }}
# path: packages/next-swc/crates/wasm/pkg-*
publishRelease:
if: ${{ needs.build.outputs.isRelease == 'true' }}
......@@ -399,8 +399,8 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
- build-wasm
- build-native
# - build-wasm
# - build-native
permissions:
contents: write
id-token: write
......@@ -425,17 +425,17 @@ jobs:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}
- uses: actions/download-artifact@v4
with:
pattern: next-swc-binaries-*
merge-multiple: true
path: packages/next-swc/native
# - uses: actions/download-artifact@v4
# with:
# pattern: next-swc-binaries-*
# merge-multiple: true
# path: packages/next-swc/native
- uses: actions/download-artifact@v4
with:
pattern: wasm-binaries-*
merge-multiple: true
path: packages/next-swc/crates/wasm
# - uses: actions/download-artifact@v4
# with:
# pattern: wasm-binaries-*
# merge-multiple: true
# path: packages/next-swc/crates/wasm
- run: npm i -g npm@9.6.7 # need latest version for provenance (pinning to avoid bugs)
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
......@@ -465,51 +465,51 @@ jobs:
VERCEL_API_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
DEPLOY_ENVIRONMENT: production
releaseStats:
name: Release Stats
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
timeout-minutes: 25
needs: [publishRelease]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 25
- uses: actions/download-artifact@v4
with:
name: next-swc-binaries-*
path: packages/next-swc/native
- run: cp -r packages/next-swc/native .github/actions/next-stats-action/native
- run: ./scripts/release-stats.sh
- uses: ./.github/actions/next-stats-action
env:
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
NEXT_SKIP_NATIVE_POSTINSTALL: 1
upload_turbopack_bytesize:
name: Upload Turbopack Bytesize trace to Datadog
runs-on: ubuntu-latest
needs: [build-native]
env:
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
steps:
- name: Collect bytesize traces
uses: actions/download-artifact@v4
with:
name: turbopack-bytesize
path: turbopack-bin-size
- name: Upload to Datadog
run: |
ls -al turbopack-bin-size
npm install -g @datadog/datadog-ci@2.14.0 @aws-sdk/property-provider@3
for filename in turbopack-bin-size/*; do
export BYTESIZE+=" --metrics $(cat $filename)"
done
echo "Reporting $BYTESIZE"
datadog-ci metric --no-fail --level pipeline $BYTESIZE
# releaseStats:
# name: Release Stats
# runs-on:
# - 'self-hosted'
# - 'linux'
# - 'x64'
# - 'metal'
# timeout-minutes: 25
# needs: [publishRelease]
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 25
# - uses: actions/download-artifact@v4
# with:
# name: next-swc-binaries-*
# path: packages/next-swc/native
# - run: cp -r packages/next-swc/native .github/actions/next-stats-action/native
# - run: ./scripts/release-stats.sh
# - uses: ./.github/actions/next-stats-action
# env:
# PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
# NEXT_SKIP_NATIVE_POSTINSTALL: 1
# upload_turbopack_bytesize:
# name: Upload Turbopack Bytesize trace to Datadog
# runs-on: ubuntu-latest
# needs: [build-native]
# env:
# DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
# steps:
# - name: Collect bytesize traces
# uses: actions/download-artifact@v4
# with:
# name: turbopack-bytesize
# path: turbopack-bin-size
# - name: Upload to Datadog
# run: |
# ls -al turbopack-bin-size
# npm install -g @datadog/datadog-ci@2.14.0 @aws-sdk/property-provider@3
# for filename in turbopack-bin-size/*; do
# export BYTESIZE+=" --metrics $(cat $filename)"
# done
# echo "Reporting $BYTESIZE"
# datadog-ci metric --no-fail --level pipeline $BYTESIZE
......@@ -177,7 +177,7 @@ jobs:
- run: pnpm playwright install chromium
if: ${{ inputs.skipInstallBuild != 'yes' }}
- run: pnpm turbo run get-test-timings -- --build ${{ github.sha }}
- run: pnpm dlx turbo@${TURBO_VERSION} run get-test-timings -- --build ${{ github.sha }}
- run: /bin/bash -c "${{ inputs.afterBuild }}"
if: ${{(inputs.skipForDocsOnly != 'yes' || steps.docs-change.outputs.DOCS_CHANGE == 'nope') && (inputs.skipForRelease != 'yes' || steps.is-release.outputs.IS_RELEASE == 'nope')}}
......
......@@ -100,7 +100,8 @@ const __INTERNAL_CUSTOM_TURBOPACK_BINDINGS =
function checkVersionMismatch(pkgData: any) {
const version = pkgData.version
if (version && version !== nextVersion) {
// swc version is locked to 13.5.9 so don't warn for that case
if (version && version !== nextVersion && version !== '13.5.9') {
Log.warn(
`Mismatching @next/swc version, detected: ${version} while Next.js is on ${nextVersion}. Please ensure these match`
)
......
#!/usr/bin/env node
const path = require('path')
const execa = require('execa')
const { copy } = require('fs-extra')
const { Sema } = require('async-sema')
// const execa = require('execa')
// const { copy } = require('fs-extra')
// const { Sema } = require('async-sema')
const { readFile, readdir, writeFile } = require('fs/promises')
const cwd = process.cwd()
;(async function () {
try {
const publishSema = new Sema(2)
// const publishSema = new Sema(2)
let version = JSON.parse(
await readFile(path.join(cwd, 'lerna.json'))
).version
// let version = JSON.parse(
// await readFile(path.join(cwd, 'lerna.json'))
// ).version
// Copy binaries to package folders, update version, and publish
let nativePackagesDir = path.join(cwd, 'packages/next-swc/crates/napi/npm')
......@@ -22,122 +22,125 @@ const cwd = process.cwd()
(name) => !name.startsWith('.')
)
await Promise.all(
platforms.map(async (platform) => {
await publishSema.acquire()
// await Promise.all(
// platforms.map(async (platform) => {
// await publishSema.acquire()
try {
let binaryName = `next-swc.${platform}.node`
await copy(
path.join(cwd, 'packages/next-swc/native', binaryName),
path.join(nativePackagesDir, platform, binaryName)
)
let pkg = JSON.parse(
await readFile(
path.join(nativePackagesDir, platform, 'package.json')
)
)
pkg.version = version
await writeFile(
path.join(nativePackagesDir, platform, 'package.json'),
JSON.stringify(pkg, null, 2)
)
await execa(
`npm`,
[
`publish`,
`${path.join(nativePackagesDir, platform)}`,
`--access`,
`public`,
...(version.includes('canary')
? ['--tag', 'canary']
: ['--tag', 'next-13']),
],
{ stdio: 'inherit' }
)
} catch (err) {
// don't block publishing other versions on single platform error
console.error(`Failed to publish`, platform, err)
// try {
// let binaryName = `next-swc.${platform}.node`
// await copy(
// path.join(cwd, 'packages/next-swc/native', binaryName),
// path.join(nativePackagesDir, platform, binaryName)
// )
// let pkg = JSON.parse(
// await readFile(
// path.join(nativePackagesDir, platform, 'package.json')
// )
// )
// pkg.version = version
// await writeFile(
// path.join(nativePackagesDir, platform, 'package.json'),
// JSON.stringify(pkg, null, 2)
// )
// await execa(
// `npm`,
// [
// `publish`,
// `${path.join(nativePackagesDir, platform)}`,
// `--access`,
// `public`,
// ...(version.includes('canary')
// ? ['--tag', 'canary']
// : ['--tag', 'next-13']),
// ],
// { stdio: 'inherit' }
// )
// } catch (err) {
// // don't block publishing other versions on single platform error
// console.error(`Failed to publish`, platform, err)
if (
err.message &&
err.message.includes(
'You cannot publish over the previously published versions'
)
) {
console.error('Ignoring already published error', platform, err)
} else {
// throw err
}
} finally {
publishSema.release()
}
})
)
// if (
// err.message &&
// err.message.includes(
// 'You cannot publish over the previously published versions'
// )
// ) {
// console.error('Ignoring already published error', platform, err)
// } else {
// // throw err
// }
// } finally {
// publishSema.release()
// }
// })
// )
// Update name/version of wasm packages and publish
const pkgDirectory = 'packages/next-swc/crates/wasm'
let wasmDir = path.join(cwd, pkgDirectory)
// const pkgDirectory = 'packages/next-swc/crates/wasm'
// let wasmDir = path.join(cwd, pkgDirectory)
await Promise.all(
['web', 'nodejs'].map(async (wasmTarget) => {
await publishSema.acquire()
// await Promise.all(
// ['web', 'nodejs'].map(async (wasmTarget) => {
// await publishSema.acquire()
let wasmPkg = JSON.parse(
await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
)
wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
wasmPkg.version = version
wasmPkg.repository = {
type: 'git',
url: 'https://github.com/vercel/next.js',
directory: pkgDirectory,
}
// let wasmPkg = JSON.parse(
// await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
// )
// wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
// wasmPkg.version = version
// wasmPkg.repository = {
// type: 'git',
// url: 'https://github.com/vercel/next.js',
// directory: pkgDirectory,
// }
await writeFile(
path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
JSON.stringify(wasmPkg, null, 2)
)
// await writeFile(
// path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
// JSON.stringify(wasmPkg, null, 2)
// )
try {
await execa(
`npm`,
[
'publish',
`${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
'--access',
'public',
...(version.includes('canary') ? ['--tag', 'canary'] : []),
],
{ stdio: 'inherit' }
)
} catch (err) {
// don't block publishing other versions on single platform error
console.error(`Failed to publish`, wasmTarget, err)
// try {
// await execa(
// `npm`,
// [
// 'publish',
// `${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
// '--access',
// 'public',
// ...(version.includes('canary') ? ['--tag', 'canary'] : []),
// ],
// { stdio: 'inherit' }
// )
// } catch (err) {
// // don't block publishing other versions on single platform error
// console.error(`Failed to publish`, wasmTarget, err)
if (
err.message &&
err.message.includes(
'You cannot publish over the previously published versions'
)
) {
console.error('Ignoring already published error', wasmTarget)
} else {
// throw err
}
} finally {
publishSema.release()
}
})
)
// if (
// err.message &&
// err.message.includes(
// 'You cannot publish over the previously published versions'
// )
// ) {
// console.error('Ignoring already published error', wasmTarget)
// } else {
// // throw err
// }
// } finally {
// publishSema.release()
// }
// })
// )
// Update optional dependencies versions
let nextPkg = JSON.parse(
await readFile(path.join(cwd, 'packages/next/package.json'))
)
// we lock the version to last built swc binaries for
// last successfully built binaries
// https://github.com/vercel/next.js/pull/77477#issuecomment-2752725970
for (let platform of platforms) {
let optionalDependencies = nextPkg.optionalDependencies || {}
optionalDependencies['@next/swc-' + platform] = version
optionalDependencies['@next/swc-' + platform] = '13.5.9'
nextPkg.optionalDependencies = optionalDependencies
}
await writeFile(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment