Skip to content

Commit a8ed32a

Browse files
committed
add release pipeline
1 parent 0448acb commit a8ed32a

File tree

5 files changed

+215
-105
lines changed

5 files changed

+215
-105
lines changed

.axion.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Axion Release Plugin configuration
2+
versionCreator: versionWithBranch
3+
4+
# Version format
5+
tag:
6+
prefix: 'v'
7+
versionSeparator: ''
8+
9+
# Semantic versioning
10+
versionIncrementer: incrementMinor
11+
12+
# Branch rules
13+
branchVersionCreators:
14+
main:
15+
versionIncrementer: incrementPatch
16+
develop:
17+
versionIncrementer: incrementMinor
18+
19+
# Ignore certain files for version bumps
20+
checks:
21+
uncommittedChanges: false
22+
aheadOfRemote: false

.github/workflows/release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Fetch all history for proper versioning
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Set up JDK 21
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
cache: gradle
29+
30+
- name: Configure Git
31+
run: |
32+
git config user.name "github-actions[bot]"
33+
git config user.email "github-actions[bot]@users.noreply.github.com"
34+
35+
- name: Grant execute permission for gradlew
36+
run: chmod +x gradlew
37+
38+
- name: Get current version
39+
id: version
40+
run: |
41+
VERSION=$(./gradlew currentVersion -q -Prelease.quiet | tail -1)
42+
echo "version=$VERSION" >> $GITHUB_OUTPUT
43+
echo "Current version: $VERSION"
44+
45+
- name: Build and test
46+
run: ./gradlew clean build
47+
48+
- name: Create release tag
49+
run: |
50+
./gradlew release -Prelease.quiet
51+
52+
- name: Push tags
53+
run: git push --tags
54+
55+
- name: Build JAR for release
56+
run: ./gradlew jar
57+
58+
- name: Create GitHub Release
59+
uses: softprops/action-gh-release@v1
60+
with:
61+
tag_name: v${{ steps.version.outputs.version }}
62+
name: Release v${{ steps.version.outputs.version }}
63+
body: |
64+
## Changes in this release
65+
66+
See the [CHANGELOG](https://github.com/drag0sd0g/kafka-csv-loader/compare/v${{ steps.version.outputs.version }}...main) for details.
67+
68+
## Installation
69+
70+
Download the JAR file below and run:
71+
```bash
72+
java -jar kafka-csv-loader-${{ steps.version.outputs.version }}.jar --help
73+
```
74+
files: |
75+
build/libs/kafka-csv-loader-*.jar
76+
draft: false
77+
prerelease: false
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ plugins {
66
id("com.github.davidmc24.gradle.plugin.avro") version "1.9.1"
77
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
88
jacoco
9+
id("pl.allegro.tech.build.axion-release") version "1.17.0"
910
}
1011

1112
group = "com.dragos"
12-
version = "0.1.0-SNAPSHOT"
13+
version = scmVersion.version
1314

1415
repositories {
1516
mavenCentral()
@@ -85,6 +86,7 @@ tasks.withType<Test> {
8586
tasks.jar {
8687
manifest {
8788
attributes["Main-Class"] = "com.dragos.kafkacsvloader.MainKt"
89+
attributes["Implementation-Version"] = version
8890
}
8991
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
9092
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })

src/main/kotlin/com/dragos/kafkacsvloader/Main.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class KafkaCsvLoaderCommand : CliktCommand(
2121
name = "kafka-csv-loader",
2222
help = "Load CSV data into Kafka with Avro schema validation",
2323
) {
24+
init {
25+
versionOption(version = getVersion())
26+
}
27+
2428
private val csvFile by option("--csv", "-c", help = "Path to CSV file").required()
2529
private val schemaFile by option("--schema", "-s", help = "Path to Avro schema file (.avsc)").required()
2630
private val topic by option("--topic", "-t", help = "Kafka topic name").required()
@@ -149,6 +153,10 @@ class KafkaCsvLoaderCommand : CliktCommand(
149153
exitProcess(1)
150154
}
151155
}
156+
157+
private fun getVersion(): String {
158+
return this::class.java.`package`.implementationVersion ?: "development"
159+
}
152160
}
153161

154162
fun main(args: Array<String>) = KafkaCsvLoaderCommand().main(args)

0 commit comments

Comments
 (0)