Skip to content

Merge pull request #15 from artiz/claude/nodejs-bun-typescript-bindin… #116

Merge pull request #15 from artiz/claude/nodejs-bun-typescript-bindin…

Merge pull request #15 from artiz/claude/nodejs-bun-typescript-bindin… #116

Workflow file for this run

name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
# Manual re-run from the Actions tab / `gh workflow run`. Left blank it runs lint
# + test only; set `force_version` to (re)publish that exact version — use it to
# release a version a failed/blocked run skipped (e.g. the master-ruleset reject).
workflow_dispatch:
inputs:
force_version:
description: "Force a release at this exact version (e.g. 0.3.0). Blank = lint+test only, no publish."
required: false
default: ""
# Cancel superseded PR runs, but never interrupt a master run (it may publish).
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
# Rust version for the style/lint gates. Pinned on purpose: rustfmt and clippy
# change their output/lints between releases, so a floating `stable` would let
# a new toolchain fail CI on otherwise-unrelated commits. Bump this manually
# (and fix any new findings in the same PR) when you want to adopt a newer one.
LINT_TOOLCHAIN: "1.96.0"
jobs:
lint:
name: fmt · clippy (pinned)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.LINT_TOOLCHAIN }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --all --check
- name: Clippy
run: cargo clippy --workspace --all-targets -- -D warnings
test:
name: test (stable)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Tests stay on the current stable so they catch real compiler breakage.
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# Pure-Rust unit tests + the output-regression suite. The PDF/image/METS
# snapshot tests need pdfium + the ONNX models, so they are NOT run here —
# this job downloads no ML models and stays fast.
- name: Test
run: cargo test --workspace
publish:
name: release & publish
needs: [lint, test]
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.force_version != '')
runs-on: ubuntu-latest
permissions:
contents: write # push the version-bump commit + tag
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history + tags, for the semantic version bump
# Push the release commit + tag as an admin PAT so it satisfies the
# `master` ruleset; the default GITHUB_TOKEN can't be granted a bypass.
token: ${{ secrets.RELEASE_PAT }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# Decide the next version from conventional commits since the last tag (or
# use force_version on a manual dispatch); if there is one, bump + commit +
# tag it, push to master, and publish the crates (in dependency order,
# skipping any already on crates.io). A no-op when no release-worthy commit
# landed. The release commit is pushed with RELEASE_PAT (an admin token, so
# it satisfies the master ruleset) and carries [skip ci], so it does not
# re-trigger CI.
- name: Release & publish
id: release
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
FORCE_VERSION: ${{ github.event.inputs.force_version }}
run: bash scripts/release.sh
# Cut a GitHub Release for the tag release.sh just pushed, using the commit
# list it assembled as the description. Skipped when the release step was a
# no-op (no release-worthy commits). Idempotent: if a release for the tag
# already exists (e.g. a forced re-publish), refresh its notes instead of
# failing.
- name: Create GitHub Release
if: steps.release.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.RELEASE_PAT }}
run: |
tag="v${{ steps.release.outputs.version }}"
notes="${{ steps.release.outputs.notes_file }}"
if gh release view "$tag" >/dev/null 2>&1; then
gh release edit "$tag" --title "$tag" --notes-file "$notes"
else
gh release create "$tag" --title "$tag" --notes-file "$notes" --verify-tag
fi