Skip to content

Commit 6922303

Browse files
knokmki612claude
andauthored
ci: migrate to trust publishing & publish when release is merged (#737)
* ci: migrate to trust publishing & publish when release is merged * website-boilerplate -> jumpu-ui * ci(release): restore concurrency group to prevent parallel runs Concurrent executions would overwrite the release branch and corrupt the version bump or the release PR. Restoring cancel-in-progress ensures only the latest run proceeds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: allow lerna version to run on alpha branch publish.yaml bumps the version from the alpha branch, but lerna.json only allowed the release branch. Adding alpha prevents lerna from rejecting the command during the alpha bump step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: simplify version flow diagram in RELEASING.md Removed the separate alpha.1 entry which implied alpha.0 and alpha.1 behave differently. Both are equally publishable via manual workflow_dispatch, so a single alpha entry is sufficient. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5ecb213 commit 6922303

File tree

9 files changed

+307
-133
lines changed

9 files changed

+307
-133
lines changed

.github/workflows/publish.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
id-token: write
13+
pull-requests: write
14+
15+
jobs:
16+
publish:
17+
if: >-
18+
github.event_name == 'workflow_dispatch' ||
19+
(github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'chore(release):'))
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- uses: tuqulore/.github/setup@main
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Configure git
27+
run: |
28+
git config --global user.name "${{ github.actor }}"
29+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
30+
31+
- name: Publish to npm
32+
run: pnpm packages:publish --yes
33+
env:
34+
NPM_CONFIG_PROVENANCE: true
35+
36+
- name: Create release tag
37+
run: |
38+
git checkout main
39+
git pull origin main
40+
VERSION=$(cat lerna.json | jq -r .version)
41+
git tag "v${VERSION}"
42+
git push origin "v${VERSION}"
43+
44+
- name: Create alpha branch and bump version
45+
run: |
46+
git checkout main
47+
git pull origin main
48+
git checkout -b alpha
49+
pnpm packages:bump-version prerelease --preid alpha --yes --no-git-tag-version
50+
git commit --all --message "chore(alpha): v$(cat lerna.json | jq -r .version)"
51+
git push -f origin alpha
52+
53+
- name: Create alpha pull request
54+
run: |
55+
VERSION=$(cat lerna.json | jq -r .version)
56+
gh pr create \
57+
--base main \
58+
--title "chore(alpha): v${VERSION}" \
59+
--body "Bump to alpha version v${VERSION}"
60+
env:
61+
GH_TOKEN: ${{ github.token }}
62+
63+
- name: Cleanup alpha branch on failure
64+
if: failure()
65+
run: git push origin :alpha

.github/workflows/release.yaml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,51 @@
11
name: Release
22
on:
3-
release:
4-
types: [created]
3+
workflow_dispatch:
4+
inputs:
5+
semver:
6+
description: next semantic version(s) value
7+
default: patch
8+
type: choice
9+
options:
10+
- patch
11+
- minor
12+
- major
13+
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
518
jobs:
619
release:
720
runs-on: ubuntu-24.04
821
concurrency:
922
group: release
1023
cancel-in-progress: true
1124
steps:
12-
- uses: tuqulore/.github/setup@80f9e99c22e033871e7f972d24d666b057fdfecf # main
13-
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
25+
- uses: tuqulore/.github/setup@main
26+
27+
- name: Configure git
28+
run: |
29+
git config --global user.name "${{ github.actor }}"
30+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
31+
32+
- name: Create release branch and bump version
33+
run: |
34+
git checkout -b release
35+
pnpm packages:bump-version ${{ inputs.semver }} --yes --no-git-tag-version
36+
VERSION=$(cat lerna.json | jq -r .version)
37+
git commit --all --message "chore(release): v${VERSION}"
38+
git push -f origin release
39+
40+
- name: Create pull request
41+
run: |
42+
VERSION=$(cat lerna.json | jq -r .version)
43+
gh pr create \
44+
--base main \
45+
--title "chore(release): v${VERSION}" \
46+
--body "Release v${VERSION}"
1447
env:
15-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
16-
- run: pnpm release --yes
48+
GH_TOKEN: ${{ github.token }}
49+
50+
- if: failure()
51+
run: git push origin :release

.github/workflows/versionup.yaml

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

RELEASE_GUIDE.md

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

RELEASING.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# リリースガイド
2+
3+
このドキュメントでは、パッケージのリリース手順を説明します。
4+
5+
## 概要
6+
7+
このリポジトリでは2段階のワークフローでリリースを管理しています:
8+
9+
- **release.yaml**: 正式リリース用(手動実行)
10+
- **publish.yaml**: npm公開用(自動実行 + 手動実行)
11+
12+
## バージョン管理の流れ
13+
14+
```
15+
正式リリース (3.0.1)
16+
17+
alpha開発版 (3.0.2-alpha.0) ← 手動でpublish可能
18+
19+
正式リリース (3.0.2)
20+
```
21+
22+
## 操作一覧
23+
24+
| やりたいこと | 操作 |
25+
| --------------------- | --------------------------------------- |
26+
| 正式リリース | release.yaml を手動実行 → PRマージ |
27+
| alphaバージョンに更新 | alpha PRをマージ(npmには公開されない) |
28+
| alphaをnpmに公開 | publish.yaml を手動実行 |
29+
30+
## 正式リリースの手順
31+
32+
### 1. release.yaml を実行
33+
34+
1. GitHub Actions の [release.yaml](https://github.com/tuqulore/jumpu-ui/actions/workflows/release.yaml) を開く
35+
2. 「Run workflow」をクリック
36+
3. semver(`patch` / `minor` / `major`)を選択
37+
4. 「Run workflow」を実行
38+
39+
これにより、以下が自動的に行われます:
40+
41+
- releaseブランチが作成される
42+
- 指定したsemverでバージョンがバンプされる
43+
- リリースPR(`chore(release): vX.X.X`)が作成される
44+
45+
### 2. リリースPRをマージ
46+
47+
PRをレビューし、マージします。
48+
49+
マージすると、publish.yaml が自動的に実行され:
50+
51+
- npmにパッケージが公開される
52+
- リリースタグ(`vX.X.X`)が作成される
53+
- 次のalphaバージョンにバンプされる
54+
- alpha PR(`chore(alpha): vX.X.X-alpha.0`)が作成される
55+
56+
### 3. alpha PRをマージ
57+
58+
alpha PRをマージして、mainブランチをalphaバージョンに更新します。
59+
60+
**この時点ではnpmには公開されません。**
61+
62+
## alpha版の公開手順
63+
64+
開発中にalpha版をnpmに公開したい場合:
65+
66+
### 1. publish.yaml を手動実行
67+
68+
1. GitHub Actions の [publish.yaml](https://github.com/tuqulore/jumpu-ui/actions/workflows/publish.yaml) を開く
69+
2. 「Run workflow」をクリック
70+
3. 「Run workflow」を実行
71+
72+
これにより、以下が自動的に行われます:
73+
74+
- 現在のalphaバージョンがnpmに公開される
75+
- alphaタグ(`vX.X.X-alpha.N`)が作成される
76+
- 次のalphaバージョンにバンプされる
77+
- 新しいalpha PR(`chore(alpha): vX.X.X-alpha.N+1`)が作成される
78+
79+
### 2. alpha PRをマージ
80+
81+
alpha PRをマージして、mainブランチを次のalphaバージョンに更新します。
82+
83+
## 運用例
84+
85+
### シナリオ: v3.0.0 から開発を始める場合
86+
87+
```
88+
main: 3.0.0
89+
90+
① release.yaml 実行 (patch)
91+
→ リリースPR: "chore(release): v3.0.1"
92+
93+
② リリースPRマージ
94+
→ npm publish (3.0.1)
95+
→ タグ: v3.0.1
96+
→ alpha PR: "chore(alpha): v3.0.2-alpha.0"
97+
98+
③ alpha PRマージ(npmには公開されない)
99+
→ main: 3.0.2-alpha.0
100+
101+
... 開発期間 ...
102+
103+
④ publish.yaml 手動実行
104+
→ npm publish (3.0.2-alpha.0)
105+
→ タグ: v3.0.2-alpha.0
106+
→ alpha PR: "chore(alpha): v3.0.2-alpha.1"
107+
108+
⑤ alpha PRマージ(npmには公開されない)
109+
→ main: 3.0.2-alpha.1
110+
111+
... 開発続行 ...
112+
113+
⑥ release.yaml 実行 (patch)
114+
→ リリースPR: "chore(release): v3.0.2"
115+
116+
⑦ リリースPRマージ
117+
→ npm publish (3.0.2)
118+
→ タグ: v3.0.2
119+
→ alpha PR: "chore(alpha): v3.0.3-alpha.0"
120+
121+
...
122+
```
123+
124+
## 注意事項
125+
126+
### Trusted Publishing
127+
128+
このリポジトリではnpmのTrusted Publishingを使用しています。npmトークンは不要で、GitHub ActionsのOIDC認証によりパッケージを公開します。
129+
130+
npmjs.comで各パッケージにTrusted Publisherを設定する必要があります:
131+
132+
- Organization/User: `tuqulore`
133+
- Repository: `jumpu-ui`
134+
- Workflow filename: `publish.yaml`
135+
136+
### alpha PRの取り扱い
137+
138+
- alpha PRは**すぐにマージ**してください(長期間放置しない)
139+
- alpha PRをマージしても、npmには公開されません
140+
- alphaを公開したい場合のみ、publish.yaml を手動実行してください
141+
142+
### 正式リリース時の注意
143+
144+
正式リリース(release.yaml)を実行する前に、既存のalpha PRがある場合はクローズまたは削除してください。

lerna.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
},
1313
"version": {
1414
"allowBranch": [
15-
"release"
15+
"release",
16+
"alpha"
1617
],
1718
"noChangelog": true
1819
}

0 commit comments

Comments
 (0)