Skip to content

Commit a5fd0f5

Browse files
committed
init
0 parents  commit a5fd0f5

47 files changed

Lines changed: 8571 additions & 0 deletions

Some content is hidden

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

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[target.aarch64-unknown-linux-musl]
2+
linker = "aarch64-linux-musl-gcc"
3+
rustflags = ["-C", "target-feature=-crt-static"]
4+
[target.x86_64-pc-windows-msvc]
5+
rustflags = ["-C", "target-feature=+crt-static"]

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
github: seydx
2+
ko_fi: seydx
3+
custom: https://paypal.me/seydx

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
- package-ecosystem: cargo
8+
directory: "/"
9+
schedule:
10+
interval: weekly
11+
- package-ecosystem: npm
12+
directory: "/"
13+
schedule:
14+
interval: weekly

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ci-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
DEBUG: napi:*
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v7
23+
24+
- uses: actions/setup-node@v6
25+
with:
26+
node-version: 22
27+
cache: npm
28+
29+
- name: Install Rust toolchain
30+
uses: dtolnay/rust-toolchain@stable
31+
with:
32+
toolchain: nightly-2025-09-30
33+
components: clippy, rustfmt
34+
35+
- name: Cache cargo
36+
uses: actions/cache@v5
37+
with:
38+
path: |
39+
~/.cargo/registry/index/
40+
~/.cargo/registry/cache/
41+
~/.cargo/git/db/
42+
target/
43+
key: ci-x86_64-unknown-linux-gnu-cargo
44+
45+
- name: Install dependencies
46+
run: npm ci
47+
48+
- name: Format check (rustfmt)
49+
run: cargo fmt --check
50+
51+
- name: Lint (clippy + eslint)
52+
run: npm run lint
53+
54+
- name: Build (debug)
55+
run: npm run build:debug
56+
57+
- name: Verify generated bindings are up to date
58+
run: git diff --exit-code index.js index.d.ts

.github/workflows/release.yml

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
name: Release
2+
env:
3+
DEBUG: napi:*
4+
APP_NAME: rust-decoder
5+
MACOSX_DEPLOYMENT_TARGET: "10.13"
6+
permissions:
7+
contents: read
8+
on:
9+
push:
10+
tags:
11+
- "v*"
12+
workflow_dispatch:
13+
jobs:
14+
build:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
settings:
19+
- host: macos-latest
20+
target: x86_64-apple-darwin
21+
- host: windows-latest
22+
target: x86_64-pc-windows-msvc
23+
- host: ubuntu-latest
24+
target: x86_64-unknown-linux-gnu
25+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
26+
- host: ubuntu-latest
27+
target: x86_64-unknown-linux-musl
28+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
29+
- host: macos-latest
30+
target: aarch64-apple-darwin
31+
- host: ubuntu-latest
32+
target: aarch64-unknown-linux-gnu
33+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
34+
- host: ubuntu-latest
35+
target: aarch64-unknown-linux-musl
36+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
37+
- host: windows-latest
38+
target: aarch64-pc-windows-msvc
39+
- host: ubuntu-latest
40+
target: riscv64gc-unknown-linux-gnu
41+
setup: |
42+
sudo apt-get update
43+
sudo apt-get install gcc-riscv64-linux-gnu -y
44+
name: stable - ${{ matrix.settings.target }} - node@22
45+
runs-on: ${{ matrix.settings.host }}
46+
steps:
47+
- uses: actions/checkout@v7
48+
- name: Setup node
49+
uses: actions/setup-node@v6
50+
if: ${{ !matrix.settings.docker }}
51+
with:
52+
node-version: 22
53+
cache: npm
54+
- name: Install
55+
uses: dtolnay/rust-toolchain@stable
56+
if: ${{ !matrix.settings.docker }}
57+
with:
58+
toolchain: nightly-2025-09-30
59+
targets: ${{ matrix.settings.target }}
60+
- name: Cache cargo
61+
uses: actions/cache@v5
62+
with:
63+
path: |
64+
~/.cargo/registry/index/
65+
~/.cargo/registry/cache/
66+
~/.cargo/git/db/
67+
.cargo-cache
68+
target/
69+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
70+
- name: Setup toolchain
71+
run: ${{ matrix.settings.setup }}
72+
if: ${{ matrix.settings.setup }}
73+
shell: bash
74+
- name: Install dependencies
75+
if: ${{ !matrix.settings.docker }}
76+
run: npm ci
77+
- name: Build in docker
78+
uses: addnab/docker-run-action@v3
79+
if: ${{ matrix.settings.docker }}
80+
with:
81+
image: ${{ matrix.settings.docker }}
82+
options: "--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build"
83+
run: |
84+
# Upgrade Node.js to 22 (napi-rs images ship Node 18, @napi-rs/cli requires >= 20)
85+
if command -v apk > /dev/null 2>&1; then
86+
apk add --no-cache xz
87+
wget -qO- https://unofficial-builds.nodejs.org/download/release/v22.14.0/node-v22.14.0-linux-x64-musl.tar.xz | tar -xJ -C /usr/local --strip-components=1
88+
else
89+
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
90+
apt-get install -y nodejs
91+
fi
92+
rustup toolchain install nightly-2025-09-30
93+
rustup default nightly-2025-09-30
94+
rustup target add ${{ matrix.settings.target }}
95+
if [ "${{ matrix.settings.target }}" = "aarch64-unknown-linux-musl" ]; then
96+
apk add --no-cache zig
97+
fi
98+
npm ci
99+
npm run build -- --target ${{ matrix.settings.target }}
100+
- name: Build
101+
run: npm run build -- --target ${{ matrix.settings.target }}
102+
if: ${{ !matrix.settings.docker }}
103+
shell: bash
104+
- name: Upload artifact
105+
uses: actions/upload-artifact@v7
106+
with:
107+
name: bindings-${{ matrix.settings.target }}
108+
path: ${{ env.APP_NAME }}.*.node
109+
if-no-files-found: error
110+
build-freebsd:
111+
runs-on: ubuntu-latest
112+
name: Build FreeBSD
113+
steps:
114+
- uses: actions/checkout@v7
115+
- name: Build
116+
id: build
117+
uses: cross-platform-actions/action@v1.2.0
118+
env:
119+
DEBUG: napi:*
120+
RUSTUP_IO_THREADS: 1
121+
with:
122+
operating_system: freebsd
123+
version: "14.0"
124+
memory: 8G
125+
cpu_count: 3
126+
environment_variables: DEBUG RUSTUP_IO_THREADS
127+
shell: bash
128+
run: |
129+
sudo pkg install -y -f curl node libnghttp2 npm
130+
curl https://sh.rustup.rs -sSf --output rustup.sh
131+
sh rustup.sh -y --profile minimal --default-toolchain nightly-2025-09-30
132+
source "$HOME/.cargo/env"
133+
echo "~~~~ rustc --version ~~~~"
134+
rustc --version
135+
echo "~~~~ node -v ~~~~"
136+
node -v
137+
echo "~~~~ npm --version ~~~~"
138+
npm --version
139+
pwd
140+
ls -lah
141+
whoami
142+
env
143+
freebsd-version
144+
npm ci
145+
npm run build
146+
rm -rf node_modules
147+
rm -rf target
148+
- name: Upload artifact
149+
uses: actions/upload-artifact@v7
150+
with:
151+
name: bindings-freebsd
152+
path: ${{ env.APP_NAME }}.*.node
153+
if-no-files-found: error
154+
publish:
155+
name: Publish
156+
runs-on: ubuntu-latest
157+
environment: release
158+
permissions:
159+
id-token: write
160+
contents: read
161+
needs:
162+
- build
163+
- build-freebsd
164+
steps:
165+
- uses: actions/checkout@v7
166+
- name: Setup node
167+
uses: actions/setup-node@v6
168+
with:
169+
node-version: 22
170+
registry-url: "https://registry.npmjs.org"
171+
cache: npm
172+
- name: Install dependencies
173+
run: npm ci
174+
- name: Verify tag matches package.json version
175+
if: startsWith(github.ref, 'refs/tags/')
176+
run: |
177+
TAG="${GITHUB_REF_NAME#v}"
178+
PKG="$(node -p "require('./package.json').version")"
179+
echo "tag=$TAG package.json=$PKG"
180+
if [ "$TAG" != "$PKG" ]; then
181+
echo "::error::tag $GITHUB_REF_NAME does not match package.json version $PKG"
182+
exit 1
183+
fi
184+
- name: Download all artifacts
185+
uses: actions/download-artifact@v8
186+
with:
187+
path: artifacts
188+
- name: Move artifacts
189+
run: npm run artifacts
190+
- name: List packages
191+
run: ls -R ./npm
192+
shell: bash
193+
- name: Publish
194+
run: |
195+
# Upgrade npm for OIDC trusted publishing (requires npm >= 11.5.1)
196+
npm install -g npm@latest
197+
198+
# Update versions across platform packages (skip auto-publishing them)
199+
npx napi prepublish --no-gh-release --skip-optional-publish
200+
201+
# Publish platform packages (skip packages without artifacts, stuck at 0.0.0)
202+
for pkg_dir in npm/*/; do
203+
if [ -d "$pkg_dir" ]; then
204+
pkg_version=$(node -p "require('./${pkg_dir}package.json').version")
205+
if [ "$pkg_version" = "0.0.0" ]; then
206+
echo "Skipping ${pkg_dir} (no artifact, version 0.0.0)"
207+
continue
208+
fi
209+
(cd "$pkg_dir" && npm publish --provenance --access public)
210+
fi
211+
done
212+
213+
# Publish main package (prepublish already ran above)
214+
npm publish --provenance --access public --ignore-scripts

.github/workflows/stale.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Stale
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '45 11 * * *'
7+
8+
jobs:
9+
stale:
10+
name: Stale Bot
11+
runs-on: ubuntu-latest
12+
permissions:
13+
issues: write
14+
pull-requests: write
15+
16+
steps:
17+
- uses: actions/stale@v10.3.0
18+
with:
19+
repo-token: ${{ secrets.GITHUB_TOKEN }}
20+
stale-issue-label: 'stale'
21+
stale-pr-label: 'stale'
22+
exempt-issue-labels: pinned,security,long running,discussion,vision
23+
exempt-pr-labels: 'awaiting-approval,work-in-progress,pinned'
24+
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
25+
stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
26+
close-issue-message: 'This issue has been closed as no further activity has occurred.'
27+
close-pr-message: 'This pull request has been automatically closed because it has not had recent activity. Thank you for your contributions.'
28+
days-before-issue-stale: 30
29+
days-before-issue-close: 5
30+
days-before-stale: 15
31+
days-before-close: 2
32+
remove-stale-when-updated: true

0 commit comments

Comments
 (0)