Consistent logging in all Bash scripts via formatters/logging/logging.sh

This commit is contained in:
Mario Zechner 2025-07-20 20:45:54 +02:00
parent 2036aa3e76
commit 0dd86dfdc1
19 changed files with 689 additions and 182 deletions

View File

@ -2,6 +2,9 @@
set -e
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Source logging utilities
source "$dir/logging/logging.sh"
# Default: format all languages
FORMAT_JAVA=true
FORMAT_TS=true
@ -13,8 +16,7 @@ FORMAT_SWIFT=true
# Parse command line arguments
show_help() {
echo "Spine Runtimes Code Formatter"
echo ""
log_title "Spine Runtimes Code Formatter"
echo "Usage: ./format.sh [options]"
echo ""
echo "Options:"
@ -87,40 +89,63 @@ while [[ $# -gt 0 ]]; do
shift
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
log_fail "Unknown option: $1"
log_detail "Use --help for usage information"
exit 1
;;
esac
done
log_title "Code Formatting"
# Call individual formatter scripts
if [ "$FORMAT_CPP" = true ]; then
log_section "C/C++"
log_action "Formatting C/C++ files"
"$dir/format-cpp.sh"
log_ok "C/C++ formatting completed"
fi
if [ "$FORMAT_JAVA" = true ]; then
log_section "Java"
log_action "Formatting Java files"
"$dir/format-java.sh"
log_ok "Java formatting completed"
fi
if [ "$FORMAT_CSHARP" = true ]; then
log_section "C#"
log_action "Formatting C# files"
"$dir/format-csharp.sh"
log_ok "C# formatting completed"
fi
if [ "$FORMAT_TS" = true ]; then
log_section "TypeScript"
log_action "Formatting TypeScript files"
"$dir/format-ts.sh"
log_ok "TypeScript formatting completed"
fi
if [ "$FORMAT_DART" = true ]; then
log_section "Dart"
log_action "Formatting Dart files"
"$dir/format-dart.sh"
log_ok "Dart formatting completed"
fi
if [ "$FORMAT_HAXE" = true ]; then
log_section "Haxe"
log_action "Formatting Haxe files"
"$dir/format-haxe.sh"
log_ok "Haxe formatting completed"
fi
if [ "$FORMAT_SWIFT" = true ]; then
log_section "Swift"
log_action "Formatting Swift files"
"$dir/format-swift.sh"
log_ok "Swift formatting completed"
fi
echo "Formatting complete!"
log_summary "✓ All formatting completed"

View File

@ -76,7 +76,7 @@ log_summary "✗ Tests failed (3/5)"
```bash
#!/bin/bash
source ../formatters/bash-colors.sh
source ../formatters/logging/logging.sh
log_title "Spine-C++ Test"
log_detail "Platform: $(uname)"
@ -145,7 +145,7 @@ fi
1. Source the utilities in your script:
```bash
source ../formatters/logging/bash-colors.sh
source ../formatters/logging/logging.sh
```
2. Follow the hierarchy patterns shown above

View File

@ -1,34 +1,67 @@
#!/bin/sh
#
# Modern Central Portal Publishing Setup:
# 1. Set up PGP key for signing: gpg --generate-key
# 2. Create Central Portal account at https://central.sonatype.com/
# 3. Generate user token in Central Portal settings
# 4. Create ~/.gradle/gradle.properties with:
# MAVEN_USERNAME=<central-portal-username>
# MAVEN_PASSWORD=<central-portal-token>
# signing.gnupg.passphrase=<pgp-key-passphrase>
#
# Version Configuration:
# - Edit spine-libgdx/gradle.properties and update the 'version' property. YES, THIS IS THE SINGLE SOURCE OF TRUTH.
# - For releases: version=4.2.9 (no -SNAPSHOT suffix)
# - For snapshots: version=4.2.9-SNAPSHOT (with -SNAPSHOT suffix)
#
# Usage: ./publish.sh
# The script automatically detects snapshot vs release based on version in gradle.properties
#
#!/bin/bash
set -e
cd "$(dirname "$0")"
# Read version from spine-libgdx gradle.properties (single source of truth)
VERSION=$(grep '^version=' ../spine-libgdx/gradle.properties | cut -d'=' -f2)
# Source logging utilities
source ../formatters/logging/logging.sh
if echo "$VERSION" | grep -q "SNAPSHOT"; then
echo "Publishing SNAPSHOT version $VERSION to Central Portal..."
./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository --info
log_title "Spine Android Publisher"
log_detail "Modern Central Portal Publishing Setup:"
log_detail "1. Set up PGP key for signing: gpg --generate-key"
log_detail "2. Create Central Portal account at https://central.sonatype.com/"
log_detail "3. Generate user token in Central Portal settings"
log_detail "4. Create ~/.gradle/gradle.properties with:"
log_detail " MAVEN_USERNAME=<central-portal-username>"
log_detail " MAVEN_PASSWORD=<central-portal-token>"
log_detail " signing.gnupg.passphrase=<pgp-key-passphrase>"
log_detail ""
log_detail "Version Configuration:"
log_detail "- Edit spine-libgdx/gradle.properties and update the 'version' property (single source of truth)"
log_detail "- For releases: version=4.2.9 (no -SNAPSHOT suffix)"
log_detail "- For snapshots: version=4.2.9-SNAPSHOT (with -SNAPSHOT suffix)"
log_section "Reading Version Configuration"
log_action "Reading version from spine-libgdx gradle.properties"
if VERSION=$(grep '^version=' ../spine-libgdx/gradle.properties | cut -d'=' -f2); then
log_ok "Version found: $VERSION"
else
echo "Publishing RELEASE version $VERSION to Central Portal via JReleaser..."
./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository -PRELEASE
./gradlew :spine-android:jreleaserDeploy -PRELEASE --info
log_fail "Failed to read version from ../spine-libgdx/gradle.properties"
exit 1
fi
log_section "Publishing to Central Portal"
if echo "$VERSION" | grep -q "SNAPSHOT"; then
log_detail "Detected SNAPSHOT version"
log_action "Publishing SNAPSHOT version $VERSION to Central Portal"
if output=$(./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository --info 2>&1); then
log_ok "Successfully published SNAPSHOT version $VERSION"
log_summary "Android SNAPSHOT published successfully to Central Portal"
else
log_fail "Failed to publish SNAPSHOT version"
log_detail "$output"
exit 1
fi
else
log_detail "Detected RELEASE version"
log_action "Publishing RELEASE version $VERSION to Central Portal via JReleaser"
log_action "Publishing to SonaType repository"
if output=$(./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository -PRELEASE 2>&1); then
log_ok "Successfully published to SonaType repository"
else
log_fail "Failed to publish to SonaType repository"
log_detail "$output"
exit 1
fi
log_action "Deploying via JReleaser"
if output=$(./gradlew :spine-android:jreleaserDeploy -PRELEASE --info 2>&1); then
log_ok "Successfully deployed via JReleaser"
log_summary "Android RELEASE published successfully to Central Portal"
else
log_fail "Failed to deploy via JReleaser"
log_detail "$output"
exit 1
fi
fi

View File

@ -3,10 +3,12 @@ set -e
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
# Display help information
show_help() {
echo "spine-c build script"
echo ""
log_title "Spine-C Build Script"
echo "Usage: ./build.sh [option]"
echo ""
echo "Options:"
@ -32,16 +34,34 @@ fi
# Run codegen if requested
if [ "$1" = "codegen" ]; then
npx -y tsx codegen/src/index.ts
# Format the generated C++ files
echo "Formatting generated C++ files..."
log_title "Spine-C Code Generation"
log_section "Generate"
log_action "Generating C bindings"
if CODEGEN_OUTPUT=$(npx -y tsx codegen/src/index.ts 2>&1); then
log_ok "Code generation completed"
else
log_fail "Code generation failed"
log_detail "$CODEGEN_OUTPUT"
exit 1
fi
log_section "Format"
log_action "Formatting generated C++ files"
../formatters/format.sh cpp
log_summary "✓ Code generation successful"
exit 0
fi
log_title "Spine-C Build"
# Clean only if explicitly requested
if [ "$1" = "clean" ]; then
log_section "Clean"
log_action "Removing build directory"
rm -rf build
log_ok "Cleaned"
fi
# Determine build type
@ -50,6 +70,25 @@ if [ "$1" = "release" ]; then
BUILD_TYPE="release"
fi
# Always build
cmake --preset=$BUILD_TYPE .
cmake --build --preset=$BUILD_TYPE
# Configure and build
log_section "Configure"
log_action "Configuring $BUILD_TYPE build"
if CMAKE_OUTPUT=$(cmake --preset=$BUILD_TYPE . 2>&1); then
log_ok "Configured"
else
log_fail "Configuration failed"
log_detail "$CMAKE_OUTPUT"
exit 1
fi
log_section "Build"
log_action "Building"
if BUILD_OUTPUT=$(cmake --build --preset=$BUILD_TYPE 2>&1); then
log_ok "Build completed"
else
log_fail "Build failed"
log_detail "$BUILD_OUTPUT"
exit 1
fi
log_summary "✓ Build successful"

View File

@ -3,6 +3,9 @@ set -e
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
# Parse arguments
BUILD_TYPE="debug"
NOFILEIO=""
@ -23,18 +26,42 @@ for arg in "$@"; do
NOFILEIO="-DSPINE_NO_FILE_IO=ON"
;;
*)
echo "Unknown argument: $arg"
echo "Usage: $0 [clean] [release|debug] [nofileio]"
log_fail "Unknown argument: $arg"
log_detail "Usage: $0 [clean] [release|debug] [nofileio]"
exit 1
;;
esac
done
log_title "Spine-C++ Build"
# Clean if requested
if [ "$CLEAN" = "true" ]; then
log_section "Clean"
log_action "Removing build directory"
rm -rf build
log_ok "Cleaned"
fi
# Configure and build
cmake --preset=$BUILD_TYPE $NOFILEIO .
cmake --build --preset=$BUILD_TYPE
log_section "Configure"
log_action "Configuring $BUILD_TYPE build"
if CMAKE_OUTPUT=$(cmake --preset=$BUILD_TYPE $NOFILEIO . 2>&1); then
log_ok "Configured"
else
log_fail "Configuration failed"
log_detail "$CMAKE_OUTPUT"
exit 1
fi
log_section "Build"
log_action "Building"
if BUILD_OUTPUT=$(cmake --build --preset=$BUILD_TYPE 2>&1); then
log_ok "Build completed"
else
log_fail "Build failed"
log_detail "$BUILD_OUTPUT"
exit 1
fi
log_summary "✓ Build successful"

View File

@ -13,7 +13,7 @@ set -e
cd "$(dirname "$0")/.."
# Source logging utilities
source ../formatters/logging/bash-colors.sh
source ../formatters/logging/logging.sh
# Test configuration - spineboy example files and animation
SPINEBOY_SKEL="../examples/spineboy/export/spineboy-pro.skel"

View File

@ -1,30 +1,73 @@
#!/bin/sh
#!/bin/bash
set -e
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
pushd $dir > /dev/null
mkdir -p lib/assets/
# Need to use -O2, as -O3 applies the Closure compiler to native function names.
# The entries for exported functions in Module.asm will be scrambled so
# EmscriptenModule._fromJs() is unable to parse them and link them with original
# names set on the module, e.g. Module._spine_get_major_version.
echo "const module = {};" > pre.js
em++ \
-Isrc/spine-cpp/include \
-O2 --closure 1 -fno-rtti -fno-exceptions \
-s STRICT=1 \
-s EXPORTED_RUNTIME_METHODS=wasmExports \
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
-s MODULARIZE=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s ALLOW_TABLE_GROWTH \
-s MALLOC=emmalloc \
-s EXPORT_ALL=1 \
-s EXPORTED_FUNCTIONS='["_malloc", "_free"]' \
--no-entry \
--extern-pre-js pre.js \
-s EXPORT_NAME=libspine_flutter \
src/spine-cpp-lite/spine-cpp-lite.cpp `find src/spine-cpp/src -type f` \
-o lib/assets/libspine_flutter.js
ls -lah lib/assets
rm pre.js
popd
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
log_title "Spine Flutter WASM Compiler"
log_section "Preparing Build Environment"
log_action "Creating assets directory"
if mkdir -p lib/assets/; then
log_ok "Assets directory created"
else
log_fail "Failed to create assets directory"
exit 1
fi
log_action "Creating pre.js module file"
if echo "const module = {};" > pre.js; then
log_ok "pre.js created successfully"
else
log_fail "Failed to create pre.js"
exit 1
fi
log_section "Compiling WASM"
log_detail "Using -O2 optimization to preserve function names"
log_detail "The Closure compiler in -O3 would scramble native function names"
log_action "Compiling spine-cpp to WASM"
# Build the emscripten command
if output=$(em++ \
-Isrc/spine-cpp/include \
-O2 --closure 1 -fno-rtti -fno-exceptions \
-s STRICT=1 \
-s EXPORTED_RUNTIME_METHODS=wasmExports \
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
-s MODULARIZE=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s ALLOW_TABLE_GROWTH \
-s MALLOC=emmalloc \
-s EXPORT_ALL=1 \
-s EXPORTED_FUNCTIONS='["_malloc", "_free"]' \
--no-entry \
--extern-pre-js pre.js \
-s EXPORT_NAME=libspine_flutter \
src/spine-cpp-lite/spine-cpp-lite.cpp $(find src/spine-cpp/src -type f) \
-o lib/assets/libspine_flutter.js 2>&1); then
log_ok "WASM compilation completed successfully"
else
log_fail "WASM compilation failed"
log_detail "$output"
rm -f pre.js
exit 1
fi
log_section "Build Results"
log_action "Listing generated assets"
if ls -lah lib/assets; then
log_ok "Assets generated successfully"
else
log_warn "Could not list assets directory"
fi
log_action "Cleaning up temporary files"
if rm pre.js; then
log_ok "Cleaned up pre.js"
else
log_warn "Could not remove pre.js"
fi
log_summary "WASM compilation completed successfully"

View File

@ -1,6 +1,47 @@
#!/bin/sh
#!/bin/bash
set -e
./setup.sh
./compile-wasm.sh
dart pub publish --dry-run
dart pub publish
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
log_title "Spine Flutter Publisher"
log_section "Preparation"
log_action "Setting up environment"
if output=$(./setup.sh 2>&1); then
log_ok "Setup completed successfully"
else
log_fail "Setup failed"
log_detail "$output"
exit 1
fi
log_action "Compiling WASM"
if output=$(./compile-wasm.sh 2>&1); then
log_ok "WASM compilation completed successfully"
else
log_fail "WASM compilation failed"
log_detail "$output"
exit 1
fi
log_section "Publishing to Dart Pub"
log_action "Running dry-run publish"
if output=$(dart pub publish --dry-run 2>&1); then
log_ok "Dry-run publish completed successfully"
else
log_fail "Dry-run publish failed"
log_detail "$output"
exit 1
fi
log_action "Publishing to Dart Pub"
if output=$(dart pub publish 2>&1); then
log_ok "Successfully published to Dart Pub"
log_summary "Flutter package published successfully"
else
log_fail "Failed to publish to Dart Pub"
log_detail "$output"
exit 1
fi

View File

@ -1,11 +1,47 @@
#!/bin/bash
set -e
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
pushd $dir > /dev/null
# Need to copy spine-cpp sources to the ios and macos folders, as CocoaPods requires
# all source files to be under the same folder hierarchy the podspec file resides in.
cp -r ../spine-cpp/spine-cpp ios/Classes
cp -r ../spine-cpp/spine-cpp macos/Classes
cp -r ../spine-cpp/spine-cpp src
cp -r ../spine-cpp/spine-cpp-lite src
popd
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
log_title "Spine Flutter Setup"
log_detail "CocoaPods requires all source files to be under the same folder hierarchy"
log_detail "as the podspec file resides in. Copying spine-cpp sources to platform folders."
log_section "Copying Spine C++ Sources"
log_action "Copying spine-cpp to iOS Classes"
if cp -r ../spine-cpp/spine-cpp ios/Classes 2>/dev/null; then
log_ok "iOS Classes updated successfully"
else
log_fail "Failed to copy spine-cpp to iOS Classes"
exit 1
fi
log_action "Copying spine-cpp to macOS Classes"
if cp -r ../spine-cpp/spine-cpp macos/Classes 2>/dev/null; then
log_ok "macOS Classes updated successfully"
else
log_fail "Failed to copy spine-cpp to macOS Classes"
exit 1
fi
log_action "Copying spine-cpp to src directory"
if cp -r ../spine-cpp/spine-cpp src 2>/dev/null; then
log_ok "src directory updated successfully"
else
log_fail "Failed to copy spine-cpp to src directory"
exit 1
fi
log_action "Copying spine-cpp-lite to src directory"
if cp -r ../spine-cpp/spine-cpp-lite src 2>/dev/null; then
log_ok "spine-cpp-lite copied successfully"
else
log_fail "Failed to copy spine-cpp-lite to src directory"
exit 1
fi
log_summary "Flutter setup completed successfully"

View File

@ -1,6 +1,11 @@
#!/bin/sh
#!/bin/bash
set -e
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
if [ -z "$GITHUB_REF" ]; then
BRANCH=$(git symbolic-ref --short -q HEAD)
else
@ -10,23 +15,39 @@ fi
# Get the latest commit message
COMMIT_MSG=$(git log -1 --pretty=%B)
log_title "Spine-Haxe Build"
log_detail "Branch: $BRANCH"
# Public only if the commit message is in the correct format
if echo "$COMMIT_MSG" | grep -qE '^\[haxe\] Release [0-9]+\.[0-9]+\.[0-9]+$'; then
VERSION=$(echo "$COMMIT_MSG" | sed -E 's/^\[haxe\] Release ([0-9]+\.[0-9]+\.[0-9]+)$/\1/')
echo "Building spine-haxe $BRANCH artifacts (version $VERSION)"
log_detail "Version: $VERSION"
if [ ! -z "$HAXE_UPDATE_URL" ] && [ ! -z "$BRANCH" ]; then
echo "Deploying spine-haxe $BRANCH artifacts (version $VERSION)"
log_section "Deploy"
log_action "Creating release package"
zip -r "spine-haxe-$VERSION.zip" \
haxelib.json \
LICENSE \
README.md \
spine-haxe
curl -f -F "file=@spine-haxe-$VERSION.zip" "$HAXE_UPDATE_URL$BRANCH"
spine-haxe > /dev/null 2>&1
log_ok "Package created"
log_action "Uploading to $HAXE_UPDATE_URL$BRANCH"
if curl -f -F "file=@spine-haxe-$VERSION.zip" "$HAXE_UPDATE_URL$BRANCH" > /dev/null 2>&1; then
log_ok "Package deployed"
else
log_fail "Upload failed"
exit 1
fi
log_summary "✓ Build and deployment successful"
else
echo "Not deploying artifacts. HAXE_UPDATE_URL and/or BRANCH not set."
log_skip "Deployment skipped (HAXE_UPDATE_URL and/or BRANCH not set)"
log_summary "✓ Build successful"
fi
else
echo "The commit is not a release - do not publish."
echo "To release the commit has to be in the for: \"[haxe] Release x.y.z\""
log_warn "Commit is not a release - skipping publish"
log_detail "To release, commit message must be: \"[haxe] Release x.y.z\""
log_summary "Build skipped"
fi

View File

@ -1,6 +1,11 @@
#!/bin/sh
#!/bin/bash
set -e
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
currentVersion=$(grep -o '"version": "[^"]*' haxelib.json | grep -o '[^"]*$')
major=$(echo "$currentVersion" | cut -d. -f1)
@ -9,21 +14,38 @@ patch=$(echo "$currentVersion" | cut -d. -f3)
newPatch=$((patch + 1))
newVersion="$major.$minor.$newPatch"
echo "current version: $currentVersion"
echo "new version: $newVersion"
log_title "Spine-Haxe Publish"
log_section "Version Update"
log_detail "Current version: $currentVersion"
log_detail "New version: $newVersion"
log_action "Updating haxelib.json"
sed -i '' "s/$currentVersion/$newVersion/" haxelib.json
log_ok "Version updated in haxelib.json"
log_section "Confirm"
echo "Write Y if you want to commit and push the new version $newVersion."
echo "This will trigger a pipeline that will publish the new version on esoteric software server."
echo "Do you want to proceed [y/n]?"
read answer
if [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then
log_section "Publish"
log_action "Committing changes"
git add haxelib.json
git commit -m "[haxe] Release $newVersion"
git push origin 4.2
echo "Changes committed and pushed."
log_ok "Changes committed"
log_action "Pushing to origin"
if git push origin 4.2; then
log_ok "Changes pushed"
log_summary "✓ Version $newVersion published successfully"
else
log_fail "Push failed"
exit 1
fi
else
echo "Commit and push cancelled, but haxelib.json version updated."
log_skip "Commit and push cancelled"
log_summary "Version updated locally only"
fi

View File

@ -1,4 +1,24 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
python3 ../spine-cpp/spine-cpp-lite/spine-cpp-lite-codegen.py > Sources/Spine/Spine.Generated.swift
# Source logging utilities
source ../formatters/logging/logging.sh
log_title "Spine iOS Setup"
log_section "Generating Swift Bindings"
log_action "Running spine-cpp-lite code generator"
if output=$(python3 ../spine-cpp/spine-cpp-lite/spine-cpp-lite-codegen.py 2>&1); then
if echo "$output" > Sources/Spine/Spine.Generated.swift; then
log_ok "Swift bindings generated successfully"
log_summary "iOS setup completed successfully"
else
log_fail "Failed to write generated Swift code"
exit 1
fi
else
log_fail "Failed to run spine-cpp-lite code generator"
log_detail "$output"
exit 1
fi

View File

@ -1,34 +1,67 @@
#!/bin/sh
#
# Modern Central Portal Publishing Setup:
# 1. Set up PGP key for signing: gpg --generate-key
# 2. Create Central Portal account at https://central.sonatype.com/
# 3. Generate user token in Central Portal settings
# 4. Create ~/.gradle/gradle.properties with:
# MAVEN_USERNAME=<central-portal-username>
# MAVEN_PASSWORD=<central-portal-token>
# signing.gnupg.passphrase=<pgp-key-passphrase>
#
# Version Configuration:
# - Edit gradle.properties and update the 'version' property
# - For releases: version=4.2.9 (no -SNAPSHOT suffix)
# - For snapshots: version=4.2.9-SNAPSHOT (with -SNAPSHOT suffix)
#
# Usage: ./publish.sh
# The script automatically detects snapshot vs release based on version in gradle.properties
#
#!/bin/bash
set -e
cd "$(dirname "$0")"
# Read version from gradle.properties
VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2)
# Source logging utilities
source ../formatters/logging/logging.sh
if echo "$VERSION" | grep -q "SNAPSHOT"; then
echo "Publishing SNAPSHOT version $VERSION to Central Portal..."
./gradlew publishReleasePublicationToSonaTypeRepository
log_title "Spine LibGDX Publisher"
log_detail "Modern Central Portal Publishing Setup:"
log_detail "1. Set up PGP key for signing: gpg --generate-key"
log_detail "2. Create Central Portal account at https://central.sonatype.com/"
log_detail "3. Generate user token in Central Portal settings"
log_detail "4. Create ~/.gradle/gradle.properties with:"
log_detail " MAVEN_USERNAME=<central-portal-username>"
log_detail " MAVEN_PASSWORD=<central-portal-token>"
log_detail " signing.gnupg.passphrase=<pgp-key-passphrase>"
log_detail ""
log_detail "Version Configuration:"
log_detail "- Edit gradle.properties and update the 'version' property"
log_detail "- For releases: version=4.2.9 (no -SNAPSHOT suffix)"
log_detail "- For snapshots: version=4.2.9-SNAPSHOT (with -SNAPSHOT suffix)"
log_section "Reading Version Configuration"
log_action "Reading version from gradle.properties"
if VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2); then
log_ok "Version found: $VERSION"
else
echo "Publishing RELEASE version $VERSION to Central Portal via JReleaser..."
./gradlew publishReleasePublicationToSonaTypeRepository -PRELEASE
./gradlew jreleaserDeploy -PRELEASE
log_fail "Failed to read version from gradle.properties"
exit 1
fi
log_section "Publishing to Central Portal"
if echo "$VERSION" | grep -q "SNAPSHOT"; then
log_detail "Detected SNAPSHOT version"
log_action "Publishing SNAPSHOT version $VERSION to Central Portal"
if output=$(./gradlew publishReleasePublicationToSonaTypeRepository 2>&1); then
log_ok "Successfully published SNAPSHOT version $VERSION"
log_summary "LibGDX SNAPSHOT published successfully to Central Portal"
else
log_fail "Failed to publish SNAPSHOT version"
log_detail "$output"
exit 1
fi
else
log_detail "Detected RELEASE version"
log_action "Publishing RELEASE version $VERSION to Central Portal via JReleaser"
log_action "Publishing to SonaType repository"
if output=$(./gradlew publishReleasePublicationToSonaTypeRepository -PRELEASE 2>&1); then
log_ok "Successfully published to SonaType repository"
else
log_fail "Failed to publish to SonaType repository"
log_detail "$output"
exit 1
fi
log_action "Deploying via JReleaser"
if output=$(./gradlew jreleaserDeploy -PRELEASE 2>&1); then
log_ok "Successfully deployed via JReleaser"
log_summary "LibGDX RELEASE published successfully to Central Portal"
else
log_fail "Failed to deploy via JReleaser"
log_detail "$output"
exit 1
fi
fi

View File

@ -1,6 +1,11 @@
#!/bin/sh
#!/bin/bash
set -e
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
if [ -z "$GITHUB_REF" ];
then
BRANCH=$(git symbolic-ref --short -q HEAD)
@ -8,12 +13,23 @@ else
BRANCH=${GITHUB_REF#refs/heads/}
fi
echo "Building spine-ts $BRANCH artifacts"
npm install
log_title "Spine-TS Build"
log_detail "Branch: $BRANCH"
log_section "Setup"
log_action "Installing dependencies"
if npm install > /tmp/npm-install.log 2>&1; then
log_ok "Dependencies installed"
else
log_fail "npm install failed"
log_detail "$(cat /tmp/npm-install.log)"
exit 1
fi
if ! [ -z "$TS_UPDATE_URL" ] && ! [ -z "$BRANCH" ];
then
echo "Deploying spine-ts $BRANCH artifacts"
log_section "Deploy"
log_action "Creating artifacts zip"
zip -j spine-ts.zip \
spine-core/dist/iife/* \
spine-canvas/dist/iife/* \
@ -35,8 +51,18 @@ then
spine-phaser-v3/dist/esm/* \
spine-phaser-v4/dist/esm/* \
spine-webcomponents/dist/esm/* \
spine-player/css/spine-player.css
curl -f -F "file=@spine-ts.zip" "$TS_UPDATE_URL$BRANCH"
spine-player/css/spine-player.css > /dev/null 2>&1
log_action "Uploading to $TS_UPDATE_URL$BRANCH"
if curl -f -F "file=@spine-ts.zip" "$TS_UPDATE_URL$BRANCH" > /dev/null 2>&1; then
log_ok "Artifacts deployed"
else
log_fail "Upload failed"
exit 1
fi
log_summary "✓ Build and deployment successful"
else
echo "Not deploying artifacts. TS_UPDATE_URL and/or BRANCH not set."
log_skip "Deployment skipped (TS_UPDATE_URL and/or BRANCH not set)"
log_summary "✓ Build successful"
fi

View File

@ -1,6 +1,13 @@
#!/bin/sh
#!/bin/bash
set -e
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
log_title "Spine TypeScript Publisher"
# Get current version
currentVersion=$(grep -o '"version": "[^"]*' package.json | grep -o '[^"]*$')
major=$(echo "$currentVersion" | cut -d. -f1)
minor=$(echo "$currentVersion" | cut -d. -f2)
@ -8,23 +15,68 @@ patch=$(echo "$currentVersion" | cut -d. -f3)
newPatch=$((patch + 1))
newVersion="$major.$minor.$newPatch"
echo "current version: $currentVersion"
echo "new version: $newVersion"
log_section "Version Management"
log_detail "Current version: $currentVersion"
log_detail "New version: $newVersion"
sed -i '' "s/$currentVersion/$newVersion/" package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-canvas/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-canvaskit/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-core/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-phaser-v3/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-phaser-v4/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-pixi-v7/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-pixi-v8/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-player/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-threejs/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-webgl/package.json
sed -i '' "s/$currentVersion/$newVersion/" spine-webcomponents/package.json
log_section "Updating Package Versions"
packages=(
"package.json"
"spine-canvas/package.json"
"spine-canvaskit/package.json"
"spine-core/package.json"
"spine-phaser-v3/package.json"
"spine-phaser-v4/package.json"
"spine-pixi-v7/package.json"
"spine-pixi-v8/package.json"
"spine-player/package.json"
"spine-threejs/package.json"
"spine-webgl/package.json"
"spine-webcomponents/package.json"
)
rm package-lock.json
rm -rf node_modules/@esotericsoftware
npm install --workspaces
npm publish --access public --workspaces
for package in "${packages[@]}"; do
log_action "Updating $package"
if sed -i '' "s/$currentVersion/$newVersion/" "$package" 2>/dev/null; then
log_ok "Updated $package"
else
log_fail "Failed to update $package"
exit 1
fi
done
log_section "Preparing for Publish"
log_action "Removing package-lock.json"
if rm package-lock.json 2>/dev/null; then
log_ok "Removed package-lock.json"
else
log_warn "package-lock.json not found or already removed"
fi
log_action "Cleaning @esotericsoftware modules"
if rm -rf node_modules/@esotericsoftware 2>/dev/null; then
log_ok "Cleaned @esotericsoftware modules"
else
log_warn "@esotericsoftware modules not found or already removed"
fi
log_section "Installing Dependencies"
log_action "Installing workspace dependencies"
if output=$(npm install --workspaces 2>&1); then
log_ok "Dependencies installed successfully"
else
log_fail "Failed to install dependencies"
log_detail "$output"
exit 1
fi
log_section "Publishing to NPM"
log_action "Publishing all workspaces"
if output=$(npm publish --access public --workspaces 2>&1); then
log_ok "Successfully published all packages to NPM"
log_summary "TypeScript packages published successfully with version $newVersion"
else
log_fail "Failed to publish packages"
log_detail "$output"
exit 1
fi

View File

@ -1,3 +1,25 @@
#!/bin/sh
rm -rf Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp
cp -r ../spine-cpp/spine-cpp Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp
#!/bin/bash
set -e
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
log_title "Spine Unreal Engine Setup"
log_section "Updating Spine C++ Sources"
log_action "Removing existing spine-cpp directory"
if rm -rf Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp 2>/dev/null; then
log_ok "Existing spine-cpp directory removed"
else
log_warn "No existing spine-cpp directory found"
fi
log_action "Copying updated spine-cpp sources"
if cp -r ../spine-cpp/spine-cpp Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp 2>/dev/null; then
log_ok "spine-cpp sources copied successfully"
log_summary "Unreal Engine setup completed successfully"
else
log_fail "Failed to copy spine-cpp sources"
exit 1
fi

View File

@ -2,21 +2,77 @@
set -e
set -o pipefail
cd "$(dirname "$0")"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pushd "$SCRIPT_DIR" > /dev/null
# Source logging utilities
source ../formatters/logging/logging.sh
echo "Analyzing Java API..."
npx -y tsx src/analyze-java-api.ts || { echo "Failed to analyze Java API"; exit 1; }
log_title "Spine Serializer Generator"
echo "Generating serializer IR..."
npx -y tsx src/generate-serializer-ir.ts || { echo "Failed to generate IR"; exit 1; }
# Check if node/npm is available
if ! command -v npm &> /dev/null; then
log_fail "npm is not installed"
exit 1
fi
echo "Generating Java SkeletonSerializer..."
npx -y tsx src/generate-java-serializer.ts || { echo "Failed to generate Java serializer"; exit 1; }
# Install dependencies if node_modules doesn't exist
if [ ! -d "node_modules" ]; then
log_section "Setup"
log_action "Installing dependencies"
if npm install > /tmp/npm-install.log 2>&1; then
log_ok "Dependencies installed"
else
log_fail "npm install failed"
log_detail "$(cat /tmp/npm-install.log)"
exit 1
fi
fi
echo "Generating C++ SkeletonSerializer..."
npx -y tsx src/generate-cpp-serializer.ts || { echo "Failed to generate C++ serializer"; exit 1; }
log_section "Analyzing API"
log_action "Analyzing Java API"
if output=$(npx -y tsx src/analyze-java-api.ts 2>&1); then
log_ok "Java API analysis completed"
else
log_fail "Failed to analyze Java API"
log_detail "$output"
exit 1
fi
echo "Done."
popd > /dev/null
log_section "Generating Serializer IR"
log_action "Generating intermediate representation"
if output=$(npx -y tsx src/generate-serializer-ir.ts 2>&1); then
log_ok "Serializer IR generated successfully"
else
log_fail "Failed to generate serializer IR"
log_detail "$output"
exit 1
fi
log_section "Generating Language-Specific Serializers"
log_action "Generating Java SkeletonSerializer"
if output=$(npx -y tsx src/generate-java-serializer.ts 2>&1); then
log_ok "Java serializer generated successfully"
log_action "Formatting Java code"
../formatters/format.sh java
log_ok "Java code formatted"
else
log_fail "Failed to generate Java serializer"
log_detail "$output"
exit 1
fi
log_action "Generating C++ SkeletonSerializer"
if output=$(npx -y tsx src/generate-cpp-serializer.ts 2>&1); then
log_ok "C++ serializer generated successfully"
log_action "Formatting C++ code"
../formatters/format.sh cpp
log_ok "C++ code formatted"
else
log_fail "Failed to generate C++ serializer"
log_detail "$output"
exit 1
fi
log_summary "✓ Serializer generation and formatting completed successfully"

View File

@ -3,21 +3,32 @@
# Change to the script's directory
cd "$(dirname "$0")"
# Source logging utilities
source ../formatters/logging/logging.sh
log_title "Spine Tests"
# Check if node/npm is available
if ! command -v npm &> /dev/null; then
echo "Error: npm is not installed" >&2
log_fail "npm is not installed"
exit 1
fi
# Install dependencies if node_modules doesn't exist
if [ ! -d "node_modules" ]; then
echo "Installing dependencies..." >&2
if ! npm install > /tmp/npm-install.log 2>&1; then
echo "npm install failed! Output:" >&2
cat /tmp/npm-install.log >&2
log_section "Setup"
log_action "Installing dependencies"
if npm install > /tmp/npm-install.log 2>&1; then
log_ok "Dependencies installed"
else
log_fail "npm install failed"
log_detail "$(cat /tmp/npm-install.log)"
exit 1
fi
fi
log_section "Test"
log_action "Running TypeScript test runner"
# Run the TypeScript headless test runner with all arguments
npx -y tsx src/headless-test-runner.ts "$@"