refactor: split modules to separate repos

This commit is contained in:
2026-06-02 14:05:27 +08:00
parent 7bb9383c2b
commit e4e1eb824b
2 changed files with 16 additions and 100 deletions
+15 -99
View File
@@ -1,25 +1,18 @@
# This workflow publishes one or more modules to Maven Central when a version tag is pushed
# to the main branch.
# Publishes onixbyte-tuple to Maven Central when a version tag is pushed to main.
#
# Supported tag formats:
# <module>/v<version> — publish a single module (e.g. tuple/v3.3.1)
# <module>+<module>/v<version> — publish multiple modules (e.g. tuple+crypto-toolbox/v3.3.1)
# v<version> — publish all modules (e.g. v3.4.0)
#
# Valid module names: common-toolbox, tuple, identity-generator, crypto-toolbox, math-toolbox, version-catalogue
# Supported tag format: <major>.<minor>.<patch>[-suffix] (e.g. 3.3.1, 3.3.1-alpha)
name: Publish Packages to Maven Central
name: Publish Package to Maven Central
on:
push:
tags:
- 'v[0-9]*.[0-9]*.[0-9]*'
- '*/v[0-9]*.[0-9]*.[0-9]*'
- '[0-9]*.[0-9]*.[0-9]*'
jobs:
publish:
name: Build and Publish
runs-on: self-hosted
runs-on: ubuntu-latest
permissions:
contents: read
@@ -38,63 +31,12 @@ jobs:
fi
echo "✓ Tag ${{ github.ref_name }} is on main"
- name: Parse Tag
id: parse-tag
- name: Extract Version
id: version
run: |
declare -A MODULE_PROPS=(
["common-toolbox"]="commonToolboxVersion"
["tuple"]="tupleVersion"
["identity-generator"]="identityGeneratorVersion"
["crypto-toolbox"]="cryptoToolboxVersion"
["math-toolbox"]="mathToolboxVersion"
["version-catalogue"]="versionCatalogueVersion"
)
TAG="${{ github.ref_name }}"
echo "Tag: ${TAG}"
# <module>[+<module>...]/v<version> — one or more specific modules
if [[ "${TAG}" =~ ^([a-z][a-z0-9-]+(\+[a-z][a-z0-9-]+)*)/v?([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
IFS='+' read -ra MODULES <<< "${BASH_REMATCH[1]}"
VERSION="${BASH_REMATCH[3]}"
# v<version> — all modules
else
MODULES=("common-toolbox" "tuple" "identity-generator" "crypto-toolbox" "math-toolbox" "version-catalogue")
VERSION="${TAG#v}"
fi
# Validate all modules
for m in "${MODULES[@]}"; do
if [ -z "${MODULE_PROPS[$m]}" ]; then
echo "::error::Unknown module: ${m}"
echo "Valid modules: ${!MODULE_PROPS[*]}"
exit 1
fi
done
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "count=${#MODULES[@]}" >> $GITHUB_OUTPUT
for m in "${MODULES[@]}"; do
echo "→ ${m} @ ${VERSION}"
done
# Store module list as a multi-line output
{
echo "modules<<MODULES_EOF"
printf '%s\n' "${MODULES[@]}"
echo "MODULES_EOF"
} >> $GITHUB_OUTPUT
# Store property mappings
{
echo "props<<PROPS_EOF"
for m in "${MODULES[@]}"; do
echo "${m}=${MODULE_PROPS[$m]}"
done
echo "PROPS_EOF"
} >> $GITHUB_OUTPUT
VERSION="${{ github.ref_name }}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Version: ${VERSION}"
- name: Setup GPG TTY
run: export GPG_TTY=$(tty)
@@ -134,42 +76,16 @@ jobs:
- name: Build with Gradle
env:
MODULES: ${{ steps.parse-tag.outputs.modules }}
PROPS: ${{ steps.parse-tag.outputs.props }}
VERSION: ${{ steps.parse-tag.outputs.version }}
run: |
declare -A MODULE_PROPS
while IFS='=' read -r key value; do
MODULE_PROPS[$key]="$value"
done <<< "$PROPS"
while IFS= read -r MODULE; do
echo "::group::Building ${MODULE}"
PROP="${MODULE_PROPS[$MODULE]}"
./gradlew ":${MODULE}:build" "-P${PROP}=${VERSION}"
echo "::endgroup::"
done <<< "$MODULES"
VERSION: ${{ steps.version.outputs.version }}
run: ./gradlew build "-PartefactVersion=${VERSION}"
- name: List Output Items
run: ls -l ./**/build/libs
run: ls -l ./build/libs
- name: Publish to Maven Central
env:
MODULES: ${{ steps.parse-tag.outputs.modules }}
PROPS: ${{ steps.parse-tag.outputs.props }}
VERSION: ${{ steps.parse-tag.outputs.version }}
run: |
declare -A MODULE_PROPS
while IFS='=' read -r key value; do
MODULE_PROPS[$key]="$value"
done <<< "$PROPS"
while IFS= read -r MODULE; do
echo "::group::Publishing ${MODULE}"
PROP="${MODULE_PROPS[$MODULE]}"
./gradlew ":${MODULE}:publish" "-P${PROP}=${VERSION}"
echo "::endgroup::"
done <<< "$MODULES"
VERSION: ${{ steps.version.outputs.version }}
run: ./gradlew publish "-PartefactVersion=${VERSION}"
- name: Create Deployment on Central Publisher Portal
run: |