Skip to content

Commit 60797c6

Browse files
authored
Merge pull request #8 from Chuseok22/20251023_#7_일반_프로젝트_버전_관리_기능_추가
20251023 #7 일반 프로젝트 버전 관리 기능 추가
2 parents 2b18135 + dca9702 commit 60797c6

9 files changed

Lines changed: 218 additions & 219 deletions

File tree

.github/workflows/auto-version.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ on:
6565
type: string
6666
default: "version-bumped"
6767

68+
# 일반 프로젝트 버전 파일 경로
69+
plain_version_file:
70+
description: "일반 프로젝트 버전 관리 파일 경로 - 기본: VERSION"
71+
required: false
72+
type: string
73+
default: "VERSION"
74+
6875
outputs:
6976
version_bumped:
7077
description: "버전 증가 여부 (true/false)"
@@ -99,6 +106,7 @@ jobs:
99106
bump_level: ${{ steps.bump.outputs.bump_level }}
100107
new_version: ${{ steps.bump.outputs.new_version }}
101108
new_tag: ${{ steps.bump.outputs.new_tag }}
109+
plain_version_file: ${{ inputs.plain_version_file }}
102110

103111
steps:
104112
- name: 코드 체크아웃
@@ -117,6 +125,7 @@ jobs:
117125
next_constants_path: ${{ inputs.next_constants_path }}
118126
sync_app_yaml: ${{ inputs.sync_app_yaml }}
119127
workdir: ${{ inputs.workdir }}
128+
plain_version_file: ${{ inputs.plain_version_file }}
120129

121130
# 버전 bump 시 repository_dispatch 전송
122131
- name: Send repository_dispatch (only when bumped)

README.en.md

Lines changed: 64 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,180 +1,77 @@
1-
# version-management
2-
3-
> **Centralized, reusable GitHub Actions workflow for automated versioning (Spring Boot & Next.js)**
4-
> On pushes to the default branch (`main`) with a compliant commit message, this project performs **Version bump → Project file sync → CHANGELOG update → Git Tag creation/push** in a standardized way.
5-
> It also emits a `repository_dispatch` event **only when a version bump actually happens**, so you can trigger follow‑up workflows (e.g., `apk-build.yml`) conditionally.
6-
7-
> **한국어 문서**[README.md](README.md)
8-
9-
---
10-
11-
## 🚀 Features
12-
13-
- **Two frameworks supported**
14-
- **Spring Boot (Gradle/Groovy)**: updates `version` in `build.gradle`, optionally replaces the `version:` key in `src/main/resources/application.yml`
15-
- **Next.js (TypeScript)**: updates `package.json.version` and creates/updates `src/constants/version.ts` (path is configurable)
16-
- **Commit‑driven versioning**
17-
- `version(major): ...`
18-
- `version(minor): ...`
19-
- `version(patch): ...`
20-
- **Policy guarantees**
21-
- Bump **only on the default branch (`main`)**
22-
- Detect current version in order: **Tag → Files → Default value**
23-
- `CHANGELOG.md` is **prepended at the top** (insert banner only once; subsequent entries accumulate **under** the banner)
24-
- Create & push **Git Tag** (`vX.Y.Z`) + push **release commit**
25-
Release commit message: `chore(release): vX.Y.Z {original subject description} [skip version]`
26-
- **No bump → workflow still succeeds** (handy for pipeline branching)
27-
- **Follow‑up workflow integration**
28-
- Sends `repository_dispatch` only when the version actually bumped (default event: `version-bumped`)
29-
- Payload: `new_version`, `new_tag`, `bump_level`, `sha`
30-
31-
---
32-
33-
## 📦 Repository layout
34-
35-
```
36-
version-management/
37-
├─ action.yml # Composite action entry (can be used directly)
38-
├─ scripts/
39-
│ ├─ compute-bump.mjs # Commit inspection + version calculation
40-
│ ├─ sync-files.mjs # File sync + commit
41-
│ ├─ update-changelog.mjs # CHANGELOG prepend (+ initial banner)
42-
│ └─ create-tag.mjs # Tag create/push + release commit handling
43-
└─ .github/
44-
└─ workflows/
45-
└─ auto-version.yml # Reusable workflow (workflow_call) orchestrator
46-
```
47-
> **Why split it like this?**
48-
> The **reusable workflow** handles pipeline orchestration (permissions, concurrency, dispatch), while the **composite action** bundles the actual logic (bump/file updates/changelog/tagging) so it can be reused anywhere.
49-
50-
---
51-
52-
## 🧭 Quick start (consumer repo)
53-
54-
### 1) Use the **reusable workflow** (recommended)
55-
56-
**Consumer repo**: `.github/workflows/version-management.yml`
57-
1+
# Release Notes — v1.0.0
2+
3+
**Tag:** `v1.0.0`
4+
**Summary:** Official **1.0** release of a centralized, reusable version‑management workflow for **Spring Boot · Next.js · Plain** projects. It performs commit‑driven SemVer bumps, project file synchronization, top‑prepended CHANGELOG updates, and Git tag creation/push in a consistent way. It also emits `repository_dispatch` **only when a bump occurs**, enabling conditional follow‑up pipelines.
5+
6+
## ✨ Highlights
7+
- **SemVer bump from commit subject**: `version(major|min|patch): {message}`
8+
- **Project file synchronization**
9+
- **Spring Boot**: update `version` in `build.gradle`; optionally update `version:` in `src/main/resources/application.yml`
10+
- **Next.js**: update `package.json.version`; create/replace `src/constants/version.ts` (configurable path); update `package-lock.json`
11+
- **Plain**: create/replace a **version file (`VERSION`)** so the file contains **only one line** with the new version
12+
- If missing → create file with `X.Y.Z`
13+
- If present → **overwrite entire content** with `X.Y.Z`
14+
- **Automatic CHANGELOG**
15+
- Prepend new section to the top
16+
- Insert a banner once; subsequent entries accumulate under the banner
17+
- **Git tagging**
18+
- Format: `vX.Y.Z`
19+
- Release commit message: `chore(release): vX.Y.Z {message} [skip version]`
20+
- **Follow‑up workflows**
21+
- Send `repository_dispatch` (default: `version-bumped`) **only when bumped**
22+
23+
## 🔧 Usage examples
24+
25+
### Reusable workflow (recommended)
5826
```yaml
59-
name: Version Management (from chuseok22/version-management)
60-
61-
on:
62-
push:
63-
branches: [ main ]
64-
workflow_dispatch:
65-
66-
permissions:
67-
contents: write
68-
actions: read
69-
7027
jobs:
7128
chuseok22-version-bump:
7229
uses: chuseok22/version-management/.github/workflows/auto-version.yml@v1
7330
with:
74-
project_type: "auto" # spring | next | auto
75-
default_branch: "main"
76-
tag_prefix: "v"
77-
default_version: "0.0.0"
78-
next_constants_path: "src/constants/version.ts" # for Next.js only
79-
sync_app_yaml: "false" # Spring application.yml version update
80-
workdir: "" # subdir in a monorepo, e.g., "backend"/"web"
81-
dispatch_on_bump: "true" # trigger follow-ups only when bumped
82-
dispatch_event_type: "version-bumped"
31+
project_type: auto # spring | next | plain | auto
32+
default_branch: main
33+
tag_prefix: v
34+
default_version: 0.0.0
35+
next_constants_path: src/constants/version.ts # Next.js only
36+
sync_app_yaml: false
37+
workdir: ""
38+
dispatch_on_bump: true
39+
dispatch_event_type: version-bumped
40+
plain_version_file: VERSION
8341
```
8442
85-
### 2) (Advanced) Use only the logic in an existing CI
86-
87-
Call the **composite action** directly inside your job:
88-
43+
### Composite action (logic only)
8944
```yaml
90-
jobs:
91-
some-job:
92-
runs-on: ubuntu-latest
93-
steps:
94-
- uses: actions/checkout@v4
95-
with: { fetch-depth: 0 }
96-
- uses: actions/setup-node@v4
97-
with: { node-version: 20 }
98-
99-
- name: Version bump only
100-
uses: chuseok22/version-management@v1
101-
with:
102-
project_type: auto
103-
default_branch: main
104-
tag_prefix: v
105-
default_version: 0.0.0
106-
next_constants_path: src/constants/version.ts
107-
sync_app_yaml: "false"
108-
workdir: ""
45+
- uses: actions/checkout@v4
46+
with: { fetch-depth: 0 }
47+
- uses: actions/setup-node@v4
48+
with: { node-version: 20 }
49+
- uses: chuseok22/version-management@v1
50+
with:
51+
project_type: auto
52+
default_branch: main
53+
tag_prefix: v
54+
default_version: 0.0.0
55+
next_constants_path: src/constants/version.ts
56+
sync_app_yaml: false
57+
workdir: ""
58+
plain_version_file: VERSION
10959
```
11060
111-
---
61+
## 🐛 Fixes & improvements
62+
- **Plain project support**: auto create/replace `VERSION` (keep only the new version line); new input `plain_version_file`
63+
- **Tag matching improved**: robust for **multi‑digit** segments like `v1.0.14`
64+
- **Auto detection**: `package.json` → **next**, `build.gradle` → **spring**, otherwise → **plain**
65+
- **Release commit normalization**: includes original subject description + always appends `[skip version]`
66+
- **CHANGELOG banner/header ordering**: banner pinned to the very top
11267

113-
## ✍️ Commit convention (required)
114-
115-
Version is determined **by the commit subject**:
116-
117-
- `version(major): message` → increase **MAJOR** (+1), reset MINOR/PATCH to 0
118-
- `version(minor): message` → increase **MINOR** (+1), reset PATCH to 0
119-
- `version(patch): message` → increase **PATCH** (+1)
120-
- Any other commit → **no bump** (workflow still succeeds)
121-
122-
Examples:
123-
```
124-
version(major): drop legacy API
125-
version(minor): add CSV export
126-
version(patch): fix null check
127-
```
128-
129-
---
130-
131-
## ⚙️ Inputs (overview)
132-
133-
**Reusable workflow** `.github/workflows/auto-version.yml` (`on: workflow_call`)
134-
135-
| Input | Default | Description |
136-
|---|---|---|
137-
| `project_type` | `auto` | `spring` \| `next` \| `auto` (auto-detect: `package.json` → next, `build.gradle` → spring) |
138-
| `default_branch` | `main` | Only bump on this branch |
139-
| `tag_prefix` | `v` | Tag prefix (e.g., `v1.2.3`) |
140-
| `default_version` | `0.0.0` | Seed version when no tag/file exists |
141-
| `next_constants_path` | `src/constants/version.ts` | Next.js constant file path |
142-
| `sync_app_yaml` | `false` | Update `version:` in Spring `src/main/resources/application.yml` if present |
143-
| `workdir` | `""` | Subdirectory in a monorepo (e.g., `backend`, `web`) |
144-
| `dispatch_on_bump` | `true` | Send `repository_dispatch` only when a bump occurred |
145-
| `dispatch_event_type` | `version-bumped` | Event type for follow-up workflows |
146-
147-
> The **composite action** (`action.yml`) accepts the same/similar inputs.
148-
149-
---
150-
151-
## 🧩 CHANGELOG policy
152-
153-
- On each release, **prepend** a new version section to the very top.
154-
- On first creation, insert the **banner once** (future entries are added **below** the banner).
155-
- The release commit message **always includes `[skip version]`** to prevent re-run loops.
156-
157-
Banner example:
158-
```
159-
<!-- vm-banner:start -->
160-
🔧 **Version Management Auto Change History**
161-
162-
This file is automatically generated and maintained by the centralized workflow (**Version Management**).
163-
Author: **Chuseok22** · https://github.com/Chuseok22
164-
Workflow repo: https://github.com/Chuseok22/version-management
165-
166-
※ Manual edits may be overwritten in future releases.
167-
<!-- vm-banner:end -->
168-
```
169-
170-
---
171-
172-
## 🔒 Requirements & permissions
68+
## ⚠️ Notes / limitations
69+
- Bump happens **only** on `default_branch` (default: `main`).
70+
Commits with `version(...)` on other branches are **skipped** (workflow succeeds).
71+
- When using the **composite action alone**, no `repository_dispatch` is sent.
72+
Use the **reusable workflow** if you need dispatch.
17373

74+
## ✅ Requirements
17475
- Runner: `ubuntu-latest`, Node: `20`
175-
- Permissions: `contents: write`
176-
- Checkout: `actions/checkout@v4` with `fetch-depth: 0` (tags/history required)
177-
178-
---
179-
180-
**Author: [Chuseok22](https://github.com/Chuseok22)** · Repo: https://github.com/Chuseok22/version-management
76+
- Permission: `contents: write`
77+
- Checkout: `actions/checkout@v4` with `fetch-depth: 0`

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# version-management
22

3-
> **GitHub Actions 기반 중앙 배포형 “자동 버전 관리” (Spring Boot & Next.js 지원)**
3+
> **GitHub Actions 기반 중앙 배포형 “자동 버전 관리” (Spring Boot · Next.js · Plain 지원)**
44
> 기본 브랜치(`main`)에서 규칙에 맞는 커밋이 푸시되면 **버전 증가 → 프로젝트 파일 동기화 → CHANGELOG 갱신 → Git Tag 생성/푸시**를 표준화된 방식으로 수행합니다.
55
> 또한 **버전이 실제로 증가했을 때만** `repository_dispatch` 이벤트를 보내 후속 워크플로우(예: `apk-build.yml`)를 조건부로 트리거합니다.
66
@@ -10,16 +10,24 @@
1010

1111
## 🚀 핵심 기능
1212

13-
- **두 프레임워크 지원**
14-
- **Spring Boot(Gradle Groovy)**: `build.gradle``version` 갱신, (옵션) `src/main/resources/application.yml``version:` 키 치환
15-
- **Next.js(TypeScript)**: `package.json.version` 갱신 + `src/constants/version.ts`(경로 커스터마이즈 가능) 생성/치환
13+
- **세 가지 프로젝트 타입 지원**
14+
- **Spring Boot (Gradle Groovy)**
15+
`build.gradle``version` 갱신, (옵션) `src/main/resources/application.yml``version:` 키 치환
16+
- **Next.js (TypeScript)**
17+
`package.json.version` 갱신 + `src/constants/version.ts`(경로 커스터마이즈 가능) 생성/치환 + `package-lock.json` 반영
18+
- **Plain (일반 프로젝트)**
19+
루트(또는 지정 경로)의 **버전 파일(`VERSION`)****생성/치환**하여 새 버전 **한 줄만** 유지
20+
· 파일이 없으면 생성 → `X.Y.Z
21+
` 작성
22+
· 파일이 있으면 **완전 덮어쓰기** → 최종적으로 `X.Y.Z` **한 줄만** 남김
1623
- **커밋 메시지로 버전 제어**
1724
- `version(major): ...`
1825
- `version(minor): ...`
1926
- `version(patch): ...`
2027
- **정책 보장**
2128
- **기본 브랜치(`main`)에서만** 버전 증가 처리
22-
- 태그 우선 → 파일 → 기본값 순으로 **현재 버전 인식**
29+
- 태그 우선 → 파일 → 기본값 순으로 **현재 버전 인식**
30+
· `auto` 탐지: `package.json`**next**, `build.gradle`**spring**, 그 외 → **plain**
2331
- `CHANGELOG.md`**상단 prepend** (최초 1회 배너 추가, 이후 배너 아래에 누적)
2432
- **Git Tag**(`vX.Y.Z`) 생성·푸시 + **릴리즈 커밋** 푸시
2533
릴리즈 커밋 메시지: `chore(release): vX.Y.Z {원본 커밋 설명} [skip version]`
@@ -37,7 +45,7 @@ version-management/
3745
├─ action.yml # 컴포지트 액션 엔트리 (직접 사용 가능)
3846
├─ scripts/
3947
│ ├─ compute-bump.mjs # 커밋 검사 + 버전 계산
40-
│ ├─ sync-files.mjs # 파일 동기화 + 커밋
48+
│ ├─ sync-files.mjs # 파일 동기화 + 커밋 (spring/next/plain)
4149
│ ├─ update-changelog.mjs # CHANGELOG prepend (+ 최초 배너)
4250
│ └─ create-tag.mjs # 태그 생성/푸시 + 릴리즈 커밋 정리
4351
└─ .github/
@@ -72,7 +80,7 @@ jobs:
7280
chuseok22-version-bump:
7381
uses: chuseok22/version-management/.github/workflows/auto-version.yml@v1
7482
with:
75-
project_type: "auto" # spring | next | auto
83+
project_type: "auto" # spring | next | plain | auto
7684
default_branch: "main"
7785
tag_prefix: "v"
7886
default_version: "0.0.0"
@@ -81,6 +89,7 @@ jobs:
8189
workdir: "" # 모노레포면 "backend"/"web" 등 하위 경로
8290
dispatch_on_bump: "true" # 버전 증가시에만 후속 트리거
8391
dispatch_event_type: "version-bumped"
92+
plain_version_file: "VERSION" # Plain 프로젝트일 때 버전 파일 경로
8493
```
8594
8695
### 2) (고급) 기존 CI에서 **로직만** 사용
@@ -107,6 +116,7 @@ jobs:
107116
next_constants_path: src/constants/version.ts
108117
sync_app_yaml: "false"
109118
workdir: ""
119+
plain_version_file: VERSION
110120
```
111121
112122
---
@@ -135,7 +145,7 @@ version(patch): fix null check
135145

136146
| 입력 | 기본값 | 설명 |
137147
|---|---|---|
138-
| `project_type` | `auto` | `spring` \| `next` \| `auto`(자동 탐지: `package.json` → next, `build.gradle` → spring) |
148+
| `project_type` | `auto` | `spring` \| `next` \| `plain` \| `auto`(자동 탐지: `package.json` → next, `build.gradle` → spring, 그 외 → plain) |
139149
| `default_branch` | `main` | 이 브랜치에서만 버전 증가 처리 |
140150
| `tag_prefix` | `v` | 태그 접두어 (예: `v1.2.3`) |
141151
| `default_version` | `0.0.0` | 최초 태그/파일 모두 없을 때 시드 버전 |
@@ -144,6 +154,7 @@ version(patch): fix null check
144154
| `workdir` | `""` | 모노레포 하위 경로 (예: `backend`, `web`) |
145155
| `dispatch_on_bump` | `true` | 버전 증가시에만 `repository_dispatch` 송신 |
146156
| `dispatch_event_type` | `version-bumped` | 후속 워크플로에서 수신할 이벤트 타입 |
157+
| `plain_version_file` | `VERSION` | **Plain** 프로젝트의 버전 파일 경로(없으면 생성, 있으면 내용 전체를 새 버전 한 줄로 치환) |
147158

148159
> **컴포지트 액션**(`action.yml`)도 동일/유사 입력을 받습니다.
149160

0 commit comments

Comments
 (0)