Skip to content

Commit 5d99636

Browse files
committed
feat: receive the xslint release cascade
On a repository_dispatch (xslint-released) from xslint, bump the @maxonfjvipon/xslint dependency to the released version, validate against it (lint, test, coverage), then cut this tool's own next patch: compute it from npm view xslint-lsp version + 1 (independent of xslint's number), record it in the changelog, commit to master, and push the tag so release.yml publishes. Pushes use DISPATCH_TOKEN so the tag triggers release.yml and the commit bypasses the branch ruleset.
1 parent 810e2a0 commit 5d99636

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

.github/workflows/cascade.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 Max Trunnikov
2+
# SPDX-License-Identifier: MIT
3+
---
4+
name: cascade
5+
'on':
6+
repository_dispatch:
7+
types: [xslint-released]
8+
permissions:
9+
contents: write
10+
concurrency:
11+
group: cascade-${{ github.ref }}
12+
cancel-in-progress: false
13+
jobs:
14+
cascade:
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- uses: actions/checkout@v7
18+
with:
19+
token: ${{ secrets.DISPATCH_TOKEN }}
20+
- uses: actions/setup-node@v7
21+
with:
22+
node-version: 22
23+
- name: Bump @maxonfjvipon/xslint to the released version
24+
id: bump
25+
env:
26+
NEW: ${{ github.event.client_payload.version }}
27+
run: |
28+
current="$(node -p "require('./package.json').dependencies['@maxonfjvipon/xslint']")"
29+
current="${current//[!0-9.]/}"
30+
if [ "${current}" = "${NEW}" ]; then
31+
echo "changed=false" >> "${GITHUB_OUTPUT}"
32+
echo "Already depends on ${NEW}; nothing to do"
33+
exit 0
34+
fi
35+
npm install --save "@maxonfjvipon/xslint@^${NEW}"
36+
echo "changed=true" >> "${GITHUB_OUTPUT}"
37+
- name: Validate against the new xslint
38+
if: steps.bump.outputs.changed == 'true'
39+
run: |
40+
npm run lint
41+
npm test
42+
npm run coverage
43+
- name: Compute this tool's next patch version
44+
id: next
45+
if: steps.bump.outputs.changed == 'true'
46+
run: |
47+
latest="$(npm view xslint-lsp version)"
48+
next="$(echo "${latest}" | awk -F. '{printf "%d.%d.%d", $1, $2, $3 + 1}')"
49+
echo "version=${next}" >> "${GITHUB_OUTPUT}"
50+
- name: Record the change in the changelog
51+
if: steps.bump.outputs.changed == 'true'
52+
env:
53+
NEW: ${{ github.event.client_payload.version }}
54+
NEXT: ${{ steps.next.outputs.version }}
55+
run: node scripts/changelog-add.js "${NEXT}" "${NEW}"
56+
- name: Commit the bump and tag the release
57+
if: steps.bump.outputs.changed == 'true'
58+
env:
59+
NEW: ${{ github.event.client_payload.version }}
60+
NEXT: ${{ steps.next.outputs.version }}
61+
run: |
62+
git config user.name "github-actions[bot]"
63+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
64+
git add package.json package-lock.json CHANGELOG.md
65+
git commit -m "chore: bump @maxonfjvipon/xslint to ${NEW}"
66+
git push origin HEAD:master
67+
git tag "${NEXT}"
68+
git push origin "${NEXT}"

scripts/changelog-add.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright (c) 2025-2026 Max Trunnikov
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
6+
'use strict'
7+
8+
const fs = require('fs')
9+
10+
const version = process.argv[2]
11+
const dependency = process.argv[3]
12+
if (!version || !dependency) {
13+
throw new Error('usage: changelog-add.js <version> <xslint-version>')
14+
}
15+
16+
const today = new Date().toISOString().slice(0, 10)
17+
const lines = fs.readFileSync('CHANGELOG.md', 'utf-8').split('\n')
18+
const at = lines.indexOf('## Unreleased')
19+
if (at < 0) {
20+
throw new Error('no "## Unreleased" section in CHANGELOG.md')
21+
}
22+
lines.splice(
23+
at + 1,
24+
0,
25+
'',
26+
`## ${version} - ${today}`,
27+
'',
28+
`- Bump \`@maxonfjvipon/xslint\` to ${dependency}.`,
29+
)
30+
fs.writeFileSync('CHANGELOG.md', lines.join('\n'))

0 commit comments

Comments
 (0)