Skip to content

Commit bf16d60

Browse files
authored
ci(release): replace standard-version with semantic-release (#1666)
[`standard-version`](https://github.com/conventional-changelog/standard-version/) has been deprecated since May 2022, so it is necessary to stop using it for this project. [**`semantic-release`**](https://github.com/semantic-release/semantic-release) is available as a more capable alternative to help automate the release process: 1. Updating Node/Gem version numbers 2. Generating changelogs 3. Automating GitHub Releases 4. Building Chirpy-gem and pushing it to RubyGems.org 5. Create commits and tags on the `production` branch 6. Merge the `production` branch into the `master` branch > ⚠️ Note: Step _6_ may be canceled in CD environments due to merge conflicts, so we need to do this step manually in such cases. Whenever a commit is pushed to the release branch (`production`), all of the above release processes will be triggered.
1 parent 8c1be9f commit bf16d60

File tree

5 files changed

+193
-125
lines changed

5 files changed

+193
-125
lines changed

.github/workflows/cd.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
name: CD
2+
23
on:
34
push:
4-
tags:
5-
- "v[0-9]+.[0-9]+.[0-9]+"
65
branches:
7-
- docs
6+
- production
7+
tags-ignore:
8+
- "**"
89

910
jobs:
10-
launch:
11+
release:
12+
permissions:
13+
contents: write
14+
issues: write
15+
pull-requests: write
1116
runs-on: ubuntu-latest
1217
steps:
13-
- run: |
14-
curl -X POST -H "Accept: application/vnd.github+json" \
15-
-H "Authorization: Bearer ${{ secrets.GH_PAT }}" \
16-
https://api.github.com/repos/${{ secrets.BUILDER }}/dispatches \
17-
-d '{"event_type":"deploy", "client_payload":{"branch": "${{ github.ref_name }}"}}'
18+
- uses: actions/checkout@v4
19+
20+
- uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: 3.2
23+
bundler-cache: true
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: latest
28+
29+
- run: npm install
30+
- run: npx semantic-release
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
34+
35+
publish:
36+
needs: release
37+
uses: ./.github/workflows/publish.yml

.github/workflows/publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- docs
7+
workflow_call:
8+
9+
jobs:
10+
launch:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- run: |
14+
curl -X POST -H "Accept: application/vnd.github+json" \
15+
-H "Authorization: Bearer ${{ secrets.GH_PAT }}" \
16+
https://api.github.com/repos/${{ secrets.BUILDER }}/dispatches \
17+
-d '{"event_type":"deploy", "client_payload":{"branch": "${{ github.ref_name }}"}}'

docs/CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4-
53
## [6.5.5](https://github.com/cotes2020/jekyll-theme-chirpy/compare/v6.5.4...v6.5.5) (2024-03-23)
64

75
### Bug Fixes

package.json

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@
2828
"@commitlint/config-conventional": "^19.1.0",
2929
"@rollup/plugin-babel": "^6.0.4",
3030
"@rollup/plugin-terser": "^0.4.4",
31+
"@semantic-release/changelog": "^6.0.3",
32+
"@semantic-release/exec": "^6.0.3",
33+
"@semantic-release/git": "^10.0.1",
34+
"conventional-changelog-conventionalcommits": "^7.0.2",
3135
"husky": "^9.0.11",
3236
"rimraf": "^5.0.5",
3337
"rollup": "^4.13.2",
3438
"rollup-plugin-license": "^3.3.1",
39+
"semantic-release": "^23.0.8",
3540
"stylelint": "^16.3.1",
3641
"stylelint-config-standard-scss": "^13.0.0"
3742
},
@@ -89,24 +94,76 @@
8994
"media-feature-range-notation": "prefix"
9095
}
9196
},
92-
"standard-version": {
93-
"skip": {
94-
"commit": true,
95-
"tag": true
96-
},
97-
"types": [
98-
{
99-
"type": "feat",
100-
"section": "Features"
101-
},
102-
{
103-
"type": "fix",
104-
"section": "Bug Fixes"
105-
},
106-
{
107-
"type": "perf",
108-
"section": "Improvements"
109-
}
97+
"release": {
98+
"branches": [
99+
"production"
100+
],
101+
"plugins": [
102+
[
103+
"@semantic-release/commit-analyzer",
104+
{
105+
"preset": "conventionalcommits"
106+
}
107+
],
108+
[
109+
"@semantic-release/release-notes-generator",
110+
{
111+
"preset": "conventionalcommits",
112+
"presetConfig": {
113+
"types": [
114+
{
115+
"type": "feat",
116+
"section": "Features"
117+
},
118+
{
119+
"type": "fix",
120+
"section": "Bug Fixes"
121+
},
122+
{
123+
"type": "perf",
124+
"section": "Improvements"
125+
},
126+
{
127+
"type": "refactor",
128+
"section": "Changes",
129+
"hidden": true
130+
}
131+
]
132+
}
133+
}
134+
],
135+
[
136+
"@semantic-release/changelog",
137+
{
138+
"changelogFile": "docs/CHANGELOG.md",
139+
"changelogTitle": "# Changelog"
140+
}
141+
],
142+
[
143+
"@semantic-release/npm",
144+
{
145+
"npmPublish": false
146+
}
147+
],
148+
[
149+
"@semantic-release/exec",
150+
{
151+
"prepareCmd": "bash tools/release --prepare",
152+
"publishCmd": "bash tools/release"
153+
}
154+
],
155+
[
156+
"@semantic-release/git",
157+
{
158+
"assets": [
159+
"docs",
160+
"package.json",
161+
"*.gemspec"
162+
],
163+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
164+
}
165+
],
166+
"@semantic-release/github"
110167
]
111168
}
112169
}

0 commit comments

Comments
 (0)