这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: release @turbo/repository #9865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions .github/workflows/turborepo-library-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
dry_run:
description: "Do a dry run, skipping the final publish step."
description: Do a dry run, skipping the final publish step.
type: boolean

jobs:
Expand All @@ -18,31 +18,37 @@ jobs:
matrix:
settings:
- host: macos-latest
target: "aarch64-apple-darwin"
target: aarch64-apple-darwin

- host: macos-latest
target: "x86_64-apple-darwin"
target: x86_64-apple-darwin

- host: ubuntu-latest
target: "aarch64-unknown-linux-gnu"
target: aarch64-unknown-linux-gnu
setup: |
sudo apt update
sudo apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
sudo apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross xz-utils
mkdir zig
curl --show-error --location https://ziglang.org/builds/zig-linux-x86_64-0.14.0-dev.3028+cdc9d65b0.tar.xz | tar -J -xf - -C zig --strip-components 1
export PATH=$PATH:$(pwd)/zig
echo "$(pwd)/zig" >> $GITHUB_PATH

- host: ubuntu-latest
target: "x86_64-unknown-linux-gnu"
target: x86_64-unknown-linux-gnu
container: amazon/aws-lambda-nodejs:20
install: |
microdnf install -y gcc gcc-c++ git
microdnf install -y gcc gcc-c++ git tar xz
curl https://sh.rustup.rs -sSf | bash -s -- -y
npm i -g pnpm@8.9.0
mkdir ../zig
curl --show-error --location https://ziglang.org/builds/zig-linux-x86_64-0.14.0-dev.3028+cdc9d65b0.tar.xz | tar -J -xf - -C ../zig --strip-components 1
export PATH=$PATH:$(pwd)/../zig
echo "$(pwd)/../zig" >> $GITHUB_PATH
setup: |
pnpm install

- host: ubuntu-latest
target: "x86_64-unknown-linux-musl"
target: x86_64-unknown-linux-musl
container: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-alpine
install: |
apk update && apk upgrade
Expand All @@ -56,7 +62,7 @@ jobs:
pnpm install

- host: ubuntu-latest
target: "aarch64-unknown-linux-musl"
target: aarch64-unknown-linux-musl
container: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-alpine
install: |
apk update && apk upgrade
Expand All @@ -73,10 +79,10 @@ jobs:
rust_env: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc RUSTFLAGS="-Ctarget-feature=-crt-static"

- host: windows-latest
target: "aarch64-pc-windows-msvc"
target: aarch64-pc-windows-msvc

- host: windows-latest
target: "x86_64-pc-windows-msvc"
target: x86_64-pc-windows-msvc

runs-on: ${{ matrix.settings.host }}
container:
Expand Down Expand Up @@ -109,8 +115,6 @@ jobs:
if: ${{ matrix.settings.setup }}

- name: Build native library
# For some reason PATH modifications from Setup toolchain aren't populated
# when using the nodejs-rust alpine container.
run: |
export PATH=/usr/local/cargo/bin/rustup:/root/.cargo/bin:${PATH}
cd packages/turbo-repository
Expand All @@ -123,7 +127,7 @@ jobs:
path: packages/turbo-repository/native

package:
name: "Publish to NPM"
name: Publish to NPM
runs-on: ubuntu-latest
needs: [build]
steps:
Expand Down
4 changes: 2 additions & 2 deletions packages/turbo-repository/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"bugs": "https://github.com/vercel/turborepo/issues",
"homepage": "https://turbo.build/repo",
"scripts": {
"build": "bash scripts/build.sh",
"build:release": "bash scripts/build.sh release",
"build": "bash scripts/build.sh --dts ../js/index.d.ts",
"build:release": "bash scripts/build.sh --release",
"package": "node scripts/publish.mjs",
"test": "node --import tsx --test __tests__/*.test.ts"
},
Expand Down
30 changes: 19 additions & 11 deletions packages/turbo-repository/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
#!/bin/bash

flags="\
user_provided_flags="$@"
script_provided_flags="\
--platform \
-p turborepo-napi \
--cargo-cwd ../../ \
--cargo-name turborepo_napi \
-p=turborepo-napi \
--cargo-cwd=../../ \
--cargo-name=turborepo_napi \
native \
--js false \
--js=false \
"

if [ "$1" == "release" ]; then
flags+=" --release"
else
flags+=" --dts ../js/index.d.ts"
fi
for flag in $user_provided_flags; do
if [[ $flag == --target=* ]]; then
target=${flag#*=}
rustup target add "$target"

node_modules/.bin/napi build $flags
# For we need to cross-compile some targets with Zig
# Fortunately, napi comes with a `--zig` flag
if [[ $target == x86_64-unknown-linux-gnu || $target == aarch64-unknown-linux-gnu ]]; then
script_provided_flags+=" --zig"
fi
fi
done

node_modules/.bin/napi build $script_provided_flags $user_provided_flags

# Unfortunately, when napi generates a .d.ts file, it doesn't match our formatting rules (it doesn't have semicolons).
# Since there's now way to configure this from napi itself, so we need to run prettier on it after generating it.
Expand Down
Loading