Skip to content

Commit 91a8140

Browse files
committed
ci: config beachball to automate publishing process
1 parent 2298068 commit 91a8140

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed

Diff for: .github/workflows/ci.yml

+20
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,23 @@ jobs:
4040

4141
- name: Build
4242
run: pnpm run build
43+
44+
- name: Publish (development)
45+
if: github.repository == 'RightCapitalHQ/php-parser' && github.base_ref == github.event.repository.default_branch
46+
env:
47+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
48+
run: |
49+
npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}"
50+
preid=$(sed -e s:/:-:g <<<${{ github.head_ref }}).${{ github.run_number }}.${{ github.run_attempt }}
51+
npm --no-git-tag-version version prerelease --preid="${preid}"
52+
pnpm publish --no-git-checks --access public --tag development
53+
54+
- name: Publish (main)
55+
if: github.repository == 'RightCapitalHQ/php-parser' && github.ref_name == github.event.repository.default_branch
56+
env:
57+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
58+
run: |
59+
npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}"
60+
git config --local user.email "[email protected]"
61+
git config --local user.name "GitHub Actions[bot]"
62+
pnpm beachball publish --access public --yes -m 'chore(release): applying package updates'

Diff for: beachball.config.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// @ts-check
2+
/** @type {import('beachball').BeachballConfig} */
3+
module.exports = {
4+
registry: 'https://registry.npmjs.org',
5+
ignorePatterns: [
6+
'.*ignore',
7+
'prettier.config.cjs',
8+
'.eslintrc.cjs',
9+
'jest.*.js',
10+
'.pnpm-store/**',
11+
'.vscode/**',
12+
'pnpm-lock.yaml',
13+
],
14+
changelog: {
15+
customRenderers: {
16+
renderHeader() {},
17+
renderChangeTypeHeader(changeType, renderInfo) {
18+
const changelogDate = renderInfo.newVersionChangelog.date
19+
.toLocaleDateString('zh-CN')
20+
.replace(/\//g, '-');
21+
const heading =
22+
changeType === 'major' || changeType === 'minor' ? '##' : '###';
23+
return `${heading} [${renderInfo.newVersionChangelog.version}](https://github.com/RightCapitalHQ/phpdoc-parser/tree/${renderInfo.newVersionChangelog.tag}) (${changelogDate})`;
24+
},
25+
// Original template: https://github.com/microsoft/beachball/blob/aefbc1ac37ee85961cc787133c827f1fd3925550/src/changelog/renderPackageChangelog.ts#L93
26+
renderEntry(entry) {
27+
if (entry.author === 'beachball') {
28+
return `- ${entry.comment}`;
29+
}
30+
// Imitate GitHub's commit format https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls#commit-shas
31+
return `- ${entry.comment} ([${entry.commit.substring(
32+
0,
33+
7,
34+
)}](https://github.com/RightCapitalHQ/phpdoc-parser/commit/${
35+
entry.commit
36+
}))`;
37+
},
38+
},
39+
},
40+
};

Diff for: package.json

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"scripts": {
77
"commit": "cz",
88
"clean": "tsc --build --clean ./tsconfig.build.json",
9+
"change": "beachball change --no-commit",
10+
"check": "beachball check",
911
"build": "pnpm run clean && tsc --project ./tsconfig.build.json",
1012
"eslint": "eslint --report-unused-disable-directives 'src/**/*.ts*'",
1113
"eslint:fix": "eslint --report-unused-disable-directives --fix 'src/**/*.ts*'",
@@ -49,6 +51,7 @@
4951
"@types/lodash": "4.14.198",
5052
"@types/mustache": "4.2.2",
5153
"@types/node": "20.6.0",
54+
"beachball": "2.37.0",
5255
"husky": "8.0.3"
5356
},
5457
"config": {

Diff for: pnpm-lock.yaml

+132
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)