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.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
# This workflow publishes one or all modules to Maven Central when a GitHub Release is published.
#
# Supported release tag formats:
# <module-name>/v<version> — publish a single module (e.g. tuple/v3.3.1)
# v<version> — publish all modules (e.g. v3.3.0, backward compat)
#
# 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:
release:
@@ -13,7 +14,7 @@ on:
- published
jobs:
build:
publish:
name: Build and Publish
runs-on: ubuntu-latest
permissions:
@@ -24,6 +25,47 @@ jobs:
- name: Checkout
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
run: export GPG_TTY=$(tty)
@@ -61,19 +103,50 @@ jobs:
run: chmod +x ./gradlew
- name: Build with Gradle
# Overwrite artefactVersion with tag name
run: ./gradlew build -PartefactVersion=${{ github.event.release.tag_name }}
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}:build" "-P${PROPERTY}=${VERSION}"
else
./gradlew build \
-PcommonToolboxVersion="${VERSION}" \
-PtupleVersion="${VERSION}" \
-PidentityGeneratorVersion="${VERSION}" \
-PcryptoToolboxVersion="${VERSION}" \
-PmathToolboxVersion="${VERSION}" \
-PversionCatalogueVersion="${VERSION}"
fi
- name: List Output Items
run: ls -l ./**/build/libs
- 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
run: |
curl --fail -X 'POST' \
'https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.onixbyte?publishing_type=user_managed' \
-H 'accept: */*' \
-H 'Authorization: Bearer ${{ secrets.MAVEN_PORTAL_TOKEN }}' \
-d ''
'https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.onixbyte?publishing_type=user_managed' \
-H 'accept: */*' \
-H 'Authorization: Bearer ${{ secrets.MAVEN_PORTAL_TOKEN }}' \
-d ''
-3
View File
@@ -20,9 +20,6 @@
* SOFTWARE.
*/
val artefactVersion: String by project
subprojects {
group = "com.onixbyte"
version = artefactVersion
}
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing")
}
val artefactVersion: String by project
val commonToolboxVersion: String by project
version = commonToolboxVersion
val projectUrl: String by project
val projectGithubUrl: String by project
val licenseName: String by project
@@ -70,7 +72,7 @@ publishing {
create<MavenPublication>("commonToolbox") {
groupId = group.toString()
artifactId = "common-toolbox"
version = artefactVersion
version = commonToolboxVersion
pom {
name = "OnixByte Common Toolbox"
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing")
}
val artefactVersion: String by project
val cryptoToolboxVersion: String by project
version = cryptoToolboxVersion
val projectUrl: String by project
val projectGithubUrl: String by project
val licenseName: String by project
@@ -73,7 +75,7 @@ publishing {
create<MavenPublication>("cryptoToolbox") {
groupId = group.toString()
artifactId = "crypto-toolbox"
version = artefactVersion
version = cryptoToolboxVersion
pom {
name = "OnixByte Crypto Toolbox"
+6
View File
@@ -21,6 +21,12 @@
#
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
projectGithubUrl=https://github.com/onixbyte/onixbyte-toolbox
licenseName=MIT
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing")
}
val artefactVersion: String by project
val identityGeneratorVersion: String by project
version = identityGeneratorVersion
val projectUrl: String by project
val projectGithubUrl: String by project
val licenseName: String by project
@@ -70,7 +72,7 @@ publishing {
create<MavenPublication>("identityGenerator") {
groupId = group.toString()
artifactId = "identity-generator"
version = artefactVersion
version = identityGeneratorVersion
pom {
name = "OnixByte Identity Generator"
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing")
}
val artefactVersion: String by project
val mathToolboxVersion: String by project
version = mathToolboxVersion
val projectUrl: String by project
val projectGithubUrl: String by project
val licenseName: String by project
@@ -70,7 +72,7 @@ publishing {
create<MavenPublication>("mathToolbox") {
groupId = group.toString()
artifactId = "math-toolbox"
version = artefactVersion
version = mathToolboxVersion
pom {
name = "OnixByte Math Toolbox"
+4 -2
View File
@@ -29,7 +29,9 @@ plugins {
id("signing")
}
val artefactVersion: String by project
val tupleVersion: String by project
version = tupleVersion
val projectUrl: String by project
val projectGithubUrl: String by project
val licenseName: String by project
@@ -70,7 +72,7 @@ publishing {
create<MavenPublication>("tuple") {
groupId = group.toString()
artifactId = "tuple"
version = artefactVersion
version = tupleVersion
pom {
name = "OnixByte Tuple"
+14 -7
View File
@@ -28,7 +28,14 @@ plugins {
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 projectGithubUrl: String by project
val licenseName: String by project
@@ -40,11 +47,11 @@ repositories {
dependencies {
constraints {
api("com.onixbyte:common-toolbox:$artefactVersion")
api("com.onixbyte:identity-generator:$artefactVersion")
api("com.onixbyte:crypto-toolbox:$artefactVersion")
api("com.onixbyte:math-toolbox:$artefactVersion")
api("com.onixbyte:tuple:$artefactVersion")
api("com.onixbyte:common-toolbox:$commonToolboxVersion")
api("com.onixbyte:identity-generator:$identityGeneratorVersion")
api("com.onixbyte:crypto-toolbox:$cryptoToolboxVersion")
api("com.onixbyte:math-toolbox:$mathToolboxVersion")
api("com.onixbyte:tuple:$tupleVersion")
}
}
@@ -53,7 +60,7 @@ publishing {
create<MavenPublication>("versionCatalogue") {
groupId = group.toString()
artifactId = "version-catalogue"
version = artefactVersion
version = versionCatalogueVersion
pom {
name = "OnixByte Version Catalogue"