Skip to content

ci(node) Pack before deploy (#4) #4

ci(node) Pack before deploy (#4)

ci(node) Pack before deploy (#4) #4

Workflow file for this run

name: Node Release
env:
NODE_VERSION: 18
on:
push:
tags:
- node-v*
jobs:
build:
env:
MACOSX_DEPLOYMENT_TARGET: 10.11
strategy:
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
- host: flyci-macos-14-m2
target: arm64-apple-darwin
runs-on: ${{ matrix.settings.host }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
# Necessary for now for the cargo cache: https://github.com/actions/cache/issues/133#issuecomment-599102035
- if: matrix.os == 'ubuntu-latest'
run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
- name: Cache Cargo Registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
- name: Install Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
cache-dependency-path: ./bindings/node/
- name: Install npm dependencies
working-directory: ./bindings/node
run: yarn install
- name: Build and package rust
working-directory: ./bindings/node
run: |
yarn build &&
strip -x *.node
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ./bindings/node/*.node
if-no-files-found: error
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache-dependency-path: ./bindings/node/
cache: yarn
- name: Install dependencies
working-directory: ./bindings/node
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./bindings/node/artifacts
- name: Move artifacts
working-directory: ./bindings/node
run: yarn artifacts
- name: List packages
working-directory: ./bindings/node
run: ls -R ./npm
shell: bash
- name: List files
working-directory: ./bindings/node
run: ls -la
shell: bash
- name: Package Library for Publish
id: package
working-directory: ./bindings/node
run: |
version=$(echo "${{github.ref}}" | sed 's/refs\/tags\/node-v//g')
echo "version=${version}"
npm version $version -m "build(version): Bump version to %s"
npm pack
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Publish
working-directory: ./bindings/node
env:
VERSION: ${{ steps.package.outputs.version }}
run: |
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm publish turingscript-tokenizers-${VERSION}.tgz --access public