Enhance release workflow: enable publishing to GitHub Packages and integrate versioning from tags

This commit is contained in:
!verity
2026-03-13 20:47:19 +01:00
parent fee9d8533c
commit ac1e1f1ece
2 changed files with 33 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
# On push of a version tag (e.g. v1.0.0): build, create GitHub Release, upload JARs. # On push of a version tag (e.g. v1.0.0): build, publish to GitHub Packages, create Release, upload JARs.
name: Release name: Release
on: on:
@@ -8,10 +8,13 @@ on:
permissions: permissions:
contents: write contents: write
packages: write
jobs: jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ github.ref_name }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -23,7 +26,12 @@ jobs:
java-version: 21 java-version: 21
cache: gradle cache: gradle
- run: chmod +x gradlew && ./gradlew build --no-daemon - name: Strip v from version
run: echo "RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV
- run: chmod +x gradlew && ./gradlew build publish --no-daemon
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release - name: Create Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2

View File

@@ -2,15 +2,15 @@ plugins {
id("java") id("java")
id("java-library") id("java-library")
id("application") id("application")
id("maven-publish")
} }
tasks.named<JavaExec>("run") { tasks.named<JavaExec>("run") {
jvmArgs("-Ddev.jakub.terminal.ansi=true", "-Dfile.encoding=UTF-8") jvmArgs("-Ddev.jakub.terminal.ansi=true", "-Dfile.encoding=UTF-8")
} }
group = "dev.jakub.terminal" group = "dev.jakub.terminal"
version = "1.0-SNAPSHOT" version = System.getenv("RELEASE_VERSION") ?: "1.0-SNAPSHOT"
java { java {
sourceCompatibility = JavaVersion.VERSION_21 sourceCompatibility = JavaVersion.VERSION_21
@@ -29,4 +29,25 @@ dependencies {
tasks.test { tasks.test {
useJUnitPlatform() useJUnitPlatform()
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = "terminal-ui"
version = project.version.toString()
from(components["java"])
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/jakubbbdev/terminal-ui")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: project.findProperty("gpr.user")?.toString()
password = System.getenv("GITHUB_TOKEN") ?: project.findProperty("gpr.token")?.toString()
}
}
}
} }