Skip to content

Release

Release #28

Workflow file for this run

name: Release
on:
workflow_run:
workflows: ["CI"]
types:
- completed
jobs:
build-binaries:
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'master' &&
startsWith(github.event.workflow_run.head_commit.message, 'chore(release)')
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- platform: linux
arch: x64
binary: vendor/lame/linux-x64/lame
- platform: darwin
arch: arm64
binary: vendor/lame/darwin-arm64/lame
- platform: win32
arch: x64
binary: vendor/lame/win32-x64/lame.exe
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_commit.id }}
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: pnpm
- name: Install dependencies
env:
LAME_SKIP_DOWNLOAD: "1"
run: pnpm install --frozen-lockfile
- name: Download LAME binary for ${{ matrix.platform }}-${{ matrix.arch }}
env:
NODE_LAME_PLATFORM: ${{ matrix.platform }}
NODE_LAME_ARCH: ${{ matrix.arch }}
LAME_FORCE_DOWNLOAD: "1"
run: node scripts/install-lame.mjs
- name: Package binary
run: node scripts/package-lame.mjs --binary "${{ matrix.binary }}" --platform "${{ matrix.platform }}" --arch "${{ matrix.arch }}" --out-dir artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: lame-${{ matrix.platform }}-${{ matrix.arch }}
path: artifacts
publish:
needs: build-binaries
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'master' &&
startsWith(github.event.workflow_run.head_commit.message, 'chore(release)')
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_commit.id }}
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24.x
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Unpack binaries into vendor directory
run: node scripts/unpack-lame-artifacts.mjs artifacts vendor/lame
- name: Build package
run: pnpm run build
- name: Prepare release assets
run: |
set -eo pipefail
VERSION=$(node -p "require('./package.json').version")
ASSET_DIR="$PWD/release-assets"
mkdir -p "$ASSET_DIR"
while IFS= read -r manifest; do
base=$(basename "$manifest" .json)
src_dir="vendor/lame/$base"
if [ ! -d "$src_dir" ]; then
echo "Skipping $base - no vendor directory"
continue
fi
tmp_dir=$(mktemp -d)
cp "$src_dir"/* "$tmp_dir/"
cp "$manifest" "$tmp_dir/manifest.json"
(cd "$tmp_dir" && zip -qr "$ASSET_DIR/node-lame-v${VERSION}-${base}.zip" .)
rm -rf "$tmp_dir"
done < <(find artifacts -maxdepth 3 -name '*.json')
zip -qr "$ASSET_DIR/node-lame-v${VERSION}-dist.zip" dist
- name: Publish release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm run release:publish
- name: Upload assets to GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="v${VERSION}"
gh release upload "$TAG" release-assets/*.zip --clobber