name: Publish to npm on: push: tags: - "v*" workflow_dispatch: permissions: contents: read jobs: publish: name: Publish runs-on: ubuntu-latest permissions: contents: read id-token: write steps: - name: Check out the repository uses: actions/checkout@v6 - name: Set up Node.js uses: actions/setup-node@v6 with: node-version: "24" registry-url: https://registry.npmjs.org package-manager-cache: false - name: Install canvas system libraries run: | sudo apt-get update sudo apt-get install -y \ build-essential \ pkg-config \ libcairo2-dev \ libpango1.0-dev \ libjpeg-dev \ libgif-dev \ librsvg2-dev \ fonts-dejavu-core - name: Use an npm CLI that supports trusted publishing run: npm install --global npm@^11.15.0 - name: Install dependencies run: npm ci - name: Check that the tag matches package.json run: | version="$(node -p "require('./package.json').version")" if [ "${GITHUB_REF_TYPE}" = "tag" ]; then tag="${GITHUB_REF_NAME#v}" if [ "$tag" != "$version" ]; then echo "Tag v${tag} does not match package.json version ${version}" exit 1 fi else echo "Manual run from ${GITHUB_REF_NAME}: publishing ${version}" fi - name: Run tests run: npm test - name: Publish run: npm publish --access public