Skip to content

Commit 6610c1c

Browse files
oleg-kovalcoderabbitai[bot]CodeRabbit
authored
feat(release): add beta channel and docs automation (#56)
* feat(release): add beta channel and docs automation * fix(release): repair changelog and dry-run CI * fix: apply CodeRabbit auto-fixes Fixed 1 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
1 parent 9550a3a commit 6610c1c

14 files changed

Lines changed: 6355 additions & 6802 deletions

.github/workflows/ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
- main
8+
- beta
9+
push:
10+
branches:
11+
- master
12+
- main
13+
- beta
14+
workflow_dispatch:
15+
16+
jobs:
17+
validate:
18+
name: Validate on Node ${{ matrix.node-version }}
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
node-version: [22, 24]
24+
permissions:
25+
contents: read
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
cache: npm
37+
38+
- name: Install dependencies
39+
run: npm ci
40+
41+
- name: Run tests
42+
run: npm test
43+
44+
- name: Smoke-load release config
45+
run: npm run test:config
46+
47+
- name: Check docs index
48+
run: npm run docs:index:check
49+
50+
semantic-release-dry-run:
51+
name: semantic-release dry run
52+
runs-on: ubuntu-latest
53+
needs: validate
54+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
55+
permissions:
56+
contents: read
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 0
62+
63+
- name: Setup Node.js
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: 24
67+
cache: npm
68+
69+
- name: Install dependencies
70+
run: npm ci
71+
72+
- name: Run semantic-release in dry-run mode
73+
run: npm run release:dry-run

.github/workflows/codeql-analysis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ master ]
16+
branches: [ master, main ]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [ master ]
19+
branches: [ master, main ]
2020
schedule:
2121
- cron: '18 1 * * 0'
2222

@@ -39,11 +39,11 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v4
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
46+
uses: github/codeql-action/init@v3
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
57+
uses: github/codeql-action/autobuild@v3
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# make release
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v1
71+
uses: github/codeql-action/analyze@v3

.github/workflows/release.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,30 @@ on:
44
push:
55
branches:
66
- master
7+
- main
8+
- beta
79

810
jobs:
911
publish:
10-
name: Publish to Github & NPM or Github Package Registry
12+
name: Publish to GitHub and npm
1113
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
issues: write
17+
pull-requests: write
1218
steps:
13-
- uses: actions/checkout@v1
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
1422
- uses: actions/setup-node@v4
1523
with:
16-
node-version: 18
17-
- env:
18-
CI: true
24+
node-version: 24
25+
cache: npm
26+
- name: Install dependencies
1927
run: npm ci
20-
- if: success()
28+
- name: Publish release
2129
env:
2230
CI: true
23-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
2431
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2532
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
26-
run: npx semantic-release
33+
run: npm run semantic-release

.github/workflows/test-release.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

commit-transform.js

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,51 @@ const COMMIT_HASH_LENGTH = 7;
1212
* @return {Object} the transformed commit.
1313
*/
1414
module.exports = (commit, context) => {
15-
if (commit.notes) {
16-
commit.notes.forEach(note => {
17-
note.title = 'Breaking changes';
18-
});
19-
}
20-
21-
if (types.types[commit.type] && (types.types[commit.type].changelog || (commit.notes && commit.notes.length > 0))) {
22-
commit.groupType = `${types.types[commit.type].emoji ? `${types.types[commit.type].emoji} ` : ''}${
23-
types.types[commit.type].title
24-
}`;
25-
commit.type = commit.groupType;
26-
} else {
15+
const commitType = types.types[commit.type];
16+
const notes = Array.isArray(commit.notes)
17+
? commit.notes.map(note => ({
18+
...note,
19+
title: 'Breaking changes',
20+
}))
21+
: [];
22+
23+
if (!commitType || (!commitType.changelog && notes.length === 0)) {
2724
return null;
2825
}
2926

30-
if (commit.scope === '*') {
31-
commit.scope = '';
32-
}
33-
34-
if (typeof commit.hash === 'string') {
35-
commit.shortHash = commit.hash.slice(0, COMMIT_HASH_LENGTH);
36-
}
27+
const groupType = `${commitType.emoji ? `${commitType.emoji} ` : ''}${commitType.title}`;
3728

3829
const references = [];
30+
let subject = commit.subject;
3931

40-
if (typeof commit.subject === 'string') {
32+
if (typeof subject === 'string') {
4133
let url = context.repository ? `${context.host}/${context.owner}/${context.repository}` : context.repoUrl;
4234

4335
if (url) {
4436
url += '/issues/';
4537
// Issue URLs.
46-
commit.subject = commit.subject.replace(/#(\d+)/g, (_, issue) => {
38+
subject = subject.replace(/#(\d+)/g, (_, issue) => {
4739
references.push(issue);
4840
return `[#${issue}](${url}${issue})`;
4941
});
5042
}
5143

5244
if (context.host) {
5345
// User URLs.
54-
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9]){0,38})/g, `[@$1](${context.host}/$1)`);
46+
subject = subject.replace(/\B@([a-z0-9](?:-?[a-z0-9]){0,38})/g, `[@$1](${context.host}/$1)`);
5547
}
5648
}
5749

58-
if (commit.references) {
59-
// Remove references that already appear in the subject
60-
commit.references = commit.references.filter(reference => {
61-
if (!references.includes(reference.issue)) {
62-
return true;
63-
}
64-
65-
return false;
66-
});
67-
}
68-
69-
return commit;
50+
return {
51+
...commit,
52+
groupType,
53+
type: groupType,
54+
scope: commit.scope === '*' ? '' : commit.scope,
55+
shortHash: typeof commit.hash === 'string' ? commit.hash.slice(0, COMMIT_HASH_LENGTH) : commit.shortHash,
56+
subject,
57+
notes,
58+
references: Array.isArray(commit.references)
59+
? commit.references.filter(reference => !references.includes(reference.issue))
60+
: commit.references,
61+
};
7062
};

docs/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Docs Index
2+
3+
Repository documentation kept in sync by `docs-index-keeper`.
4+
5+
| Doc | Purpose |
6+
| --- | --- |
7+
| [release-channels.md](./release-channels.md) | Stable and beta release channel behavior for this repository |

docs/release-channels.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Release Channels
2+
3+
This repository uses a repo-only semantic-release config to keep package consumers on the shared preset while giving the repository two release channels:
4+
5+
- `master` and `main` publish stable releases on the default `latest` channel during the branch migration window
6+
- `beta` publishes prereleases with the `beta` dist-tag and `-beta.N` versions
7+
8+
The repo automation uses `release.repo.config.js` so the published shareable config in `release.config.js` does not force prerelease branches on downstream consumers.

0 commit comments

Comments
 (0)