refactor(build): decouple per-module versioning

Each module uses its own version property instead of a shared
artefactVersion, so changes to one module no longer force a
version bump across all modules. CI now supports per-module
release tags with the format <module>/v<version>.
This commit is contained in:
2026-05-29 16:20:27 +08:00
parent 3c71efeec8
commit 54e11c9b8b
9 changed files with 128 additions and 35 deletions
+88 -15
View File
@@ -1,11 +1,12 @@
# This workflow uses actions that are not certified by GitHub. # This workflow publishes one or all modules to Maven Central when a GitHub Release is published.
# They are provided by a third-party and are governed by #
# separate terms of service, privacy policy, and support # Supported release tag formats:
# documentation. # <module-name>/v<version> — publish a single module (e.g. tuple/v3.3.1)
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created # v<version> — publish all modules (e.g. v3.3.0, backward compat)
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle #
# Valid module names: common-toolbox, tuple, identity-generator, crypto-toolbox, math-toolbox, version-catalogue
name: Publish Packages to GitHub Packages with Gradle name: Publish Packages to Maven Central
on: on:
release: release:
@@ -13,7 +14,7 @@ on:
- published - published
jobs: jobs:
build: publish:
name: Build and Publish name: Build and Publish
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
@@ -24,6 +25,47 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4.2.2 uses: actions/checkout@v4.2.2
- name: Parse Release Tag
id: parse-tag
run: |
TAG="${{ github.event.release.tag_name }}"
echo "Release tag: ${TAG}"
# <module>/v<version> — single module
if [[ "${TAG}" =~ ^([a-z][a-z0-9-]*)/v?([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
MODULE="${BASH_REMATCH[1]}"
VERSION="${BASH_REMATCH[2]}"
case "${MODULE}" in
common-toolbox) PROP="commonToolboxVersion" ;;
tuple) PROP="tupleVersion" ;;
identity-generator) PROP="identityGeneratorVersion" ;;
crypto-toolbox) PROP="cryptoToolboxVersion" ;;
math-toolbox) PROP="mathToolboxVersion" ;;
version-catalogue) PROP="versionCatalogueVersion" ;;
*)
echo "::error::Unknown module: ${MODULE}"
echo "Valid modules: common-toolbox, tuple, identity-generator, crypto-toolbox, math-toolbox, version-catalogue"
exit 1
;;
esac
echo "module=${MODULE}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "gradle_property=${PROP}" >> $GITHUB_OUTPUT
echo "gradle_project=:${MODULE}" >> $GITHUB_OUTPUT
echo "single_module=true" >> $GITHUB_OUTPUT
echo "→ Publishing single module: ${MODULE} @ ${VERSION}"
# v<version> — all modules (backward compat)
else
VERSION="${TAG#v}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "single_module=false" >> $GITHUB_OUTPUT
echo "→ Publishing all modules @ ${VERSION}"
fi
- name: Setup GPG TTY - name: Setup GPG TTY
run: export GPG_TTY=$(tty) run: export GPG_TTY=$(tty)
@@ -61,19 +103,50 @@ jobs:
run: chmod +x ./gradlew run: chmod +x ./gradlew
- name: Build with Gradle - name: Build with Gradle
# Overwrite artefactVersion with tag name env:
run: ./gradlew build -PartefactVersion=${{ github.event.release.tag_name }} SINGLE: ${{ steps.parse-tag.outputs.single_module }}
PROJECT: ${{ steps.parse-tag.outputs.gradle_project }}
PROPERTY: ${{ steps.parse-tag.outputs.gradle_property }}
VERSION: ${{ steps.parse-tag.outputs.version }}
run: |
if [ "${SINGLE}" = "true" ]; then
./gradlew "${PROJECT}:build" "-P${PROPERTY}=${VERSION}"
else
./gradlew build \
-PcommonToolboxVersion="${VERSION}" \
-PtupleVersion="${VERSION}" \
-PidentityGeneratorVersion="${VERSION}" \
-PcryptoToolboxVersion="${VERSION}" \
-PmathToolboxVersion="${VERSION}" \
-PversionCatalogueVersion="${VERSION}"
fi
- name: List Output Items - name: List Output Items
run: ls -l ./**/build/libs run: ls -l ./**/build/libs
- name: Publish to Maven Central - name: Publish to Maven Central
run: ./gradlew publish env:
SINGLE: ${{ steps.parse-tag.outputs.single_module }}
PROJECT: ${{ steps.parse-tag.outputs.gradle_project }}
PROPERTY: ${{ steps.parse-tag.outputs.gradle_property }}
VERSION: ${{ steps.parse-tag.outputs.version }}
run: |
if [ "${SINGLE}" = "true" ]; then
./gradlew "${PROJECT}:publish" "-P${PROPERTY}=${VERSION}"
else
./gradlew publish \
-PcommonToolboxVersion="${VERSION}" \
-PtupleVersion="${VERSION}" \
-PidentityGeneratorVersion="${VERSION}" \
-PcryptoToolboxVersion="${VERSION}" \
-PmathToolboxVersion="${VERSION}" \
-PversionCatalogueVersion="${VERSION}"
fi
- name: Create Deployment on Central Publisher Portal - name: Create Deployment on Central Publisher Portal
run: | run: |
curl --fail -X 'POST' \ curl --fail -X 'POST' \
'https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.onixbyte?publishing_type=user_managed' \ 'https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.onixbyte?publishing_type=user_managed' \
-H 'accept: */*' \ -H 'accept: */*' \
-H 'Authorization: Bearer ${{ secrets.MAVEN_PORTAL_TOKEN }}' \ -H 'Authorization: Bearer ${{ secrets.MAVEN_PORTAL_TOKEN }}' \
-d '' -d ''
-3
View File
@@ -20,9 +20,6 @@
* SOFTWARE. * SOFTWARE.
*/ */
val artefactVersion: String by project
subprojects { subprojects {
group = "com.onixbyte" group = "com.onixbyte"
version = artefactVersion
} }
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing") id("signing")
} }
val artefactVersion: String by project val commonToolboxVersion: String by project
version = commonToolboxVersion
val projectUrl: String by project val projectUrl: String by project
val projectGithubUrl: String by project val projectGithubUrl: String by project
val licenseName: String by project val licenseName: String by project
@@ -70,7 +72,7 @@ publishing {
create<MavenPublication>("commonToolbox") { create<MavenPublication>("commonToolbox") {
groupId = group.toString() groupId = group.toString()
artifactId = "common-toolbox" artifactId = "common-toolbox"
version = artefactVersion version = commonToolboxVersion
pom { pom {
name = "OnixByte Common Toolbox" name = "OnixByte Common Toolbox"
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing") id("signing")
} }
val artefactVersion: String by project val cryptoToolboxVersion: String by project
version = cryptoToolboxVersion
val projectUrl: String by project val projectUrl: String by project
val projectGithubUrl: String by project val projectGithubUrl: String by project
val licenseName: String by project val licenseName: String by project
@@ -73,7 +75,7 @@ publishing {
create<MavenPublication>("cryptoToolbox") { create<MavenPublication>("cryptoToolbox") {
groupId = group.toString() groupId = group.toString()
artifactId = "crypto-toolbox" artifactId = "crypto-toolbox"
version = artefactVersion version = cryptoToolboxVersion
pom { pom {
name = "OnixByte Crypto Toolbox" name = "OnixByte Crypto Toolbox"
+6
View File
@@ -21,6 +21,12 @@
# #
artefactVersion=3.3.0 artefactVersion=3.3.0
commonToolboxVersion=3.3.0
tupleVersion=3.3.0
identityGeneratorVersion=3.3.0
cryptoToolboxVersion=3.3.0
mathToolboxVersion=3.3.0
versionCatalogueVersion=3.3.0
projectUrl=https://onixbyte.com/projects/onixbyte-toolbox projectUrl=https://onixbyte.com/projects/onixbyte-toolbox
projectGithubUrl=https://github.com/onixbyte/onixbyte-toolbox projectGithubUrl=https://github.com/onixbyte/onixbyte-toolbox
licenseName=MIT licenseName=MIT
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing") id("signing")
} }
val artefactVersion: String by project val identityGeneratorVersion: String by project
version = identityGeneratorVersion
val projectUrl: String by project val projectUrl: String by project
val projectGithubUrl: String by project val projectGithubUrl: String by project
val licenseName: String by project val licenseName: String by project
@@ -70,7 +72,7 @@ publishing {
create<MavenPublication>("identityGenerator") { create<MavenPublication>("identityGenerator") {
groupId = group.toString() groupId = group.toString()
artifactId = "identity-generator" artifactId = "identity-generator"
version = artefactVersion version = identityGeneratorVersion
pom { pom {
name = "OnixByte Identity Generator" name = "OnixByte Identity Generator"
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing") id("signing")
} }
val artefactVersion: String by project val mathToolboxVersion: String by project
version = mathToolboxVersion
val projectUrl: String by project val projectUrl: String by project
val projectGithubUrl: String by project val projectGithubUrl: String by project
val licenseName: String by project val licenseName: String by project
@@ -70,7 +72,7 @@ publishing {
create<MavenPublication>("mathToolbox") { create<MavenPublication>("mathToolbox") {
groupId = group.toString() groupId = group.toString()
artifactId = "math-toolbox" artifactId = "math-toolbox"
version = artefactVersion version = mathToolboxVersion
pom { pom {
name = "OnixByte Math Toolbox" name = "OnixByte Math Toolbox"
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing") id("signing")
} }
val artefactVersion: String by project val tupleVersion: String by project
version = tupleVersion
val projectUrl: String by project val projectUrl: String by project
val projectGithubUrl: String by project val projectGithubUrl: String by project
val licenseName: String by project val licenseName: String by project
@@ -70,7 +72,7 @@ publishing {
create<MavenPublication>("tuple") { create<MavenPublication>("tuple") {
groupId = group.toString() groupId = group.toString()
artifactId = "tuple" artifactId = "tuple"
version = artefactVersion version = tupleVersion
pom { pom {
name = "OnixByte Tuple" name = "OnixByte Tuple"
+14 -7
View File
@@ -28,7 +28,14 @@ plugins {
id("signing") id("signing")
} }
val artefactVersion: String by project val commonToolboxVersion: String by project
val identityGeneratorVersion: String by project
val cryptoToolboxVersion: String by project
val mathToolboxVersion: String by project
val tupleVersion: String by project
val versionCatalogueVersion: String by project
version = versionCatalogueVersion
val projectUrl: String by project val projectUrl: String by project
val projectGithubUrl: String by project val projectGithubUrl: String by project
val licenseName: String by project val licenseName: String by project
@@ -40,11 +47,11 @@ repositories {
dependencies { dependencies {
constraints { constraints {
api("com.onixbyte:common-toolbox:$artefactVersion") api("com.onixbyte:common-toolbox:$commonToolboxVersion")
api("com.onixbyte:identity-generator:$artefactVersion") api("com.onixbyte:identity-generator:$identityGeneratorVersion")
api("com.onixbyte:crypto-toolbox:$artefactVersion") api("com.onixbyte:crypto-toolbox:$cryptoToolboxVersion")
api("com.onixbyte:math-toolbox:$artefactVersion") api("com.onixbyte:math-toolbox:$mathToolboxVersion")
api("com.onixbyte:tuple:$artefactVersion") api("com.onixbyte:tuple:$tupleVersion")
} }
} }
@@ -53,7 +60,7 @@ publishing {
create<MavenPublication>("versionCatalogue") { create<MavenPublication>("versionCatalogue") {
groupId = group.toString() groupId = group.toString()
artifactId = "version-catalogue" artifactId = "version-catalogue"
version = artefactVersion version = versionCatalogueVersion
pom { pom {
name = "OnixByte Version Catalogue" name = "OnixByte Version Catalogue"