Compare commits

...

4 Commits

7 changed files with 49 additions and 54 deletions

View File

@ -1,45 +0,0 @@
name: Build binaries and publish
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
CARGO_TERM_COLOR: always
jobs:
build-linux:
runs-on: node-16
container:
image: gitea.antonlyap.pp.ua/antonlyap/bliss-rs/node-rust:latest
credentials:
username: antonlyap
password: ${{ secrets.ACCESS_TOKEN }}
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
steps:
- name: Set path variable
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: target
key: ${{ matrix.target }}-rust-target
- run: npm install
- run: npm run build -- --release --target ${{ matrix.target }}
- uses: actions/upload-artifact@v3
with:
name: binary-${{ matrix.target }}
path: index.node

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
target
node_modules
index.node
index-*.node
bliss-rs-bliss-rs-*.tgz

View File

@ -1,7 +1,9 @@
FROM ghcr.io/catthehacker/ubuntu:js-22.04
FROM node:20-alpine
RUN apt-get update
RUN apt-get install -yqq wget build-essential yasm libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libavfilter-dev libavdevice-dev libswresample-dev libfftw3-dev libclang-dev ffmpeg
RUN apk add --update wget build-base yasm ffmpeg
# RUN apt-get update
# RUN apt-get install -yqq wget build-essential yasm libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libavfilter-dev libavdevice-dev libswresample-dev libfftw3-dev libclang-dev ffmpeg
WORKDIR /opt/rust
RUN wget https://sh.rustup.rs -O rustup-init.sh

View File

@ -6,9 +6,9 @@
This repo is a fork of [bliss-rs](https://github.com/Polochon-street/bliss-rs) with bindings for Node.js (using N-API and Neon).
## Example usage:
The package will be published to the Gitea registry and available for installation later.
The package is published to the Gitea registry: https://gitea.antonlyap.pp.ua/antonlyap/-/packages/npm/@bliss-rs%2Fbliss-rs/1.0.0
```ts
import { analyze, analyzeSync } from 'bliss';
import { analyze, analyzeSync } from '@bliss-rs/bliss-rs';
await analyze("/path/to/track.mp3") // returns Uint8Array
```

14
index.js Normal file
View File

@ -0,0 +1,14 @@
try {
module.exports = require('./index.node');
} catch {
const isLinux = process.platform === 'linux';
if (isLinux && process.arch === 'x64') {
module.exports = require('./index-x86_64-unknown-linux-gnu.node');
} else if (isLinux && process.arch === 'arm64') {
module.exports = require('./index-aarch64-unknown-linux-gnu.node');
} else {
throw new Error('Bliss: unsupported architecture');
}
}
export const { analyze, analyzeSync } = module;

18
package-lock.json generated
View File

@ -10,6 +10,18 @@
"license": "ISC",
"dependencies": {
"cargo-cp-artifact": "^0.1.8"
},
"devDependencies": {
"@types/node": "^20.10.5"
}
},
"node_modules/@types/node": {
"version": "20.10.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz",
"integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/cargo-cp-artifact": {
@ -19,6 +31,12 @@
"bin": {
"cargo-cp-artifact": "bin/cargo-cp-artifact.js"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
}
}
}

View File

@ -1,19 +1,23 @@
{
"name": "bliss-rs",
"version": "1.0.0",
"name": "@bliss-rs/bliss-rs",
"version": "0.0.1",
"description": "A fork of the bliss-rs library with Node.js bindings",
"main": "index.node",
"main": "index.js",
"types": "index.d.ts",
"directories": {
"example": "examples"
},
"files": ["index.js", "index.d.ts", "index-*.node"],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics"
},
"author": "antonlyap",
"license": "ISC",
"license": "GPL",
"dependencies": {
"cargo-cp-artifact": "^0.1.8"
},
"devDependencies": {
"@types/node": "^20.10.5"
}
}