Skip to content

Commit 91875e8

Browse files
committed
chore: version control fix
1 parent 78c915b commit 91875e8

File tree

8 files changed

+52
-39
lines changed

8 files changed

+52
-39
lines changed

.github/workflows/release-jitpack.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ permissions:
55

66
on:
77
push:
8-
branches: [ main ]
8+
tags: [ 'v*' ]
99

1010
jobs:
1111
test:
@@ -90,6 +90,7 @@ jobs:
9090
release:
9191
runs-on: ubuntu-latest
9292
needs: [test, jitpack-compatibility]
93+
if: startsWith(github.ref, 'refs/tags/v')
9394

9495
steps:
9596
- name: Check deploy token
@@ -99,7 +100,6 @@ jobs:
99100
exit 1
100101
fi
101102
echo "DEPLOY_TOKEN is available. Proceeding with release."
102-
103103
- name: Checkout repository
104104
uses: actions/checkout@v4
105105
with:
@@ -124,32 +124,24 @@ jobs:
124124
- name: Make gradlew executable
125125
run: chmod +x ./gradlew
126126

127-
- name: Final build for release
128-
run: ./gradlew build
129-
130-
- name: Generate version tag
127+
- name: Extract version from tag
131128
id: version
132129
run: |
133-
VERSION="v0.1.0-$(date +%Y%m%d-%H%M%S)"
134-
echo "tag=$VERSION" >> $GITHUB_OUTPUT
135-
echo "Generated tag: $VERSION"
130+
TAG=${GITHUB_REF#refs/tags/}
131+
VERSION=${TAG#v}
132+
echo "tag=$TAG" >> $GITHUB_OUTPUT
133+
echo "version=$VERSION" >> $GITHUB_OUTPUT
136134
137-
- name: Create and push tag
138-
run: |
139-
TAG="${{ steps.version.outputs.tag }}"
140-
echo "Creating release tag: $TAG"
141-
git config user.name "github-actions[bot]"
142-
git config user.email "github-actions[bot]@users.noreply.github.com"
143-
git tag "$TAG"
144-
git push origin "$TAG"
135+
- name: Final build for release
136+
run: ./gradlew build
145137

146138
- name: Create GitHub Release
147139
uses: softprops/action-gh-release@v1
148140
with:
149141
tag_name: ${{ steps.version.outputs.tag }}
150142
name: "Release ${{ steps.version.outputs.tag }}"
151143
body: |
152-
🚀 자동 생성 릴리스: ${{ steps.version.outputs.tag }}
144+
🚀 릴리스: ${{ steps.version.outputs.tag }}
153145
154146
## JitPack 사용법
155147
@@ -160,7 +152,7 @@ jobs:
160152
}
161153
162154
dependencies {
163-
implementation 'com.github.hj4645:commit-chronicle:${{ steps.version.outputs.tag }}'
155+
implementation 'com.github.hj4645:commit-chronicle:${{ steps.version.outputs.version }}'
164156
}
165157
```
166158
@@ -177,15 +169,15 @@ jobs:
177169
<dependency>
178170
<groupId>com.github.hj4645</groupId>
179171
<artifactId>commit-chronicle</artifactId>
180-
<version>${{ steps.version.outputs.tag }}</version>
172+
<version>${{ steps.version.outputs.version }}</version>
181173
</dependency>
182174
</dependencies>
183175
```
184176
185177
## CLI 사용법
186178
```bash
187179
# alias 설정
188-
alias cch="java -jar ~/.gradle/caches/modules-2/files-2.1/com.github.hj4645/commit-chronicle/${{ steps.version.outputs.tag }}/*/commitchronicle-0.1.0.jar"
180+
alias cch="java -jar ~/.gradle/caches/modules-2/files-2.1/com.github.hj4645/commit-chronicle/${{ steps.version.outputs.version }}/*/commitchronicle-${{ steps.version.outputs.version }}.jar"
189181
190182
# 사용
191183
cch summarize

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories {
3434
}
3535

3636
dependencies {
37-
implementation("com.github.hj4645:commit-chronicle:v0.1.0")
37+
implementation("com.github.hj4645:commit-chronicle:1.0.0")
3838
}
3939
```
4040

@@ -52,7 +52,7 @@ dependencies {
5252
<dependency>
5353
<groupId>com.github.hj4645</groupId>
5454
<artifactId>commit-chronicle</artifactId>
55-
<version>v0.1.0</version>
55+
<version>1.0.0</version>
5656
</dependency>
5757
</dependencies>
5858
```
@@ -65,13 +65,13 @@ dependencies {
6565

6666
```bash
6767
# Gradle 캐시에서 JAR 파일 경로 확인
68-
find ~/.gradle/caches -name "commitchronicle-0.1.0.jar" -type f
68+
find ~/.gradle/caches -name "commitchronicle-1.0.0.jar" -type f
6969

7070
# alias 설정 (예시 - 실제 경로로 수정 필요)
71-
alias cch="java -jar ~/.gradle/caches/modules-2/files-2.1/com.github.hj4645/commit-chronicle/v0.1.0/*/commitchronicle-0.1.0.jar"
71+
alias cch="java -jar ~/.gradle/caches/modules-2/files-2.1/com.github.hj4645/commit-chronicle/1.0.0/*/commitchronicle-1.0.0.jar"
7272

7373
# 또는 직접 다운로드한 JAR 파일 사용
74-
alias cch="java -jar /path/to/commitchronicle-0.1.0.jar"
74+
alias cch="java -jar /path/to/commitchronicle-1.0.0.jar"
7575
```
7676

7777
### 2. 초기 설정

README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories {
3434
}
3535

3636
dependencies {
37-
implementation("com.github.hj4645:commit-chronicle:v0.1.0")
37+
implementation("com.github.hj4645:commit-chronicle:1.0.0")
3838
}
3939
```
4040

@@ -52,7 +52,7 @@ dependencies {
5252
<dependency>
5353
<groupId>com.github.hj4645</groupId>
5454
<artifactId>commit-chronicle</artifactId>
55-
<version>v0.1.0</version>
55+
<version>1.0.0</version>
5656
</dependency>
5757
</dependencies>
5858
```
@@ -68,7 +68,7 @@ After adding the library as a dependency, you can set up an alias to use it as C
6868
find ~/.gradle/caches -name "commitchronicle-0.1.0.jar" -type f
6969

7070
# Set up alias (example - modify with actual path)
71-
alias cch="java -jar ~/.gradle/caches/modules-2/files-2.1/com.github.hj4645/commit-chronicle/v0.1.0/*/commitchronicle-0.1.0.jar"
71+
alias cch="java -jar ~/.gradle/caches/modules-2/files-2.1/com.github.hj4645/commit-chronicle/1.0.0/*/commitchronicle-1.0.0.jar"
7272

7373
# Or use directly downloaded JAR file
7474
alias cch="java -jar /path/to/commitchronicle-0.1.0.jar"

README_JA.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories {
3434
}
3535

3636
dependencies {
37-
implementation("com.github.hj4645:commit-chronicle:v0.1.0")
37+
implementation("com.github.hj4645:commit-chronicle:1.0.0")
3838
}
3939
```
4040

@@ -52,7 +52,7 @@ dependencies {
5252
<dependency>
5353
<groupId>com.github.hj4645</groupId>
5454
<artifactId>commit-chronicle</artifactId>
55-
<version>v0.1.0</version>
55+
<version>1.0.0</version>
5656
</dependency>
5757
</dependencies>
5858
```

README_ZH.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories {
3434
}
3535

3636
dependencies {
37-
implementation("com.github.hj4645:commit-chronicle:v0.1.0")
37+
implementation("com.github.hj4645:commit-chronicle:1.0.0")
3838
}
3939
```
4040

@@ -52,7 +52,7 @@ dependencies {
5252
<dependency>
5353
<groupId>com.github.hj4645</groupId>
5454
<artifactId>commit-chronicle</artifactId>
55-
<version>v0.1.0</version>
55+
<version>1.0.0</version>
5656
</dependency>
5757
</dependencies>
5858
```

build.gradle.kts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1+
import java.util.Properties
2+
13
plugins {
24
kotlin("jvm") version "2.1.0" apply false
35
kotlin("plugin.serialization") version "2.1.0" apply false
46
}
57

8+
// Git 태그에서 버전 추출 또는 SNAPSHOT 사용
9+
fun getProjectVersion(): String {
10+
return try {
11+
val process = ProcessBuilder("git", "describe", "--tags", "--exact-match", "HEAD")
12+
.directory(rootDir)
13+
.start()
14+
15+
if (process.waitFor() == 0) {
16+
// 정확한 태그가 있는 경우 (v1.0.0 → 1.0.0)
17+
process.inputStream.bufferedReader().readText().trim().removePrefix("v")
18+
} else {
19+
// 태그가 없는 경우 SNAPSHOT
20+
"1.0.0-SNAPSHOT"
21+
}
22+
} catch (e: Exception) {
23+
"1.0.0-SNAPSHOT"
24+
}
25+
}
26+
627
allprojects {
728
group = "com.commitchronicle"
8-
version = "0.1.0"
29+
version = getProjectVersion()
930

1031
repositories {
1132
mavenCentral()

cli/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies {
1818
tasks {
1919
shadowJar {
2020
archiveBaseName.set("commitchronicle")
21-
archiveVersion.set("0.1.0")
21+
archiveVersion.set(project.version.toString())
2222
archiveClassifier.set("")
2323
manifest {
2424
attributes["Main-Class"] = "com.commitchronicle.cli.MainKt"
@@ -54,7 +54,7 @@ publishing {
5454

5555
groupId = "com.github.hj4645"
5656
artifactId = "commit-chronicle"
57-
version = "0.1.0"
57+
version = project.version.toString()
5858

5959
pom {
6060
name.set("Commit Chronicle")
@@ -91,7 +91,7 @@ publishing {
9191
connection.set("scm:git:git://github.com/hj4645/commit-chronicle.git")
9292
developerConnection.set("scm:git:ssh://git@github.com:hj4645/commit-chronicle.git")
9393
url.set("https://github.com/hj4645/commit-chronicle")
94-
tag.set("v0.1.0")
94+
tag.set("v${project.version}")
9595
}
9696

9797
issueManagement {

cli/src/main/kotlin/com/commitchronicle/cli/Main.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class Settings : CliktCommand(
306306
val daysInput = readLine()
307307
val newDays = if (daysInput.isNullOrEmpty()) {
308308
updatedConfig.defaultDays
309-
} else {
309+
} else {
310310
daysInput.toIntOrNull()?.takeIf { it > 0 } ?: run {
311311
println("Invalid input. Keeping current value: ${updatedConfig.defaultDays}")
312312
updatedConfig.defaultDays
@@ -318,7 +318,7 @@ class Settings : CliktCommand(
318318
val limitInput = readLine()
319319
val newLimit = if (limitInput.isNullOrEmpty()) {
320320
updatedConfig.defaultLimit
321-
} else {
321+
} else {
322322
limitInput.toIntOrNull()?.takeIf { it > 0 } ?: run {
323323
println("Invalid input. Keeping current value: ${updatedConfig.defaultLimit}")
324324
updatedConfig.defaultLimit

0 commit comments

Comments
 (0)