Skip to content

Commit

Permalink
chore(ci): Fix publish action (#9463)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Aug 20, 2024
1 parent 74d6478 commit ffc64f6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/publish-npm-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ jobs:
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup toolchain install $(cat ../../rust-toolchain) &&
rustup target add aarch64-unknown-linux-musl &&
RUSTFLAGS='-C target-feature=+crt-static -C link-arg=-lgcc' cargo build --manifest-path ../../bindings/swc_cli/Cargo.toml --release --features plugin --target aarch64-unknown-linux-musl &&
rm -rf target/release/.cargo-lock &&
cp ../../bindings/target/aarch64-unknown-linux-musl/release/swc . && chmod +x ./swc &&
env RUSTFLAGS='-C target-feature=-crt-static' yarn build --target=aarch64-unknown-linux-musl
if [[ ${{ inputs.package }} == "core" ]]; then
RUSTFLAGS='-C target-feature=+crt-static -C link-arg=-lgcc' cargo build --manifest-path ../../bindings/swc_cli/Cargo.toml --release --features plugin --target aarch64-unknown-linux-musl &&
rm -rf target/release/.cargo-lock &&
cp ../../bindings/target/aarch64-unknown-linux-musl/release/swc . && chmod +x ./swc &&
env RUSTFLAGS='-C target-feature=-crt-static' yarn build --target=aarch64-unknown-linux-musl
else
env RUSTFLAGS='-C target-feature=-crt-static' yarn build --target=aarch64-unknown-linux-musl
fi
- host: windows-latest
target: aarch64-pc-windows-msvc
# Disable `LTO` and increase `codegen-units` to avoid llvm `OOM` on GitHub Actions.
Expand Down Expand Up @@ -362,7 +366,7 @@ jobs:
- name: Build TypeScript
run: yarn build:ts
- name: Test bindings
run: docker run --rm -v $(pwd):/swc -w /swc node:${{ matrix.node }}-slim sh -c 'npm install -f -g [email protected] && cd ./packages/${{ inputs.package }} && env DISABLE_PLUGIN_E2E_TESTS=true yarn test'
run: docker run --rm -v $(pwd):/swc -w /swc node:${{ matrix.node }}-slim sh -c 'npm install -f -g [email protected] && env DISABLE_PLUGIN_E2E_TESTS=true yarn test:${{ inputs.package }}'
test-linux-x64-musl-binding:
name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
needs:
Expand Down Expand Up @@ -402,7 +406,7 @@ jobs:
- name: Build TypeScript
run: yarn build:ts
- name: Test bindings
run: docker run --rm -v $(pwd):/swc -w /swc node:${{ matrix.node }}-alpine sh -c 'npm install -f -g [email protected] && cd ./packages/${{ inputs.package }} && env DISABLE_PLUGIN_E2E_TESTS=true yarn test'
run: docker run --rm -v $(pwd):/swc -w /swc node:${{ matrix.node }}-alpine sh -c 'npm install -f -g [email protected] && env DISABLE_PLUGIN_E2E_TESTS=true yarn test:${{ inputs.package }}'
# test-linux-aarch64-musl-binding:
# name: Test bindings on aarch64-unknown-linux-musl - node@lts
# needs:
Expand Down Expand Up @@ -529,7 +533,6 @@ jobs:
shell: bash

- name: Move binaries
if: inputs.package == 'core'
shell: bash
working-directory: ./packages/${{ inputs.package }}
run: |
Expand Down Expand Up @@ -559,7 +562,7 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Upload CLI binaries to gh release
if: ${{ !inputs.skipPublishing }}
if: ${{ !inputs.skipPublishing && inputs.package == 'core' }}
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"build": "cd ./packages/core && yarn build",
"build:dev": "cd ./packages/core && yarn build:dev",
"build:ts": "cd ./packages/core && yarn build:ts",
"test": "cd ./packages/core && yarn test"
"test": "cd ./packages/core && yarn test",
"test:core": "cd ./packages/core && yarn test",
"test:html": "cd ./packages/html && yarn test"
},
"devDependencies": {
"@babel/compat-data": "^7.25.2",
Expand Down
8 changes: 6 additions & 2 deletions packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,20 @@
"access": "public"
},
"scripts": {
"artifacts": "napi artifacts --dist scripts/npm",
"artifacts": "napi artifacts --npm-dir scripts/npm",
"prepack": "tsc -d && napi prepublish -p scripts/npm --tag-style npm",
"prepublishOnly": "tsc -d && napi prepublish -p scripts/npm --tagstyle npm",
"build:ts": "tsc -d",
"build": "tsc -d && napi build --manifest-path ../../bindings/Cargo.toml --platform -p binding_html_node --js ./binding.js --dts ./binding.d.ts --release -o .",
"build:dev": "tsc -d && napi build --manifest-path ../../bindings/Cargo.toml --platform -p binding_html_node --js ./binding.js --dts ./binding.d.ts -o .",
"test": "echo 'done!'",
"version": "napi version -p scripts/npm"
"version": "napi version --npm-dir scripts/npm"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.43",
"typescript": "^5.1.6"
},
"dependencies": {
"@swc/counter": "^0.1.3"
}
}
22 changes: 22 additions & 0 deletions packages/html/scripts/cli_artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

mkdir -p ./artifacts_cli
# Naive substitution to napi artifacts for the cli binary.
for filename in artifacts/*/*.node
do
BINDING_NAME=${filename#*.}
BINDING_ABI=${BINDING_NAME%%.*}
CLI_BINARY_PATH=${filename%%.*}

echo "Preparing build artifacts:"
echo "Binding name $BINDING_NAME"
echo "Filename $filename"
echo "Cli binary path $CLI_BINARY_PATH"

if [ -f "$CLI_BINARY_PATH" ]; then
chmod +x $CLI_BINARY_PATH
mv -v $CLI_BINARY_PATH ./artifacts_cli/swc-$BINDING_ABI
elif [ -f "$CLI_BINARY_PATH.exe" ]; then
mv -v $CLI_BINARY_PATH.exe ./artifacts_cli/swc-$BINDING_ABI.exe
fi
done
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4649,6 +4649,7 @@ __metadata:
resolution: "@swc/html@workspace:packages/html"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.43"
"@swc/counter": "npm:^0.1.3"
typescript: "npm:^5.1.6"
languageName: unknown
linkType: soft
Expand Down

0 comments on commit ffc64f6

Please sign in to comment.