Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit 7a2548e

Browse files
committed
chore: add gha workflows for PR validation, stable promotion, and package release
1 parent 1124775 commit 7a2548e

4 files changed

Lines changed: 162 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PR Validation
2+
3+
on:
4+
pull_request:
5+
branches: [main, stable, "*.x"]
6+
7+
concurrency:
8+
group: pr-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
validate:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 22
22+
23+
- run: npm ci
24+
25+
- name: Validate commits
26+
run: |
27+
npx commitlint \
28+
--from ${{ github.event.pull_request.base.sha }} \
29+
--to ${{ github.event.pull_request.head.sha }}
30+
31+
- run: npm run lint
32+
- run: npm run build
33+
- run: npm test
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Promote to Stable
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
promote:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
14+
- run: |
15+
git config user.name "github-actions[bot]"
16+
git config user.email "github-actions[bot]@users.noreply.github.com"
17+
git checkout stable || git checkout -b stable
18+
git merge main --no-ff -m "chore: promote main to stable"
19+
git push origin stable
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release Package
2+
3+
on:
4+
push:
5+
branches: [main, stable, "*.x"]
6+
paths:
7+
- "packages/**"
8+
- "!**.md"
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: release-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
packages: write
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: 22
30+
registry-url: "https://registry.npmjs.org"
31+
32+
- run: npm ci
33+
- run: npm run build
34+
- run: npm test
35+
36+
- name: Release
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
40+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
run: npx semantic-release

.releaserc.cjs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* eslint-env node */
2+
3+
const branch = process.env.GITHUB_REF_NAME || process.env.CI_COMMIT_BRANCH
4+
5+
const config = {
6+
branches: [
7+
{
8+
name: 'stable',
9+
channel: 'latest', // Only stable gets @latest
10+
},
11+
{
12+
name: 'main',
13+
prerelease: 'next',
14+
channel: 'next',
15+
},
16+
// Maintenance branches - channel defaults to branch name
17+
{
18+
name: '+([0-9])?(.{+([0-9]),x}).x',
19+
// No channel specified - defaults to branch name (0.8.x, 1.2.x, etc)
20+
},
21+
],
22+
tagFormat: 'v${version}',
23+
plugins: [
24+
'@semantic-release/commit-analyzer',
25+
'@semantic-release/release-notes-generator',
26+
// NPM plugin MUST come before git plugin - ADD pkgRoot HERE!
27+
[
28+
'@semantic-release/npm',
29+
{
30+
npmPublish: true,
31+
pkgRoot: 'packages/superdoc'
32+
}
33+
],
34+
'./scripts/publish-superdoc.cjs'
35+
],
36+
}
37+
38+
// Only add changelog and git plugins for non-prerelease branches
39+
const isPrerelease = config.branches.some(
40+
(b) => typeof b === 'object' && b.name === branch && b.prerelease
41+
)
42+
43+
if (!isPrerelease) {
44+
// Add changelog BEFORE git
45+
config.plugins.push([
46+
'@semantic-release/changelog',
47+
{
48+
changelogFile: 'packages/superdoc/CHANGELOG.md' // Also specify where changelog goes
49+
}
50+
])
51+
52+
// Git plugin comes AFTER npm and changelog
53+
config.plugins.push([
54+
'@semantic-release/git',
55+
{
56+
assets: [
57+
'packages/superdoc/CHANGELOG.md',
58+
'packages/superdoc/package.json' // Update paths to point to actual package
59+
],
60+
message:
61+
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
62+
},
63+
])
64+
}
65+
66+
// GitHub plugin comes last
67+
config.plugins.push('@semantic-release/github')
68+
69+
module.exports = config

0 commit comments

Comments
 (0)