Skip to content

Commit cc54b9e

Browse files
authored
ci(app): release version automatically
Merge commits below into one: * feat: add changelog generation and release workflow * chore: update release script to specify release version * chore: replace standard-version with commit-and-tag-version for release management
1 parent 317970e commit cc54b9e

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

.changelog-template.hbs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Changelog
2+
3+
{{#each releases}}
4+
## {{title}} ({{isoDate}})
5+
6+
{{#if merges}}
7+
### Merged
8+
{{#each merges}}
9+
- {{message}} ({{id}})
10+
{{/each}}
11+
{{/if}}
12+
13+
{{#if fixes}}
14+
### Fixed
15+
{{#each fixes}}
16+
- {{commit.subject}} ({{shorthash}})
17+
{{/each}}
18+
{{/if}}
19+
20+
{{#if commits}}
21+
### Commits
22+
{{#each commits}}
23+
- {{subject}} ({{shorthash}})
24+
{{/each}}
25+
{{/if}}
26+
27+
{{/each}}

.github/workflows/release.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # 仅在推送 v 开头的 tag 时触发
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v4
20+
21+
- name: Setup
22+
run: npm i -g @antfu/ni
23+
24+
- name: Install
25+
run: ni --no-frozen-lockfile
26+
27+
- name: Create Release
28+
id: create_release
29+
uses: actions/create-release@v1
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
tag_name: ${{ github.ref }}
34+
release_name: ${{ github.ref }}
35+
body_path: CHANGELOG.md # 直接指定文件路径
36+
draft: false
37+
prerelease: false

.versionrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"header": "# Changelog\n\n",
3+
"types": [
4+
{ "type": "feat", "section": "Features" },
5+
{ "type": "fix", "section": "Bug Fixes" },
6+
{ "type": "chore", "hidden": true }
7+
],
8+
"commitUrlFormat": "https://github.com/openbuildxyz/openbuild-frontend/commits/{{hash}}",
9+
"compareUrlFormat": "https://github.com/openbuildxyz/openbuild-frontend/compare/{{previousTag}}...{{currentTag}}",
10+
"issueUrlFormat": "https://github.com/openbuildxyz/openbuild-frontend/issues/{{id}}",
11+
"changelogFile": "CHANGELOG.md",
12+
"changelogTemplate": ".changelog-template.hbs"
13+
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"license": "node .knosys/scripts license add",
2424
"doc": "node .knosys/scripts site",
2525
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
26-
"prepare": "husky"
26+
"prepare": "husky",
27+
"release": "commit-and-tag-version --release-as $npm_config_release_as && git push --follow-tags origin test"
2728
},
2829
"dependencies": {
2930
"@bytemd/plugin-breaks": "^1.21.0",
@@ -129,6 +130,7 @@
129130
"@typescript-eslint/parser": "7.18.0",
130131
"astro": "4.16.7",
131132
"autoprefixer": "^10.4.12",
133+
"commit-and-tag-version": "12.5.0",
132134
"cross-env": "7.0.3",
133135
"daisyui": "4.12.10",
134136
"eslint": "^8.7.0",

0 commit comments

Comments
 (0)