Skip to content

switch to script to determine target #38

switch to script to determine target

switch to script to determine target #38

Workflow file for this run

name: Build And Release
on: [workflow_dispatch, push]
jobs:
Build:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
arch:
- x64
- arm64
runs-on: ${{matrix.os}}
steps:
- name: Checking out Repository
uses: actions/checkout@v3
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Get Target Name
id: get_target
run: |
echo "target_name=$(node ./utils/getTarget.js)" >> $GITHUB_ENV
- name: Install Rust
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: dtolnay/rust-toolchain@master
env:
npm_config_arch: ${{ matrix.arch }}
with:
toolchain: stable
targets: ${{ steps.get_target.outputs.target_name }}
- name: Building
env:
npm_config_arch: ${{ matrix.arch }}
run: pnpm install
- name: Uploading
if: ${{github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')}}
uses: actions/upload-artifact@v5
with:
name: bin-${{runner.os}}-${{matrix.arch}}
path: bin/**
Release:
if: ${{github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')}}
needs: Build
runs-on: ubuntu-latest
steps:
- name: Checking out Repository
uses: actions/checkout@v3
with:
submodules: true
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Fix Directory Structure
run: |
mkdir bin
mv bin-*/* bin/
rm -rf bin-*
sudo chmod -R +x bin
# this will only publish if the version has been updated
- name: NPM Publish
uses: JS-DevTools/[email protected]
with:
token: ${{secrets.NPM_TOKEN}}