name: Publish (node) on: push: tags: - v* env: CARGO_INCREMENTAL: 0 CI: "1" DEBUG: "napi:*" jobs: build: if: ${{ startsWith(github.ref, 'refs/tags/v') }} strategy: fail-fast: false matrix: os: [ubuntu-18.04, 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 with: node-version: 14 - name: Install Rust uses: actions-rs/toolchain@v1 with: profile: minimal override: true - name: Install node dependencies run: npm i - name: Build shell: bash run: npm run build env: MACOSX_DEPLOYMENT_TARGET: "10.13" - name: Strip (linux) shell: bash if: matrix.os == 'ubuntu-18.04' run: strip swc.*.node - name: Strip (mac os x) shell: bash if: matrix.os == 'macos-latest' run: strip -x swc.*.node - name: Upload artifact uses: actions/upload-artifact@v2 with: name: bindings path: swc.*.node - name: Test bindings run: npm test - name: Test in lts docker if: matrix.os == 'ubuntu-18.04' run: docker run --rm -v $(pwd):/swc -w /swc node:lts-slim sh -c "yarn test" build-windows-i686: if: ${{ startsWith(github.ref, 'refs/tags/v') }} 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 Node.js path run: | echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH shell: bash - name: Node.js 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-windows-aarch64: if: ${{ startsWith(github.ref, 'refs/tags/v') }} name: stable - windows-aarch64 - node@14 runs-on: windows-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-pc-windows-msvc - name: Install node dependencies run: npm i - name: Build shell: bash run: yarn build --target aarch64-pc-windows-msvc - name: Upload artifact uses: actions/upload-artifact@v2 with: name: bindings path: swc.*.node build-linux-musl: if: ${{ startsWith(github.ref, 'refs/tags/v') }} name: stable - linux-musl - node@lts 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: ghcr.io DOCKER_USERNAME: ${{ github.actor }} DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - name: Cache uses: actions/cache@v2 with: path: | target/ key: linux-musl-publish-integration - name: Pull docker image run: | docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder - name: "Install dependencies" run: npm i - name: "Build" run: | docker run --rm -v $(pwd):/swc -w /swc builder sh -c "npm run build" - name: Run tests run: | docker pull node:lts-alpine docker run --rm -v $(pwd):/swc -w /swc node:lts-alpine sh -c "npm i && npm test" - name: Upload artifact uses: actions/upload-artifact@v2 with: name: bindings path: swc.*.node build-apple-silicon: if: ${{ startsWith(github.ref, 'refs/tags/v') }} name: stable - aarch64-apple-darwin - node@14 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-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: | sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; export CC=$(xcrun -f clang); export CXX=$(xcrun -f clang++); SYSROOT=$(xcrun --sdk macosx --show-sdk-path); export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; yarn build --target aarch64-apple-darwin - name: Upload artifact uses: actions/upload-artifact@v2 with: name: bindings path: swc.*.node build-linux-aarch64: if: ${{ startsWith(github.ref, 'refs/tags/v') }} name: stable - aarch64-unknown-linux-gnu - node@14 runs-on: ubuntu-18.04 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: Run tests uses: docker://multiarch/ubuntu-core:arm64-focal with: args: > sh -c " apt-get update && \ apt-get install -y ca-certificates gnupg2 curl && \ curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ apt-get install -y nodejs && \ npm i && \ npm test " - name: Upload artifact uses: actions/upload-artifact@v2 with: name: bindings path: swc.*.node build-linux-aarch64-musl: if: ${{ startsWith(github.ref, 'refs/tags/v') }} name: stable - aarch64-unknown-linux-musl - node@14 runs-on: ubuntu-18.04 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-musl - name: Cache uses: actions/cache@v2 with: path: | target/ key: aarch64-linux-musl-publish-integration - name: Install cross compile toolchain run: | sudo apt-get update sudo apt-get install gcc-aarch64-linux-gnu -y - name: Install dependencies run: npm i - name: Cross build aarch64 run: yarn build --target aarch64-unknown-linux-musl - name: Run tests uses: docker://multiarch/alpine:aarch64-latest-stable with: args: > sh -c "sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories && \ apk add nodejs npm && \ npm i && \ npm test - name: Upload artifact uses: actions/upload-artifact@v2 with: name: bindings path: swc.*.node build-linux-arm7: if: ${{ startsWith(github.ref, 'refs/tags/v') }} name: stable - arm7-unknown-linux-gnu - node@14 runs-on: ubuntu-18.04 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: if: ${{ startsWith(github.ref, 'refs/tags/v') }} 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 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 - name: Upload artifact uses: actions/upload-artifact@v2 with: name: bindings path: swc.*.node build-freebsd: if: ${{ startsWith(github.ref, 'refs/tags/v') }} runs-on: macos-latest name: Build FreeBSD steps: - uses: actions/checkout@v2 - name: Build id: build uses: vmactions/freebsd-vm@v0.1.4 env: DEBUG: "napi:*" RUSTUP_HOME: /usr/local/rustup CARGO_HOME: /usr/local/cargo RUSTUP_IO_THREADS: 1 with: envs: "DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS" usesh: true mem: 3000 prepare: | pkg install -y curl node yarn npm curl https://sh.rustup.rs -sSf --output rustup.sh sh rustup.sh -y --profile minimal --default-toolchain stable export PATH="/usr/local/cargo/bin:$PATH" echo "~~~~ rustc --version ~~~~" rustc --version echo "~~~~ node -v ~~~~" node -v echo "~~~~ yarn --version ~~~~" yarn --version run: | export PATH="/usr/local/cargo/bin:$PATH" pwd ls -lah whoami env freebsd-version npm i cargo build --release -p node yarn build npm test rm -rf node_modules rm -rf target - name: "List files" run: ls -la - name: Upload artifact uses: actions/upload-artifact@v2 with: name: bindings path: swc.*.node publish: if: ${{ startsWith(github.ref, 'refs/tags/v') }} name: npm runs-on: ubuntu-latest needs: - build - build-windows-i686 - build-windows-aarch64 - build-linux-musl - build-linux-arm7 - build-linux-aarch64 - build-apple-silicon - build-android-aarch64 - build-freebsd - build-linux-aarch64-musl steps: - uses: actions/checkout@v2 - name: Setup node uses: actions/setup-node@v2 with: node-version: 14 - name: Set release name run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Install dependencies run: npm i - name: Download all artifacts uses: actions/download-artifact@v2 with: path: artifacts - name: List binaries run: ls -R artifacts shell: bash - name: Move binaries shell: bash run: npm run artifacts - 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: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}