Skip to content

Commit 6e934d0

Browse files
committed
バージョニングを自動化
参考: https://devblog.thebase.in/entry/automatic-release-on-github-actions master ブランチに push された際に限定し `.go` ファイルが更新された際にバージョニングを適宜行う処理を自動化します。 bump up version major
1 parent 1fa903b commit 6e934d0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: auto release demo
2+
on:
3+
push:
4+
# master ブランチにコミットがpushされたときに限定
5+
branches:
6+
- master
7+
paths:
8+
- '**.go'
9+
jobs:
10+
auto-release:
11+
runs-on: ubuntu-latest
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
RELEASE_IT_VERSION: 15.6.0
15+
steps:
16+
- name: Check out codes
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
- name: Setup Node
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: '19'
24+
- name: Set releaser settings
25+
run: |
26+
git config --global user.name kenzo0107
27+
git config --global user.email kenzo.tanaka0107@gmail.com
28+
- name: Major release
29+
id: major
30+
if: contains(toJSON(github.event.commits.*.message), 'bump up version major')
31+
run: npx release-it@${RELEASE_IT_VERSION} -- major --ci
32+
- name: Minor release
33+
id: minor
34+
# メジャーバージョンアップをしていないときマイナーバージョンアップを行なうか
35+
if: steps.major.conclusion == 'skipped' && contains(toJSON(github.event.commits.*.message), 'bump up version minor')
36+
run: npx release-it@${RELEASE_IT_VERSION} -- minor --ci
37+
- name: Patch release
38+
# コミットメッセージに特に指定がない場合はマイナーバージョンを更新する
39+
if: "!(steps.major.conclusion == 'success' || steps.minor.conclusion == 'success')"
40+
run: npx release-it@${RELEASE_IT_VERSION} -- patch --ci

0 commit comments

Comments
 (0)