diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fca477c08..79007ded2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v6 - name: Use Node.js ${{ env.NODE_VERSION }} uses: actions/setup-node@v6 diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 3b2cf8f1b..3336cfced 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -56,7 +56,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v6 - run: | git config --global user.name "github-actions[bot]" diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 2d057f5a8..474b59956 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -2,6 +2,12 @@ name: Prepare Release on: workflow_dispatch: + inputs: + dry_run: + description: Skip creating the draft GitHub release + required: false + default: true + type: boolean push: tags: - 'v*' @@ -48,38 +54,30 @@ jobs: - os: ubuntu-latest target: x86_64-unknown-linux-gnu strip: strip - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian + build-flags: --use-napi-cross - os: ubuntu-latest target: aarch64-unknown-linux-gnu - strip: llvm-strip - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 + strip: aarch64-linux-gnu-strip + build-flags: --use-napi-cross - os: ubuntu-latest target: armv7-unknown-linux-gnueabihf - strip: llvm-strip - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-zig + strip: arm-linux-gnueabihf-strip + build-flags: --use-napi-cross - os: ubuntu-latest target: aarch64-unknown-linux-musl - strip: aarch64-linux-musl-strip - download: true - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + strip-zig: true + build-flags: -x - os: ubuntu-latest target: x86_64-unknown-linux-musl strip: strip - download: true - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + build-flags: -x name: Build ${{ matrix.target }} (oxide) runs-on: ${{ matrix.os }} - container: ${{ matrix.container }} timeout-minutes: 15 steps: - uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v6 with: version: ${{ env.PNPM_VERSION }} @@ -95,6 +93,12 @@ jobs: sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y + - name: Install binutils-aarch64-linux-gnu + if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} + run: | + sudo apt-get update + sudo apt-get install binutils-aarch64-linux-gnu -y + # Cargo already skips downloading dependencies if they already exist - name: Cache cargo uses: actions/cache@v5 @@ -104,6 +108,8 @@ jobs: ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ + ~/.napi-rs + .cargo-cache target/ key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} @@ -123,15 +129,18 @@ jobs: ./crates/node/wasi-worker.mjs key: ${{ runner.os }}-${{ matrix.target }}-oxide-${{ hashFiles('./crates/**/*') }} - - name: Install Node.JS - uses: actions/setup-node@v6 + - uses: mlugg/setup-zig@v2 + if: ${{ contains(matrix.target, 'musl') }} with: - node-version: ${{ env.NODE_VERSION }} + version: 0.14.1 - - name: Install Rust (Stable) - if: ${{ matrix.download }} - run: | - rustup default stable + - name: Install cargo-zigbuild + uses: taiki-e/install-action@v2 + if: ${{ contains(matrix.target, 'musl') }} + env: + GITHUB_TOKEN: ${{ github.token }} + with: + tool: cargo-zigbuild - name: Setup rust target run: rustup target add ${{ matrix.target }} @@ -140,14 +149,26 @@ jobs: run: pnpm install --ignore-scripts --filter=!./playgrounds/* - name: Build release - run: pnpm run --filter ${{ env.OXIDE_LOCATION }} build:platform --target=${{ matrix.target }} + run: pnpm run --filter ${{ env.OXIDE_LOCATION }} build:platform --target=${{ matrix.target }} ${{ matrix.build-flags }} env: RUST_TARGET: ${{ matrix.target }} JEMALLOC_SYS_WITH_LG_PAGE: ${{ matrix.page-size }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 - if: ${{ matrix.strip }} - run: ${{ matrix.strip }} ${{ env.OXIDE_LOCATION }}/*.node + if: ${{ matrix.strip || matrix.strip-zig }} + env: + STRIP_COMMAND: ${{ matrix.strip }} + STRIP_ZIG: ${{ matrix.strip-zig }} + run: | + if [ "$STRIP_ZIG" = "true" ]; then + for file in ${{ env.OXIDE_LOCATION }}/*.node; do + zig objcopy --strip-all "$file" "$file.stripped" + mv "$file.stripped" "$file" + done + exit 0 + fi + + eval "$STRIP_COMMAND ${{ env.OXIDE_LOCATION }}/*.node" - name: Upload artifacts uses: actions/upload-artifact@v6 @@ -225,7 +246,7 @@ jobs: run: | echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v6 with: version: ${{ env.PNPM_VERSION }} @@ -322,6 +343,7 @@ jobs: path: dist/*.tgz - name: Prepare GitHub Release + if: ${{ !inputs.dry_run }} uses: softprops/action-gh-release@v2 with: draft: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e2accd55..71c934220 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,38 +58,30 @@ jobs: - os: ubuntu-latest target: x86_64-unknown-linux-gnu strip: strip - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian + build-flags: --use-napi-cross - os: ubuntu-latest target: aarch64-unknown-linux-gnu - strip: llvm-strip - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 + strip: aarch64-linux-gnu-strip + build-flags: --use-napi-cross - os: ubuntu-latest target: armv7-unknown-linux-gnueabihf - strip: llvm-strip - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-zig + strip: arm-linux-gnueabihf-strip + build-flags: --use-napi-cross - os: ubuntu-latest target: aarch64-unknown-linux-musl - strip: aarch64-linux-musl-strip - download: true - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + strip-zig: true + build-flags: -x - os: ubuntu-latest target: x86_64-unknown-linux-musl strip: strip - download: true - container: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + build-flags: -x name: Build ${{ matrix.target }} (oxide) runs-on: ${{ matrix.os }} - container: ${{ matrix.container }} timeout-minutes: 15 steps: - uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v6 with: version: ${{ env.PNPM_VERSION }} @@ -105,6 +97,12 @@ jobs: sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y + - name: Install binutils-aarch64-linux-gnu + if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} + run: | + sudo apt-get update + sudo apt-get install binutils-aarch64-linux-gnu -y + # Cargo already skips downloading dependencies if they already exist - name: Cache cargo uses: actions/cache@v5 @@ -114,6 +112,8 @@ jobs: ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ + ~/.napi-rs + .cargo-cache target/ key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} @@ -133,15 +133,18 @@ jobs: ./crates/node/wasi-worker.mjs key: ${{ runner.os }}-${{ matrix.target }}-oxide-${{ hashFiles('./crates/**/*') }} - - name: Install Node.JS - uses: actions/setup-node@v6 + - uses: mlugg/setup-zig@v2 + if: ${{ contains(matrix.target, 'musl') }} with: - node-version: ${{ env.NODE_VERSION }} + version: 0.14.1 - - name: Install Rust (Stable) - if: ${{ matrix.download }} - run: | - rustup default stable + - name: Install cargo-zigbuild + uses: taiki-e/install-action@v2 + if: ${{ contains(matrix.target, 'musl') }} + env: + GITHUB_TOKEN: ${{ github.token }} + with: + tool: cargo-zigbuild - name: Setup rust target run: rustup target add ${{ matrix.target }} @@ -150,14 +153,26 @@ jobs: run: pnpm install --ignore-scripts --filter=!./playgrounds/* - name: Build release - run: pnpm run --filter ${{ env.OXIDE_LOCATION }} build:platform --target=${{ matrix.target }} + run: pnpm run --filter ${{ env.OXIDE_LOCATION }} build:platform --target=${{ matrix.target }} ${{ matrix.build-flags }} env: RUST_TARGET: ${{ matrix.target }} JEMALLOC_SYS_WITH_LG_PAGE: ${{ matrix.page-size }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 - if: ${{ matrix.strip }} - run: ${{ matrix.strip }} ${{ env.OXIDE_LOCATION }}/*.node + if: ${{ matrix.strip || matrix.strip-zig }} + env: + STRIP_COMMAND: ${{ matrix.strip }} + STRIP_ZIG: ${{ matrix.strip-zig }} + run: | + if [ "$STRIP_ZIG" = "true" ]; then + for file in ${{ env.OXIDE_LOCATION }}/*.node; do + zig objcopy --strip-all "$file" "$file.stripped" + mv "$file.stripped" "$file" + done + exit 0 + fi + + eval "$STRIP_COMMAND ${{ env.OXIDE_LOCATION }}/*.node" - name: Upload artifacts uses: actions/upload-artifact@v6 @@ -228,7 +243,7 @@ jobs: with: fetch-depth: 20 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v6 with: version: ${{ env.PNPM_VERSION }}