Skip to content

build(deps): bump path-to-regexp from 8.3.0 to 8.4.0 #38

build(deps): bump path-to-regexp from 8.3.0 to 8.4.0

build(deps): bump path-to-regexp from 8.3.0 to 8.4.0 #38

Workflow file for this run

name: Quality and Release
on:
pull_request:
push:
branches:
- main
jobs:
quality:
name: Quality Gates
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Run quality gate
run: npm run ci:check
publish:
name: Publish Package
needs: quality
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm ci
- name: Verify package contents
run: npm run pack:dry-run
- name: Resolve publish state
id: release_state
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
node --input-type=module <<'EOF' >> "$GITHUB_OUTPUT"
import { execFileSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
const releaseTag = `v${pkg.version}`;
const compareSemver = (left, right) => {
const leftParts = left.split('.').map(Number);
const rightParts = right.split('.').map(Number);
const length = Math.max(leftParts.length, rightParts.length);
for (let index = 0; index < length; index += 1) {
const leftPart = leftParts[index] ?? 0;
const rightPart = rightParts[index] ?? 0;
if (leftPart > rightPart) return 1;
if (leftPart < rightPart) return -1;
}
return 0;
};
let npmVersion = null;
try {
npmVersion = execFileSync('npm', ['view', pkg.name, 'version'], {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
}).trim();
} catch {
npmVersion = null;
}
let releaseExists = false;
try {
execFileSync(
'gh',
['release', 'view', releaseTag, '--repo', process.env.GITHUB_REPOSITORY],
{ stdio: 'ignore' },
);
releaseExists = true;
} catch {
releaseExists = false;
}
let action = 'skip';
let reason = 'npm-and-github-aligned';
if (!npmVersion) {
action = 'publish';
reason = 'package-not-on-npm';
} else {
const comparison = compareSemver(pkg.version, npmVersion);
if (comparison > 0) {
action = 'publish';
reason = 'package-version-newer-than-npm';
} else if (comparison === 0 && !releaseExists) {
action = 'skip';
reason = 'github-release-missing-manual-reconciliation';
} else if (comparison < 0) {
action = 'skip';
reason = 'package-version-behind-npm';
}
}
console.log(`package_name=${pkg.name}`);
console.log(`package_version=${pkg.version}`);
console.log(`release_tag=${releaseTag}`);
console.log(`npm_version=${npmVersion ?? ''}`);
console.log(`release_exists=${releaseExists}`);
console.log(`action=${action}`);
console.log(`reason=${reason}`);
EOF
- name: Report publish state
run: |
echo "Package: ${{ steps.release_state.outputs.package_name }}"
echo "package.json version: ${{ steps.release_state.outputs.package_version }}"
echo "npm version: ${{ steps.release_state.outputs.npm_version || 'not published' }}"
echo "GitHub release exists: ${{ steps.release_state.outputs.release_exists }}"
echo "Action: ${{ steps.release_state.outputs.action }}"
echo "Reason: ${{ steps.release_state.outputs.reason }}"
- name: Extract release notes from changelog
if: steps.release_state.outputs.action == 'publish'
env:
PACKAGE_VERSION: ${{ steps.release_state.outputs.package_version }}
run: |
node --input-type=module <<'EOF'
import { readFileSync, writeFileSync } from 'node:fs';
const version = process.env.PACKAGE_VERSION;
const changelog = readFileSync('CHANGELOG.md', 'utf8');
const header = `## [${version}]`;
const start = changelog.indexOf(header);
if (start === -1) {
throw new Error(`CHANGELOG.md is missing an entry for ${version}.`);
}
const nextHeaderIndex = changelog.indexOf('\n## [', start + header.length);
const notes = changelog
.slice(start, nextHeaderIndex === -1 ? undefined : nextHeaderIndex)
.trim();
writeFileSync('release-notes.md', `${notes}\n`, 'utf8');
EOF
- name: Publish to npm
if: steps.release_state.outputs.action == 'publish'
run: npm publish --provenance --access public
- name: Create GitHub release
if: steps.release_state.outputs.action == 'publish'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.release_state.outputs.release_tag }}" \
--repo "${{ github.repository }}" \
--target "${{ github.sha }}" \
--title "${{ steps.release_state.outputs.release_tag }}" \
--notes-file release-notes.md