Skip to content

Commit 4afe9b1

Browse files
committed
feat: modernize repository structure and tools; introduce ci/cd
1 parent 3fdd967 commit 4afe9b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+9787
-4306
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
name: Node ${matrix.node} on ${matrix.os}
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
node: ["20.x", "22.x"]
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup pnpm
21+
uses: pnpm/action-setup@v4
22+
with:
23+
version: 10.x
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.node }}
29+
cache: pnpm
30+
31+
- name: Install dependencies
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Lint
35+
run: pnpm run lint
36+
37+
- name: Typecheck
38+
run: pnpm run typecheck
39+
40+
- name: Unit tests
41+
run: pnpm run test:unit
42+
43+
- name: Integration tests
44+
if: matrix.os == 'ubuntu-latest'
45+
run: pnpm run test:integration
46+
47+
- name: Build package
48+
run: pnpm run build

.github/workflows/release.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
build-binaries:
11+
if: >
12+
github.event.workflow_run.conclusion == 'success' &&
13+
github.event.workflow_run.head_branch == 'master'
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
node: ["20.x"]
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
25+
ref: ${{ github.event.workflow_run.head_commit.id }}
26+
27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: 10.x
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: ${{ matrix.node }}
36+
cache: pnpm
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: Install LAME (Ubuntu)
42+
if: matrix.os == 'ubuntu-latest'
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y lame
46+
47+
- name: Install LAME (macOS)
48+
if: matrix.os == 'macos-latest'
49+
run: brew install lame
50+
51+
- name: Install LAME (Windows)
52+
if: matrix.os == 'windows-latest'
53+
shell: powershell
54+
run: choco install lame --no-progress -y
55+
56+
- name: Package binary (Unix)
57+
if: matrix.os != 'windows-latest'
58+
shell: bash
59+
run: |
60+
set -euo pipefail
61+
PLATFORM=$(node -p "process.platform")
62+
ARCH=$(node -p "process.arch")
63+
BINARY_PATH=$(command -v lame)
64+
mkdir -p artifacts
65+
node scripts/package-lame.mjs --binary "$BINARY_PATH" --platform "$PLATFORM" --arch "$ARCH" --out-dir artifacts
66+
67+
- name: Package binary (Windows)
68+
if: matrix.os == 'windows-latest'
69+
shell: powershell
70+
run: |
71+
$platform = node -p "process.platform"
72+
$arch = node -p "process.arch"
73+
$binary = (Get-Command lame.exe).Source
74+
New-Item -ItemType Directory -Force -Path artifacts | Out-Null
75+
node scripts/package-lame.mjs --binary "$binary" --platform "$platform" --arch "$arch" --out-dir artifacts
76+
77+
- name: Upload artifacts
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: lame-${{ matrix.os }}
81+
path: artifacts
82+
83+
publish:
84+
needs: build-binaries
85+
if: >
86+
github.event.workflow_run.conclusion == 'success' &&
87+
github.event.workflow_run.head_branch == 'master'
88+
runs-on: ubuntu-latest
89+
permissions:
90+
contents: write
91+
id-token: write
92+
steps:
93+
- name: Checkout
94+
uses: actions/checkout@v4
95+
with:
96+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
97+
ref: ${{ github.event.workflow_run.head_commit.id }}
98+
99+
- name: Setup pnpm
100+
uses: pnpm/action-setup@v4
101+
with:
102+
version: 10.x
103+
104+
- name: Setup Node.js
105+
uses: actions/setup-node@v4
106+
with:
107+
node-version: 22.x
108+
cache: pnpm
109+
registry-url: https://registry.npmjs.org
110+
111+
- name: Install dependencies
112+
run: pnpm install --frozen-lockfile
113+
114+
- name: Download artifacts
115+
uses: actions/download-artifact@v4
116+
with:
117+
path: artifacts
118+
119+
- name: Unpack binaries into vendor directory
120+
run: node scripts/unpack-lame-artifacts.mjs artifacts vendor/lame
121+
122+
- name: Build package
123+
run: pnpm run build
124+
125+
- name: Publish to npm
126+
env:
127+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
128+
run: pnpm publish --access public

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
vendor/
5+
pnpm-lock.yaml

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"tabWidth": 4
2+
"tabWidth": 4
33
}

0 commit comments

Comments
 (0)