Abandon the automation idea, prepare the package for publishing with prebuilt binaries

This commit is contained in:
Anton Liaposhchenko 2023-12-28 00:46:05 +02:00
parent fa2e65d462
commit 7333754bb2
6 changed files with 48 additions and 51 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

15
index.js Normal file
View File

@ -0,0 +1,15 @@
let module;
try {
module = await import('./index.node');
} catch {
const isLinux = process.platform === 'linux';
if (isLinux && process.arch === 'x64') {
module = await import('./index-x86_64-unknown-linux-gnu.node');
} else if (isLinux && process.arch === 'arm64') {
module = await import('./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,24 @@
{
"name": "bliss-rs",
"name": "@bliss-rs/bliss-rs",
"type": "module",
"version": "1.0.0",
"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"
}
}