chore(ci) - converting from circleci to github actions - initial move and testing

This commit is contained in:
james.maes committed 2025-08-30 10:08:33 -05:00
1 parent fb812b7c74
commit 85a1817fbc
5 files changed
+46 -998

No files matched your search

-191
View File
@@ -1,191 +0,0 @@
#!/bin/bash
############################################################################
## calculate-version.sh
## Intelligent version calculation for GitFlow branching strategy
##
## This script determines the appropriate version based on:
## - Current branch name
## - Current version in pom.xml
## - GitFlow conventions
##
## Usage: ./calculate-version.sh [--dry-run]
## Output: Sets version in pom.xml and prints the new version
############################################################################
set -e
# Configuration
POM_FILE="pom.xml"
DRY_RUN=false
# Parse command line arguments
if [[ "$1" == "--dry-run" ]]; then
DRY_RUN=true
echo "DRY RUN MODE - No changes will be made"
fi
# Get current branch and version
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
CURRENT_VERSION=$(grep '<revision>' $POM_FILE | sed 's/.*<revision>//;s/<.*//')
echo "Current branch: $CURRENT_BRANCH"
echo "Current version: $CURRENT_VERSION"
# Function to extract version components
extract_version_parts() {
local version=$1
# Handle RC versions like 1.5.0-RC.1
if [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-RC\.[0-9]+$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
# Handle SNAPSHOT versions like 1.5.0-SNAPSHOT
elif [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-SNAPSHOT$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
# Handle stable versions like 1.5.0
elif [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
else
echo "ERROR: Cannot parse version format: $version"
exit 1
fi
}
# Function to calculate next version based on branch type
calculate_next_version() {
local branch=$1
case "$branch" in
"develop")
# Check if we just merged a release branch back to develop
# Look for very specific patterns that indicate a release completion
# Only look at recent commits to avoid historical merges triggering bumps
RECENT_RELEASE_MERGES=$(git log --oneline -10 --grep="Merge.*release.*into.*develop" --grep="Merge.*release.*back.*develop" --grep="Bump.*version.*after.*release.*v" --since="3 days ago" || true)
# Also check if current version suggests we're ready for next cycle
if [[ -n "$RECENT_RELEASE_MERGES" ]] || [[ "$CURRENT_VERSION" =~ -RC\.[0-9]+$ ]] || [[ "$CURRENT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# We just merged a release or have an RC/stable version, bump to next
NEW_VERSION="$MAJOR.$((MINOR + 1)).0-SNAPSHOT"
else
# Keep current SNAPSHOT version - no recent release activity
NEW_VERSION="$CURRENT_VERSION"
fi
;;
"main")
# Main should always have stable versions
# Check if we just merged a release branch and need to convert RC to stable
RECENT_RELEASE_MERGES=$(git log --oneline -5 --grep="Merge.*release.*into.*main" --grep="Merge.*release.*back.*main" --grep="Merge.*R.*back.*main" || true)
if [[ -n "$RECENT_RELEASE_MERGES" ]] && [[ "$CURRENT_VERSION" =~ -RC\.[0-9]+$ ]]; then
# We just merged a release and have an RC version, convert to stable
NEW_VERSION="${CURRENT_VERSION%-RC.*}"
echo "Release merge detected, converting RC version to stable: $NEW_VERSION"
else
# No recent release merge or already stable, keep current version
NEW_VERSION="$CURRENT_VERSION"
fi
;;
release/*)
# Extract major.minor from branch name (e.g., release/1.5 -> 1.5.0-RC.n)
if [[ "$branch" =~ release/([0-9]+)\.([0-9]+) ]]; then
BRANCH_MAJOR=${BASH_REMATCH[1]}
BRANCH_MINOR=${BASH_REMATCH[2]}
# Check if we already have an RC version
if [[ "$CURRENT_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-RC\.([0-9]+)$ ]]; then
# Extract current RC number and increment it
CURRENT_RC=${BASH_REMATCH[4]}
NEW_RC=$((CURRENT_RC + 1))
NEW_VERSION="$BRANCH_MAJOR.$BRANCH_MINOR.0-RC.$NEW_RC"
else
# First RC for this release
NEW_VERSION="$BRANCH_MAJOR.$BRANCH_MINOR.0-RC.1"
fi
else
echo "ERROR: Invalid release branch format: $branch"
exit 1
fi
;;
hotfix/*)
# Bump patch version for hotfix
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
;;
feature/*|*)
# Feature branches inherit version from develop, no changes
NEW_VERSION="$CURRENT_VERSION"
;;
esac
}
# Function to set version using Maven
set_version() {
local new_version=$1
if [[ "$DRY_RUN" == "true" ]]; then
echo "DRY RUN: Would set version to: $new_version"
echo "Command: mvn versions:set-property -Dproperty=revision -DnewVersion=$new_version -DgenerateBackupPoms=false"
return
fi
echo "Setting version to: $new_version"
# Use Maven versions plugin to set version
mvn versions:set-property -Dproperty=revision -DnewVersion="$new_version" -DgenerateBackupPoms=false
# Verify the change
ACTUAL_VERSION=$(grep "<revision>" $POM_FILE | sed 's/.*<revision>//;s/<.*//')
if [[ "$ACTUAL_VERSION" == "$new_version" ]]; then
echo "✅ Version successfully updated to: $ACTUAL_VERSION"
else
echo "❌ Version update failed. Expected: $new_version, Got: $ACTUAL_VERSION"
exit 1
fi
}
# Main execution
main() {
echo "=== QQQ Version Calculator ==="
echo "Branch: $CURRENT_BRANCH"
echo "Current version: $CURRENT_VERSION"
echo ""
# Extract version components
extract_version_parts "$CURRENT_VERSION"
echo "Version components: MAJOR=$MAJOR, MINOR=$MINOR, PATCH=$PATCH"
echo ""
# Calculate next version
calculate_next_version "$CURRENT_BRANCH"
echo "Calculated next version: $NEW_VERSION"
echo ""
# Set the version if it's different
if [[ "$NEW_VERSION" != "$CURRENT_VERSION" ]]; then
echo "Version change detected: $CURRENT_VERSION → $NEW_VERSION"
set_version "$NEW_VERSION"
# Show git diff
echo ""
echo "Changes made:"
git diff $POM_FILE
else
echo "No version change needed. Current version is correct for branch: $CURRENT_BRANCH"
fi
echo ""
echo "=== Version calculation complete ==="
}
# Run main function
main "$@"
-711
View File
@@ -1,711 +0,0 @@
###############################################################################
##
## CircleCI Configuration for QQQ Frontend Material Dashboard
## =========================================================
##
## This configuration implements a GitFlow-based CI/CD strategy for the frontend dashboard,
## following the same versioning and branching policies as the main QQQ project.
##
## 🚀 WORKFLOWS OVERVIEW:
## ----------------------
## 1. test_only - Feature branches (build, test, coverage)
## 2. deploy_snapshot - develop branch (publishes -SNAPSHOT versions to Maven Central + Public NPM)
## 3. release_candidate - release/* branches (publishes -RC.n versions to Maven Central + Public NPM)
## 4. production_release - main branch (publishes stable versions to Maven Central + Public NPM + GitHub releases)
## 5. hotfix_release - hotfix/* branches (publishes patch versions to Maven Central + Public NPM + GitHub releases)
##
## 🌿 GITFLOW BRANCHING STRATEGY:
## ------------------------------
## - main: Production releases (X.Y.Z) → Maven Central releases + Public NPM + GitHub releases
## - develop: Development snapshots (X.Y.Z-SNAPSHOT) → Maven Central snapshots + Public NPM
## - release/*: Release candidates (X.Y.0-RC.n) → Maven Central releases + Public NPM
## - hotfix/*: Hotfix releases (X.Y.(Z+1)) → Maven Central releases + Public NPM + GitHub releases
## - feature/*: Feature development → Build and test only (no publishing)
##
## 🔄 VERSION MANAGEMENT:
## ---------------------
## - Maven versions: Automatically calculated using .circleci/calculate-version.sh
## - GitFlow versioning: RC increments, hotfix patches, develop bumps
## - Automatic Git tags: vX.Y.Z format (e.g., v1.0.0)
## - GitHub releases: Created automatically for production and hotfix releases
## - Maven Central: Publishing via central-publishing-maven-plugin
##
## 🔐 AUTHENTICATION & SECURITY:
## -----------------------------
## - Maven Central: CENTRAL_USERNAME, CENTRAL_PASSWORD
## - GPG Signing: GPG_PRIVATE_KEY_B64, GPG_KEYNAME, GPG_PASSPHRASE
## - GitHub Integration: GITHUB_TOKEN (for creating releases and tags)
## - NPM Registry: NPM_TOKEN (for public NPM package access)
## - All artifacts are GPG signed for verification
## - Credentials stored securely as environment variables
##
## 🛠️ BUILD TOOLS & DEPENDENCIES:
## ------------------------------
## - localstack/platform@2.1: Consistent execution environment
## - browser-tools@1.4.7: Chrome/ChromeDriver for testing
## - Maven: Java build tool and dependency management
## - Node.js: JavaScript runtime and package management
## - npm: Node.js package manager with React build tools
##
## 📁 KEY SCRIPTS & FILES:
## ------------------------
## - calculate-version.sh: Maven version management based on branch type
## - sync-npm-version.sh: NPM version synchronization with Maven
## - mvn-settings.xml: Maven Central repository configuration
## - config.yml: This CircleCI configuration file
##
## 🎯 VERSION PATTERNS BY BRANCH:
## ------------------------------
## | Branch Type | Version Pattern | Example | Repository |
## |-------------|----------------|---------|------------|
## | main | X.Y.Z | 1.0.0 | Maven Central (releases) |
## | develop | X.Y.Z-SNAPSHOT | 1.0.0-SNAPSHOT | Maven Central (snapshots) |
## | release/* | X.Y.0-RC.n | 1.0.0-RC.1 | Maven Central (releases) |
## | hotfix/* | X.Y.(Z+1) | 1.0.1 | Maven Central (releases) |
## | feature/* | Inherits from develop | 1.0.0-SNAPSHOT | No publishing |
##
###############################################################################
version: 2.1
###############################################################################
## ORBS (Reusable CI Components)
## =============================
## localstack/platform@2.1: Provides consistent execution environment across all jobs
## browser-tools@1.4.7: Installs Chrome and ChromeDriver for browser-based testing
###############################################################################
orbs:
localstack: localstack/platform@2.1
browser-tools: circleci/browser-tools@1.4.7
slack: circleci/slack@5.2.1
###############################################################################
## COMMANDS (Reusable Step Collections)
## ===================================
## These commands define common operations that can be reused across multiple jobs
## to avoid duplication and ensure consistency.
###############################################################################
commands:
###############################################################################
## 🏗️ FRONTEND BUILD COMMAND
## ==========================
## Builds the frontend project and sets up the complete development environment
##
## What it does:
## - Restores Maven dependency cache for faster builds
## - Restores NPM dependency cache for faster builds
## - Installs Chrome/ChromeDriver for browser testing
## - Installs Node.js dependencies (npm install --legacy-peer-deps)
## - Compiles the project with Maven (Java components)
## - Builds React application (npm run build)
## - Saves both Maven and NPM caches for future builds
##
## Cache Strategy:
## - Maven: Based on pom.xml checksum
## - NPM: Based on package.json checksum
## - Both caches are saved together for consistency
###############################################################################
frontend_build:
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
- v1-npm-dependencies-{{ checksum "package.json" }}
- browser-tools/install-chrome
- browser-tools/install-chromedriver
- run:
name: Setup NPM authentication
command: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
- run:
name: Install Node.js dependencies
command: |
npm install --legacy-peer-deps
- run:
name: Run Maven Compile
command: |
mvn -s .circleci/mvn-settings.xml -T4 --no-transfer-progress compile
- run:
name: Build React application
command: |
npm run build
- save_cache:
paths:
- ~/.m2
- node_modules
key: v1-dependencies-{{ checksum "pom.xml" }}
###############################################################################
## 🚀 FRONTEND INTEGRATION TEST COMMAND
## =====================================
## Runs integration tests with the React app running
##
## What it does:
## - Sets up environment variables for React app
## - Starts React app in background
## - Waits for app to be ready using dockerize
## - Runs Maven verify with app running
## - Collects test results and screenshots
##
## Integration Testing:
## - React app runs on port 3001
## - Proxy configured for localhost:8001
## - Selenium tests run against running app
## - Screenshots captured for debugging
###############################################################################
frontend_test:
steps:
- checkout
# Ensure no stale Chrome/Driver is shadowing the PATH (your base image had Chrome 109)
- run:
name: Remove any preinstalled Chrome/ChromeDriver
command: |
sudo apt-get remove -y google-chrome-stable || true
sudo rm -f /usr/bin/google-chrome /opt/google/chrome/chrome || true
sudo rm -f /usr/local/bin/chromedriver /usr/bin/chromedriver || true
# Install current Chrome; DO NOT install chromedriver (let Selenium 4 auto-manage it)
- browser-tools/install-chrome
# System libs Chrome needs in headless CI
- run:
name: Install browser dependencies
command: |
sudo apt-get update
sudo apt-get install -y \
libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev
# Utility to wait for the dev server to come up
- run:
name: Install dockerize (wait-for utility)
command: |
DOCKERIZE_VERSION=v0.3.0
wget -q https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
# Restore Maven deps (Node deps are expected from prior build step; optional guard below)
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
# (Optional) Guard: if node_modules is missing, install it quickly so "npm run build" works
- run:
name: Ensure Node dependencies exist (optional guard)
command: |
if [ ! -d node_modules ]; then
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc || true
npm ci --legacy-peer-deps
fi
# Diagnostics: confirm Chrome present; ensure no chromedriver on PATH (Selenium should fetch it)
- run:
name: Chrome diagnostics
command: |
which google-chrome || true
google-chrome --version || /opt/google/chrome/chrome --version || true
which chromedriver || echo "chromedriver not present (expected)"
env | grep -i -E 'chrome|driver|selenium' || true
# Build the React app, start it, wait until it's live, then run Selenium tests via Maven.
# Note: Using 'mvn test' to avoid GPG signing during testing phase.
# GPG signing will happen later in mvn_jar_deploy when deploying to Maven Central.
- run:
name: Build app, start server, run tests
command: |
echo "HTTPS=true" >> ./.env
npm run build
export REACT_APP_PROXY_LOCALHOST_PORT=8001
export PORT=3001
npm run start &
dockerize -wait tcp://localhost:3001 -timeout 3m
export QQQ_SELENIUM_HEADLESS=true
mvn -s .circleci/mvn-settings.xml --no-transfer-progress -B test
# Always collect and publish test results & screenshots
- run:
name: Collect JUnit XML test results
when: always
command: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \; || true
- store_test_results:
path: ~/test-results
- store_artifacts:
path: /tmp/QSeleniumScreenshots
when: always
# Re-cache Maven deps
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
###############################################################################
## 📦 MAVEN CENTRAL PUBLISHING COMMAND
## ===================================
## Publishes signed artifacts to Maven Central (Sonatype Central Portal)
##
## What it does:
## - Sets up GPG signing for artifact verification and security
## - Runs verify phase with GPG signing to ensure artifacts are properly signed
## - Deploys signed artifacts to Maven Central using release profile
## - Handles authentication and repository configuration
## - Saves Maven cache for future builds
##
## Security Features:
## - GPG signing for all artifacts (verification)
## - Secure credential management via environment variables
## - Repository isolation (snapshots vs releases)
###############################################################################
mvn_jar_deploy:
steps:
- run:
name: Setup GPG for signing
command: |
mkdir -p ~/.gnupg
echo 'pinentry-mode loopback' > ~/.gnupg/gpg.conf
chmod 600 ~/.gnupg/gpg.conf
echo $GPG_PRIVATE_KEY_B64| tr -d ' \r\n\t' | base64 -d | gpg --batch --import
- run:
name: Verify build with GPG signing (skip tests)
command: |
mvn -s .circleci/mvn-settings.xml -P release -B -DskipTests -Dgpg.keyname=$GPG_KEYNAME -Dgpg.passphrase=$GPG_PASSPHRASE verify
- run:
name: Publish to Sonatype Central (releases and SNAPSHOTs)
command: |
mvn -s .circleci/mvn-settings.xml -P release -B -DskipTests -Dgpg.keyname=$GPG_KEYNAME -Dgpg.passphrase=$GPG_PASSPHRASE deploy
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
###############################################################################
## 📦 FRONTEND PACKAGING COMMAND
## =============================
## Packages the React app into the Maven JAR for distribution
##
## What it does:
## - Removes old material-dashboard resources
## - Creates new material-dashboard directory
## - Copies built React app to Maven resources
## - Prepares JAR for deployment
##
## Frontend Integration:
## - React build artifacts packaged into Maven JAR
## - Enables distribution as single artifact
## - Maintains frontend-backend integration
###############################################################################
frontend_package:
steps:
- run:
name: Package React app into Maven JAR
command: |
rm -rf src/main/resources/material-dashboard
mkdir -p src/main/resources/material-dashboard
cp -r build/* src/main/resources/material-dashboard
###############################################################################
## 🔄 VERSION MANAGEMENT COMMAND
## =============================
## Automated version management for GitFlow branching strategy
##
## What it does:
## - Determines appropriate version based on branch type and current version
## - Uses versions-maven-plugin to update pom.xml automatically
## - Synchronizes NPM version with Maven version using sync-npm-version.sh
## - Handles GitFlow versioning strategy automatically
## - Commits and pushes version changes to maintain consistency
##
## Version Strategy:
## - develop: Bumps to next minor version (X.Y+1.0-SNAPSHOT)
## - release/*: Increments RC number (X.Y.0-RC.n)
## - hotfix/*: Bumps patch version (X.Y.Z+1)
## - feature/*: No version changes (inherits from develop)
###############################################################################
manage_version:
steps:
- add_ssh_keys # injects the CircleCI User Key (write-capable)
- run:
name: Set up Git identity for version commits
command: |
git config user.email "ci@kingsrook.com"
git config user.name "CircleCI"
- run:
name: Calculate and set Maven version
command: |
chmod +x .circleci/calculate-version.sh
.circleci/calculate-version.sh
- run:
name: Commit version changes if modified
command: |
if [[ -n "$(git status --porcelain pom.xml)" ]]; then
NEW_VERSION=$(grep '<revision>' pom.xml | sed 's/.*<revision>//;s/<.*//')
git add pom.xml
git commit -m "Bump version to $NEW_VERSION [skip ci]"
git push origin "HEAD:${CIRCLE_BRANCH}"
echo "Version updated to: $NEW_VERSION and pushed"
else
echo "No version change needed"
fi
###############################################################################
## 🏷️ GITHUB RELEASE CREATION COMMAND
## ===================================
## Creates Git tags and GitHub releases for production and hotfix releases
##
## What it does:
## - Creates version tag from pom.xml revision (vX.Y.Z format)
## - Pushes tag to remote repository for version tracking
## - Creates GitHub release with automated notes and descriptions
## - Links releases to specific Git commits for traceability
##
## Release Types:
## - Production releases: Stable versions from main branch
## - Hotfix releases: Patch versions from hotfix branches
## - All releases include Git tags and GitHub release notes
###############################################################################
create_github_release:
steps:
- run:
name: Create and push version tag
command: |
VERSION=$(grep '<revision>' pom.xml | sed 's/.*<revision>//;s/<.*//')
echo "Creating tag for version: $VERSION"
# Create and push tag (if not already created)
if ! git tag --list | grep -q "v$VERSION"; then
git tag "v$VERSION"
git push origin "v$VERSION"
echo "Tag v$VERSION created and pushed"
else
echo "Tag v$VERSION already exists"
fi
# Create GitHub release
echo "Creating GitHub release for v$VERSION"
# Install GitHub CLI if not available
if ! command -v gh &> /dev/null; then
echo "Installing GitHub CLI..."
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt-get update
apt-get install -y gh
fi
echo "$GITHUB_TOKEN" | gh auth login --with-token
gh release create "v$VERSION" \
--title "Release v$VERSION" \
--notes "Automated release from CircleCI" \
--repo Kingsrook/qqq-frontend-material-dashboard
###############################################################################
## JOBS (Workflow Execution Units)
## ===============================
## Jobs define the actual work to be done in each workflow.
## Each job uses the localstack/default executor for consistent environment.
###############################################################################
jobs:
###############################################################################
## 🏗️ BUILD JOB
## =============
## Basic build job that compiles the frontend project
##
## Purpose: Compile and build the complete frontend application
## Used by: test_only workflow for feature branches
##
## What it does:
## - Sets up development environment
## - Installs all dependencies (Maven + NPM)
## - Compiles Java components with Maven
## - Builds React application with npm
## - Manages dependency caching for performance
###############################################################################
build:
executor: localstack/default
steps:
- frontend_build
###############################################################################
## 🧪 TEST JOB
## ===========
## Comprehensive testing job that runs all tests
##
## Purpose: Validate code quality and functionality
## Used by: test_only workflow for feature branches
## Dependencies: Requires build job to complete first
##
## What it does:
## - Runs Maven verify lifecycle (compile, test, package, verify)
## - Executes NPM tests with coverage reporting
## - Collects test artifacts and coverage reports
## - Stores results as CircleCI artifacts for analysis
###############################################################################
test:
executor: localstack/default
steps:
- frontend_test
###############################################################################
## 📦 SNAPSHOT DEPLOYMENT JOB
## ===========================
## Deploys snapshot versions to Maven Central
##
## Purpose: Provide nightly builds for developers and QA testing
## Used by: deploy_snapshot workflow for develop branch
## Publishes: X.Y.Z-SNAPSHOT versions to snapshots repository
##
## What it does:
## - Builds the complete frontend project
## - Manages versions (Maven + NPM sync)
## - Runs comprehensive tests
## - Deploys to Maven Central snapshots repository
## - Enables continuous integration and nightly builds
###############################################################################
mvn_deploy:
executor: localstack/default
steps:
- frontend_build
- manage_version
- frontend_test
- frontend_package
- mvn_jar_deploy
###############################################################################
## 🧪 RELEASE CANDIDATE JOB
## =========================
## Publishes release candidate versions to Maven Central
##
## Purpose: Provide RC builds for QA testing and stakeholder review
## Used by: release_candidate workflow for release/* branches
## Publishes: X.Y.0-RC.n versions to releases repository
##
## What it does:
## - Builds the complete frontend project
## - Runs comprehensive tests for quality assurance
## - Manages versions (RC increments)
## - Deploys to Maven Central releases repository
## - Prepares stable versions for production deployment
###############################################################################
publish_rc:
executor: localstack/default
steps:
- frontend_build
- frontend_test
- manage_version
- frontend_package
- mvn_jar_deploy
###############################################################################
## 🚀 PRODUCTION RELEASE JOB
## ==========================
## Publishes production releases to Maven Central and creates GitHub releases
##
## Purpose: Deploy stable versions to production and create GitHub releases
## Used by: production_release workflow for main branch
## Publishes: X.Y.Z versions to releases repository
## Creates: Git tags and GitHub releases automatically
##
## What it does:
## - Builds the complete frontend project
## - Manages versions (stable release)
## - Runs comprehensive tests for production validation
## - Deploys to Maven Central releases repository
## - Creates Git tags (vX.Y.Z) for version tracking
## - Creates GitHub releases with automated notes
###############################################################################
publish_release:
executor: localstack/default
steps:
- frontend_build
- manage_version
- frontend_test
- frontend_package
- mvn_jar_deploy
- create_github_release
###############################################################################
## 🔥 HOTFIX RELEASE JOB
## ======================
## Publishes hotfix releases to Maven Central and creates GitHub releases
##
## Purpose: Deploy critical bug fixes and security patches
## Used by: hotfix_release workflow for hotfix/* branches
## Publishes: X.Y.(Z+1) versions to releases repository
## Creates: Git tags and GitHub releases automatically
##
## What it does:
## - Builds the complete frontend project
## - Manages versions (patch increment)
## - Runs comprehensive tests for hotfix validation
## - Deploys to Maven Central releases repository
## - Creates Git tags (vX.Y.Z+1) for version tracking
## - Creates GitHub releases with automated notes
## - Enables urgent production fixes
###############################################################################
publish_hotfix:
executor: localstack/default
steps:
- frontend_build
- manage_version
- frontend_test
- frontend_package
- mvn_jar_deploy
- create_github_release
###############################################################################
## WORKFLOWS (CI/CD Pipeline Orchestration)
## =======================================
## Workflows define when and how jobs are executed based on branch patterns and triggers.
## Each workflow implements a specific part of the GitFlow branching strategy.
###############################################################################
workflows:
###############################################################################
## 🧪 TEST ONLY WORKFLOW
## =====================
## Runs on feature branches and other non-protected branches
##
## Purpose: Validate code quality and functionality before merging
## Triggers: Any push to branches NOT matching develop, main, release/*, hotfix/*
## Jobs: build → test (sequential execution)
##
## What it does:
## - Builds the frontend project
## - Runs comprehensive tests
## - Generates coverage reports
## - Stores build artifacts and test results
###############################################################################
test_only:
jobs:
- build:
context: [ qqq-maven-registry-credentials, build-qqq-sample-app ]
filters:
branches:
ignore: /(develop|main|release/.*|hotfix/.*)/
tags:
ignore: /(version|snapshot)-.*/
- test:
context: [ qqq-maven-registry-credentials, build-qqq-sample-app ]
requires:
- build
filters:
branches:
ignore: /(develop|main|release/.*|hotfix/.*)/
tags:
ignore: /(version|snapshot)-.*/
###############################################################################
## 📦 SNAPSHOT DEPLOYMENT WORKFLOW
## =================================
## Runs on develop branch to publish development snapshots
##
## Purpose: Provide nightly builds for developers and QA testing
## Triggers: Push to develop branch
## Publishes: X.Y.Z-SNAPSHOT versions to Maven Central snapshots repository
## Jobs: mvn_deploy (Maven Central publishing)
##
## What it does:
## - Builds and tests the frontend project
## - Manages versions (Maven + NPM sync)
## - Deploys to Maven Central snapshots
## - Enables continuous integration and nightly builds
###############################################################################
deploy_snapshot:
jobs:
- mvn_deploy:
context: [ qqq-maven-registry-credentials, build-qqq-sample-app ]
filters:
branches:
only:
- develop
###############################################################################
## 🧪 RELEASE CANDIDATE WORKFLOW
## =============================
## Runs on release/* branches to publish release candidates
##
## Purpose: Provide RC builds for QA testing and stakeholder review
## Triggers: Push to any branch matching release/* pattern
## Publishes: X.Y.0-RC.n versions to Maven Central releases repository
## Jobs: publish_rc (build, test, RC artifact creation)
##
## What it does:
## - Builds and tests the frontend project
## - Manages versions (RC increments)
## - Deploys to Maven Central releases
## - Prepares stable versions for production
###############################################################################
release_candidate:
jobs:
- publish_rc:
context: [ qqq-maven-registry-credentials, build-qqq-sample-app ]
filters:
branches:
only:
- /release\/.*/
###############################################################################
## 🚀 PRODUCTION RELEASE WORKFLOW
## ===============================
## Runs on main branch to publish production releases
##
## Purpose: Deploy stable versions to production and create GitHub releases
## Triggers: Push to main branch (typically after merging release branches)
## Publishes: X.Y.Z versions to Maven Central releases repository
## Creates: Git tags (vX.Y.Z) and GitHub releases automatically
## Jobs: publish_release (build, test, Maven Central deploy, GitHub release)
##
## What it does:
## - Builds and tests the frontend project
## - Manages versions (stable release)
## - Deploys to Maven Central releases
## - Creates Git tags for version tracking
## - Creates GitHub releases with automated notes
###############################################################################
production_release:
jobs:
- publish_release:
context: [ qqq-maven-registry-credentials, build-qqq-sample-app ]
filters:
branches:
only:
- main
tags:
only:
- /v.*/
###############################################################################
## 🔥 HOTFIX RELEASE WORKFLOW
## ===========================
## Runs on hotfix/* branches to publish urgent production fixes
##
## Purpose: Deploy critical bug fixes and security patches
## Triggers: Push to any branch matching hotfix/* pattern
## Publishes: X.Y.(Z+1) versions to Maven Central releases repository
## Creates: Git tags (vX.Y.(Z+1)) and GitHub releases automatically
## Jobs: publish_hotfix (build, test, Maven Central deploy, GitHub release)
##
## What it does:
## - Builds and tests the frontend project
## - Manages versions (patch increment)
## - Deploys to Maven Central releases
## - Creates Git tags for version tracking
## - Creates GitHub releases with automated notes
## - Enables urgent production fixes
###############################################################################
hotfix_release:
jobs:
- publish_hotfix:
context: [ qqq-maven-registry-credentials, build-qqq-sample-app ]
filters:
branches:
only:
- /hotfix\/.*/
-18
View File
@@ -1,18 +0,0 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<!-- Sonatype Central Portal credentials (for releases) -->
<server>
<id>central</id>
<username>${env.CENTRAL_USERNAME}</username>
<password>${env.CENTRAL_PASSWORD}</password>
</server>
<!-- Central Portal Snapshots credentials -->
<server>
<id>central-snapshots</id>
<username>${env.CENTRAL_USERNAME}</username>
<password>${env.CENTRAL_PASSWORD}</password>
</server>
</servers>
</settings>
-78
View File
@@ -1,78 +0,0 @@
#!/bin/bash
############################################################################
## sync-npm-version.sh
## Synchronizes NPM package.json version with Maven pom.xml version
##
## This script reads the version from pom.xml and updates package.json
## to maintain consistency between Maven and NPM versions.
##
## Usage: ./sync-npm-version.sh [--dry-run]
## Output: Updates package.json version to match pom.xml revision
############################################################################
set -e
# Configuration
POM_FILE="pom.xml"
PACKAGE_JSON="package.json"
DRY_RUN=false
# Parse command line arguments
if [[ "$1" == "--dry-run" ]]; then
DRY_RUN=true
echo "DRY RUN MODE - No changes will be made"
fi
# Get current versions
MAVEN_VERSION=$(grep '<revision>' $POM_FILE | sed 's/.*<revision>//;s/<.*//')
NPM_VERSION=$(grep '"version"' $PACKAGE_JSON | sed 's/.*"version": "//;s/".*//')
echo "Current Maven version: $MAVEN_VERSION"
echo "Current NPM version: $NPM_VERSION"
# Convert Maven version to NPM format
# Maven: 1.0.0-SNAPSHOT -> NPM: 1.0.0-SNAPSHOT
# Maven: 1.0.0-RC.1 -> NPM: 1.0.0-rc.1
# Maven: 1.0.0 -> NPM: 1.0.0
NPM_FORMATTED_VERSION=$(echo "$MAVEN_VERSION" | sed 's/-RC\./-rc./g')
echo "Formatted NPM version: $NPM_FORMATTED_VERSION"
# Check if versions are already in sync
if [[ "$NPM_VERSION" == "$NPM_FORMATTED_VERSION" ]]; then
echo "✅ Versions are already synchronized"
exit 0
fi
# Update package.json version
if [[ "$DRY_RUN" == "true" ]]; then
echo "DRY RUN: Would update package.json version from '$NPM_VERSION' to '$NPM_FORMATTED_VERSION'"
echo "Command: sed -i 's/\"version\": \"$NPM_VERSION\"/\"version\": \"$NPM_FORMATTED_VERSION\"/' $PACKAGE_JSON"
exit 0
fi
echo "Updating package.json version from '$NPM_VERSION' to '$NPM_FORMATTED_VERSION'"
# Use sed to update the version in package.json (macOS compatible)
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS requires an empty string for -i
sed -i '' "s/\"version\": \"$NPM_VERSION\"/\"version\": \"$NPM_FORMATTED_VERSION\"/" $PACKAGE_JSON
else
# Linux uses -i without empty string
sed -i "s/\"version\": \"$NPM_VERSION\"/\"version\": \"$NPM_FORMATTED_VERSION\"/" $PACKAGE_JSON
fi
# Verify the change
ACTUAL_NPM_VERSION=$(grep '"version"' $PACKAGE_JSON | sed 's/.*"version": "//;s/".*//')
if [[ "$ACTUAL_NPM_VERSION" == "$NPM_FORMATTED_VERSION" ]]; then
echo "✅ NPM version successfully updated to: $ACTUAL_NPM_VERSION"
else
echo "❌ NPM version update failed. Expected: $NPM_FORMATTED_VERSION, Got: $ACTUAL_NPM_VERSION"
exit 1
fi
echo ""
echo "=== NPM version synchronization complete ==="
echo "Maven: $MAVEN_VERSION"
echo "NPM: $ACTUAL_NPM_VERSION"
+46
View File
@@ -0,0 +1,46 @@
name: 'CI/CD Pipeline'
on:
push:
branches: [ main, develop, 'release/*', 'hotfix/*', 'feature/*' ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
jobs:
publish:
name: '🚀 Build, Test, and Publish Release (main, rc, hotfix, or snapshot)'
if: |
github.ref_name == 'main' ||
github.ref_name == 'develop' ||
startsWith(github.ref_name, 'release/') ||
startsWith(github.ref_name, 'hotfix/')
uses: Kingsrook/github-actions-library/.github/workflows/reusable-gitflow-publish.yml@release/0.1.0
with:
project-type: 'maven'
java-version: '17'
maven-args: '-B -q'
maven-working-directory: '.'
secrets:
GPG_PRIVATE_KEY_B64: ${{ secrets.GPG_PRIVATE_KEY_B64 }}
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
test:
name: '🧪 Build and Test Only'
if: |
!(
github.ref_name == 'main' ||
github.ref_name == 'develop' ||
startsWith(github.ref_name, 'release/') ||
startsWith(github.ref_name, 'hotfix/')
)
uses: Kingsrook/github-actions-library/.github/workflows/reusable-gitflow-test.yml@release/0.1.0
with:
project-type: 'maven'
java-version: '17'
maven-args: '-B -q'
maven-working-directory: '.'