Skip to content

Commit 9f98c4b

Browse files
committed
ci: add release workflow
1 parent ed26664 commit 9f98c4b

2 files changed

Lines changed: 97 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Library version. ex: x.x.x, x.x.x-SNAPSHOT'
8+
required: true
9+
module:
10+
description: 'Module to publish'
11+
required: true
12+
default: all
13+
type: choice
14+
options:
15+
- all
16+
- adventure
17+
- joml
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: write
25+
26+
jobs:
27+
release:
28+
name: Release
29+
runs-on: ubuntu-latest
30+
timeout-minutes: 3
31+
steps:
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
34+
with:
35+
distribution: "adopt"
36+
java-version: 21
37+
38+
- name: Setup Gradle
39+
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1
40+
41+
- name: Build
42+
run: ./gradlew build
43+
env:
44+
VERSION: ${{ github.event.inputs.version }}
45+
46+
- name: Upload a Build Artifact
47+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
48+
with:
49+
path: modules/**/build/libs/*.jar
50+
51+
- name: Publish to azisaba repo
52+
run: |
53+
if [ "${{ github.event.inputs.module }}" = "all" ]; then
54+
./gradlew \
55+
:modules:adventure:publish \
56+
:modules:joml:publish
57+
else
58+
./gradlew :modules:${{ github.event.inputs.module }}:publish
59+
fi
60+
env:
61+
VERSION: ${{ github.event.inputs.version }}
62+
REPO_USERNAME: ${{ secrets.REPO_USERNAME }}
63+
REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }}
64+
65+
- name: Create release
66+
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
67+
with:
68+
tag_name: ${{ github.event.inputs.version }}
69+
files: modules/**/build/libs/*.jar
70+
generate_release_notes: true

build.gradle.kts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = "net.azisaba.serialization"
10-
version = "1.0-SNAPSHOT"
10+
version = System.getenv("VERSION") ?: "0.0.0-SNAPSHOT"
1111

1212
val kotlinx = libs.kotlinx
1313

@@ -16,6 +16,7 @@ configure(subprojects.filter { it.childProjects.isEmpty() }) {
1616
version = rootProject.version
1717

1818
apply(plugin = "java-library")
19+
apply(plugin = "maven-publish")
1920
apply(plugin = "org.jetbrains.kotlin.jvm")
2021

2122
repositories {
@@ -34,4 +35,29 @@ configure(subprojects.filter { it.childProjects.isEmpty() }) {
3435
configure<JavaPluginExtension> {
3536
toolchain.languageVersion.set(JavaLanguageVersion.of(11))
3637
}
38+
39+
configure<PublishingExtension> {
40+
publications {
41+
create<MavenPublication>("mavenJava") {
42+
from(components["java"])
43+
groupId = group.toString()
44+
artifactId = project.name
45+
version = version.toString()
46+
}
47+
}
48+
repositories {
49+
maven {
50+
name = "azisaba"
51+
url = if (version.toString().contains("SNAPSHOT")) {
52+
uri("https://repo.azisaba.net/repository/maven-snapshots/")
53+
} else {
54+
uri("https://repo.azisaba.net/repository/maven-releases/")
55+
}
56+
credentials {
57+
username = System.getenv("REPO_USERNAME")
58+
password = System.getenv("REPO_PASSWORD")
59+
}
60+
}
61+
}
62+
}
3763
}

0 commit comments

Comments
 (0)