swc/.github/workflows/publish-node.yml

349 lines
8.3 KiB
YAML
Raw Normal View History

name: Publish (node)
2020-08-30 09:29:42 +03:00
on:
create:
tags:
- v*
env:
CARGO_INCREMENTAL: 0
CI: "1"
DEBUG: "napi:*"
2020-08-30 09:29:42 +03:00
jobs:
build:
strategy:
fail-fast: false
2020-08-30 09:29:42 +03:00
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: Build - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
2020-08-30 09:29:42 +03:00
with:
node-version: 14
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
2020-08-30 09:29:42 +03:00
- name: Install node dependencies
2020-09-05 11:48:22 +03:00
run: npm i
2020-08-30 09:29:42 +03:00
- name: Build
shell: bash
run: npm run build
env:
MACOSX_DEPLOYMENT_TARGET: "10.13"
2020-08-30 09:29:42 +03:00
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: swc.*.node
2020-08-30 09:29:42 +03:00
- name: Test bindings
2020-09-05 11:48:22 +03:00
run: npm test
2020-08-30 09:29:42 +03:00
build-windows-i686:
name: stable - windows-i686 - node@14
runs-on: windows-latest
env:
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 32
CARGO_PROFILE_RELEASE_LTO: 'false'
steps:
- uses: actions/checkout@v2
- name: Install node x86
run: |
choco install nodejs-lts --x86 -y --force
refreshenv
- name: Set 32bit NodeJS path
run: |
echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH
shell: bash
- name: NodeJS arch
run: node -e "console.log(process.arch)"
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
target: i686-pc-windows-msvc
- name: Install node dependencies
run: npm i
- name: Build
shell: bash
run: yarn build --target i686-pc-windows-msvc
- name: Test bindings
run: npm test
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: swc.*.node
build-linux-musl:
name: stable - linux-musl - node@10
2020-09-13 12:27:26 +03:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to registry
run: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
env:
DOCKER_REGISTRY_URL: docker.pkg.github.com
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Cache
uses: actions/cache@v2
with:
path: |
target/
key: linux-musl-publish-integration
2020-09-13 12:27:26 +03:00
- name: Pull docker image
run: |
docker pull docker.pkg.github.com/napi-rs/napi-rs/nodejs-rust:10-alpine
docker tag docker.pkg.github.com/napi-rs/napi-rs/nodejs-rust:10-alpine builder
- name: "Install dependencies"
run: npm i
2020-09-13 12:27:26 +03:00
- name: "Build"
2020-09-13 12:27:26 +03:00
run: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/swc -w /swc builder sh -c "./node_modules/.bin/napi build --platform --cargo-name node --release -c ./package.json --cargo-flags='-p node'"
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: swc.*.node
build-apple-silicon:
name: stable - aarch64-apple-darwin - node@14
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
2020-09-13 12:27:26 +03:00
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
target: aarch64-apple-darwin
- name: Cache
uses: actions/cache@v2
with:
path: |
target/
key: aarch64-apple-darwin-publish-integration
- name: Install dependencies
run: npm i
- name: Cross build aarch64
run: yarn build --target aarch64-apple-darwin
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: swc.*.node
build-linux-aarch64:
name: stable - aarch64-unknown-linux-gnu - node@14
runs-on: ubuntu-latest
steps:
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
target: aarch64-unknown-linux-gnu
- name: Cache
uses: actions/cache@v2
with:
path: |
target/
key: aarch64-linux-gnu-publish-integration
- name: Install cross compile toolchain
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
- name: Install dependencies
run: npm i
- name: Cross build aarch64
run: yarn build --target aarch64-unknown-linux-gnu
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: swc.*.node
build-linux-arm7:
name: stable - arm7-unknown-linux-gnu - node@14
runs-on: ubuntu-latest
steps:
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
target: armv7-unknown-linux-gnueabihf
- name: Cache
uses: actions/cache@v2
with:
path: |
target/
key: arm7-linux-gnu-publish-integration
- name: Install cross compile toolchain
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf -y
- name: Install dependencies
run: npm i
- name: Cross build aarch64
run: yarn build --target armv7-unknown-linux-gnueabihf
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: swc.*.node
build-android-aarch64:
name: Build - Android - aarch64
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
target: aarch64-linux-android
- name: Install node dependencies
run: npm i
- name: Build
2020-09-13 12:27:26 +03:00
shell: bash
run: |
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang"
yarn build --target aarch64-linux-android
2020-09-13 12:27:26 +03:00
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: swc.*.node
2020-08-30 09:29:42 +03:00
publish:
name: npm
runs-on: ubuntu-latest
needs:
- build
- build-windows-i686
- build-linux-musl
- build-linux-arm7
- build-linux-aarch64
- build-apple-silicon
- build-android-aarch64
2020-08-30 09:29:42 +03:00
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
2020-08-30 09:29:42 +03:00
with:
node-version: 14
2020-08-30 09:29:42 +03:00
2020-09-13 18:25:22 +03:00
- name: Set release name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
2020-09-13 18:25:22 +03:00
2020-08-30 09:29:42 +03:00
- name: Install dependencies
run: npm i
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
2020-09-05 11:48:22 +03:00
path: artifacts
2020-08-30 09:29:42 +03:00
- name: List binaries
2020-09-05 11:48:22 +03:00
run: ls -R artifacts
2020-08-30 09:29:42 +03:00
shell: bash
- name: Move binaries
shell: bash
2020-09-05 11:48:22 +03:00
run: npm run artifacts
2020-08-30 09:29:42 +03:00
- name: List npm
run: ls -R ./scripts/npm
shell: bash
- name: Publish
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
env:
2020-09-05 11:48:22 +03:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}