Skip to content

update release config for cross-compilation and trusted-publishing #61

update release config for cross-compilation and trusted-publishing

update release config for cross-compilation and trusted-publishing #61

Workflow file for this run

name: Build And Release
on:
workflow_dispatch:
push:
tags:
- 'v*'
branches:
- main
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: Install Linux Dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Get Target Name
id: get_target
env:
npm_config_arch: ${{ matrix.arch }}
shell: bash
run: |
TARGET_NAME=$(node ./utils/getTarget.js)
echo "target_name=$TARGET_NAME" >> $GITHUB_OUTPUT
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ steps.get_target.outputs.target_name }}
- name: Building
if: runner.os == 'Linux' && matrix.arch == 'arm64'
env:
npm_config_arch: ${{ matrix.arch }}
CC: aarch64-linux-gnu-gcc
run: pnpm install
- name: Building
if: ${{ !(runner.os == 'Linux' && matrix.arch == 'arm64') }}
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: Update npm
run: npm install -g npm@latest
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Download Artifacts
uses: actions/download-artifact@v5
- name: Fix Directory Structure
run: |
mkdir bin
ls -la
mv bin-*/* bin/
rm -rf bin-*
sudo chmod -R +x bin
- name: Verify Binaries
run: |
// make sure all binaries are present
if [ ! -f bin/dump-syms-linux-x64 ]; then echo "Missing bin/dump-syms-linux-x64" && exit 1; fi
if [ ! -f bin/dump-syms-linux-arm64 ]; then echo "Missing bin/dump-syms-linux-arm64" && exit 1; fi
if [ ! -f bin/dump-syms-macos-x64 ]; then echo "Missing bin/dump-syms-macos-x64" && exit 1; fi
if [ ! -f bin/dump-syms-macos-arm64 ]; then echo "Missing bin/dump-syms-macos-arm64" && exit 1; fi
if [ ! -f bin/dump-syms-windows-x64.exe ]; then echo "Missing bin/dump-syms-windows-x64.exe" && exit 1; fi
if [ ! -f bin/dump-syms-windows-arm64.exe ]; then echo "Missing bin/dump-syms-windows-arm64.exe" && exit 1; fi
- name: Verify Version
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
exit 1
fi
# this will only publish if the version has been updated
- name: NPM Publish
run: |
npm publish