Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,37 @@ jobs:
- name: Package prebuild
run: npm run build

bun:
name: Bun build and test on ubuntu
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: true

- name: Install Node v24
uses: actions/setup-node@v6
with:
node-version: 24

- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install --ignore-scripts

- name: Run native install
run: bun run install

- name: Build prebuild
run: bun run build

- name: Run tests
run: bun run test:bun

build_musl:
name: Build node ${{ matrix.node }} on ${{ matrix.os }} (musl)
runs-on: ${{ matrix.os }}
Expand Down
79 changes: 78 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,91 @@ jobs:
with:
path: 'build/stage/**/*.tar.gz'

bun:
name: Bun build and test on ubuntu
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: true

- name: Install Node v24
uses: actions/setup-node@v6
with:
node-version: 24

- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install --ignore-scripts

- name: Run native install
run: bun run install

- name: Build prebuild
run: bun run build

- name: Run tests
run: bun run test:bun

- name: Upload prebuild asset
uses: icrawl/action-artifact@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: 'build/stage/**/*.tar.gz'

build_debian:
name: Prebuild node ${{ matrix.node }} on ${{ matrix.os }} (debian)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
node: [20, 22]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: true

- name: Setup container
run: |
docker run --name runner --rm -it -d -v $PWD:/node-opus -w /node-opus node:${{ matrix.node }}-bullseye

- name: Setup env with Node v${{ matrix.node }}
run: |
docker exec runner apt-get update
docker exec runner apt-get install -y ca-certificates git curl build-essential python3 g++ make libopus-dev

- name: Install dependencies
run: docker exec runner npm install --build-from-source

- name: Package prebuild
run: docker exec runner npm run build

- name: Stop container
run: docker rm -f runner

- name: Upload prebuild asset
uses: icrawl/action-artifact@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: 'build/stage/**/*.tar.gz'

build_musl:
name: Prebuild node ${{ matrix.node }} on ${{ matrix.os }} (musl)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
node: [20, 22, 24, 25]
node: [20, 22]
steps:
- name: Checkout repository
uses: actions/checkout@v6
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,25 @@ const decoded = encoder.decode(encoded);
- macOS x64
- macOS arm64
- Windows x64

## Bun support

Bun does not run lifecycle scripts by default. You can either trust this dependency or run the install script manually. Bun uses the Node 20 N-API prebuilds by default:

```bash
bun pm trust @discordjs/opus
bun install
```

```bash
bun install --ignore-scripts
bun run install
```

If you use a monorepo, run the command in the workspace that installs `@discordjs/opus`.

To run the test suite with Bun, use:

```bash
bun run test:bun
```
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"author": "iCrawl <icrawltogo@gmail.com>",
"license": "MIT",
"scripts": {
"install": "node-pre-gyp install --fallback-to-build",
"build": "node-pre-gyp install build package",
"install": "bun x node-pre-gyp install --fallback-to-build || node-pre-gyp install --fallback-to-build",
"build": "bun x node-pre-gyp install build package || node-pre-gyp install build package",
"lint": "prettier --check . && eslint lib --format=pretty",
"lint:fix": "prettier --write . && eslint lib --fix --format=pretty",
"test": "node tests/test.js"
"test": "node tests/test.js",
"test:bun": "bun tests/test.js"
},
"keywords": [
"native",
Expand Down Expand Up @@ -51,9 +52,9 @@
},
"binary": {
"module_name": "opus",
"module_path": "./prebuild/{node_abi}-napi-v{napi_build_version}-{platform}-{arch}-{libc}-{libc_version}/",
"module_path": "./prebuild/{node_napi_label}-{platform}-{arch}-{libc}-{libc_version}/",
"remote_path": "v{version}",
"package_name": "{module_name}-v{version}-{node_abi}-napi-v{napi_build_version}-{platform}-{arch}-{libc}-{libc_version}.tar.gz",
"package_name": "{module_name}-v{version}-{node_napi_label}-{platform}-{arch}-{libc}-{libc_version}.tar.gz",
"host": "https://github.com/discordjs/opus/releases/download/",
"napi_versions": [
3
Expand Down