Compare commits

..
7 Commits
25 changed files with 362 additions and 29 deletions

No files matched your search

+79 -27
View File
@@ -1,23 +1,24 @@
# QQQ Orb Development Makefile
# Provides convenient commands for orb development, validation, and publishing
.PHONY: help pack validate clean test publish dev
.PHONY: help pack validate clean test publish-snapshot publish-release dev check-clean check-branch
# Default target
help:
@echo "QQQ Orb Development Commands:"
@echo ""
@echo " make pack - Pack the orb using 'orb pack' (recommended for orb development)"
@echo " make validate - Validate the packed orb"
@echo " make test - Pack and validate the orb"
@echo " make clean - Remove packed orb files"
@echo " make dev - Development workflow: pack, validate, and show status"
@echo " make lint - Run all CircleCI-style linting checks"
@echo " make publish - Show publishing instructions (requires manual steps)"
@echo " make pack - Pack the orb using 'orb pack' (recommended for orb development)"
@echo " make validate - Validate the packed orb"
@echo " make test - Pack and validate the orb"
@echo " make clean - Remove packed orb files"
@echo " make dev - Development workflow: pack, validate, and show status"
@echo " make lint - Run all CircleCI-style linting checks"
@echo " make publish-snapshot - Interactive snapshot release (dev:snapshot)"
@echo " make publish-release - Interactive production release (tagged version)"
@echo ""
@echo "Key Files:"
@echo " src/@orb.yml - Main orb definition"
@echo " target/qqq-orb-packed.yml - Packed orb (generated)"
@echo " src/@orb.yml - Main orb definition"
@echo " target/qqq-orb-packed.yml - Packed orb (generated)"
# Pack the orb using the correct command for orb development
pack:
@@ -80,25 +81,76 @@ dev: validate
@echo "Next steps:"
@echo " 1. Review the packed orb: cat target/qqq-orb-packed.yml"
@echo " 2. Test with a project configuration"
@echo " 3. Publish when ready: make publish"
@echo " 3. Publish when ready:"
@echo " - make publish-snapshot (for dev testing)"
@echo " - make publish-release (for production)"
# Show publishing instructions
publish:
@echo "🚀 Orb Publishing Instructions:"
# Check if working directory is clean
check-clean:
@if [ -n "$$(git status --porcelain)" ]; then \
echo "❌ Working directory is not clean. Commit changes first."; \
exit 1; \
fi
# Check if we're on the right branch for releases
check-branch:
@current=$$(git branch --show-current); \
if [ "$$current" != "main" ] && [ "$$current" != "master" ]; then \
echo "⚠️ Warning: You're on branch '$$current', not main/master"; \
echo " This is recommended for production releases."; \
read -p "Continue anyway? [y/N]: " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
exit 1; \
fi; \
fi
# Interactive snapshot release (dev:snapshot)
publish-snapshot: check-clean lint validate
@echo "🚀 Publishing Snapshot Release"
@echo ""
@echo "1. Ensure you're logged in to CircleCI CLI:"
@echo " circleci auth login"
@echo "This will publish to: kingsrook/qqq-orb@dev:snapshot"
@echo ""
@echo "2. Build the orb first (if not already done):"
@echo " make dev"
@read -p "Continue with snapshot release? [y/N]: " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "❌ Release cancelled"; \
exit 1; \
fi; \
echo ""; \
echo "📦 Publishing snapshot..."; \
circleci orb publish target/qqq-orb-packed.yml kingsrook/qqq-orb@dev:snapshot; \
echo "✅ Snapshot published successfully!"
# Interactive production release (tagged version)
publish-release: check-clean check-branch lint validate
@echo "🚀 Publishing Production Release"
@echo ""
@echo "3. Publish the orb:"
@echo " circleci orb publish target/qqq-orb-packed.yml kingsrook/qqq-orb@dev:alpha"
@echo "This will create a git tag and publish a production version."
@echo ""
@echo "4. For production release:"
@echo " circleci orb publish target/qqq-orb-packed.yml kingsrook/qqq-orb@2.1.0"
@echo ""
@echo "5. Promote dev version to production:"
@echo " circleci orb publish promote kingsrook/qqq-orb@dev:alpha patch"
@echo ""
@echo "📚 More info: https://circleci.com/docs/orb-author/#publishing-an-orb"
@latest=$$(git tag -l 'v*' | sort -V | tail -1); \
if [ -n "$$latest" ]; then \
echo "Latest version: $$latest"; \
next=$$(echo "$$latest" | sed 's/^v//' | awk -F. '{$$NF++; print $$1"."$$2"."$$NF}'); \
echo "Suggested next version: v$$next"; \
else \
echo "No previous versions found. Starting with v0.1.0"; \
next="0.1.0"; \
fi; \
echo ""; \
read -p "Enter version [v$$next]: " version; \
version=$${version:-v$$next}; \
if [ "$$version" != "v$$(echo $$version | sed 's/^v//')" ]; then \
echo "❌ Version must start with 'v' (e.g., v1.0.0)"; \
exit 1; \
fi; \
if git tag -l | grep -q "^$$version$$"; then \
echo "❌ Tag $$version already exists"; \
exit 1; \
fi; \
echo ""; \
echo "Creating tag $$version..."; \
git tag -a "$$version" -m "Release $$version"; \
echo "Publishing kingsrook/qqq-orb@$$(echo $$version | sed 's/^v//')..."; \
circleci orb publish target/qqq-orb-packed.yml kingsrook/qqq-orb@$$(echo $$version | sed 's/^v//'); \
echo "Pushing tag to remote..."; \
git push origin "$$version"; \
echo "✅ Production release $$version published successfully!"
+1
View File
@@ -14,3 +14,4 @@ orbs:
localstack: localstack/platform@2.1
browser-tools: circleci/browser-tools@1.4.7
slack: circleci/slack@5.2.1
node: circleci/node@4.7
File renamed without changes.
+17
View File
@@ -0,0 +1,17 @@
description: >
Builds the package
- Cleans and builds the package
- Persists build artifacts to workspace for use in publishing jobs
steps:
- run:
name: "Clean and build"
command: npm run clean-and-install
# Persist build artifacts to workspace for use in publishing jobs
- persist_to_workspace:
root: .
paths:
- lib/ # Compiled TypeScript output
- package.json # Updated package manifest
- README.md # Documentation
- LICENSE # License file
+14
View File
@@ -0,0 +1,14 @@
description: >
Installs Node.js dependencies
- Installs Node.js dependencies using NPM
- Builds the TypeScript project
steps:
# Install packages with NPM, using CircleCI's optimized caching
- node/install-packages:
pkg-manager: npm
cache-path: node_modules
# Build TypeScript project after dependencies are installed
- run:
name: "Build TypeScript project"
command: npm run prepublishOnly
+18
View File
@@ -0,0 +1,18 @@
description: >
Manages the version of the project
- Adds SSH keys for Git operations
- Sets up Git identity for version commits
- Synchronizes NPM version
- Commits version changes if modified
steps:
- add_ssh_keys # injects the CircleCI User Key (write-capable)
- run:
name: Set up Git identity for version commits
command: <<include(scripts/node_git_config.sh)>>
- run:
name: "Synchronize NPM version"
command: <<include(scripts/sync-npm-version.sh)>>
- run:
name: Commit version changes if modified
command: <<include(scripts/node_version_commit.sh)>>
+12
View File
@@ -0,0 +1,12 @@
description: >
Publishes the package to NPM
- Sets up NPM authentication
- Publishes the package to NPM
steps:
- run:
name: "Setup NPM authentication"
command: <<include(scripts/node_npm_auth.sh)>>
- run:
name: "Publish to NPM"
command: npm publish --access public
+12
View File
@@ -0,0 +1,12 @@
description: >
Runs the tests and linting
- Runs the tests
- Runs the linting
steps:
- run:
name: "Run tests"
command: npm test
- run:
name: "Run linting"
command: npm run lint
+1 -1
View File
@@ -13,7 +13,7 @@ parameters:
steps:
- checkout
- manage_version
- mvn_manage_version
- frontend_build
- frontend_test
- frontend_package
+1 -1
View File
@@ -14,7 +14,7 @@ parameters:
steps:
- checkout
- mvn_build
- manage_version
- mvn_manage_version
- attach_workspace:
at: .
- mvn_verify
+22
View File
@@ -0,0 +1,22 @@
description: >
Unified publishing job for all branch types
Handles version management, building, testing, and publishing based on branch type
Supports: snapshot, release_candidate, release, and hotfix workflows
executor: localstack/default
parameters:
branch_type:
type: string
default: "snapshot"
description: "Branch type: snapshot, release_candidate, release, or hotfix"
steps:
- checkout
- node_install_dependencies
- node_run_tests
- node_manage_version
- attach_workspace:
at: .
- node_build_package
- node_publish
+17
View File
@@ -0,0 +1,17 @@
description: >
Unified test-only job for all branch types
Handles testing based on branch type
Supports: snapshot, release_candidate, release, and hotfix workflows
executor: localstack/default
parameters:
branch_type:
type: string
default: "snapshot"
description: "Branch type: snapshot, release_candidate, release, or hotfix"
steps:
- checkout
- node_install_dependencies
- node_run_tests
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
Regular → Executable
View File
File mode changed.
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
############################################################################
## node_git_config.sh
## Git Configuration Setup for Node.js Projects
##
## This script sets up Git identity for version commits in Node.js projects.
## It configures the Git user email and name for CircleCI operations.
##
## Usage: Called by node_manage_version command
## Output: Configures Git identity for CI operations
############################################################################
set -e
echo "Setting up Git identity for version commits"
git config user.email "ci@kingsrook.com"
git config user.name "CircleCI"
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
############################################################################
## node_npm_auth.sh
## NPM Authentication Setup Script
##
## This script configures NPM authentication for publishing to the public registry.
## It sets up the authentication token and verifies the authentication.
##
## Process:
## 1. Configures NPM authentication for public registry
## 2. Verifies authentication by checking current user
##
## Usage: Called by node_publish command
## Output: Sets up NPM authentication and verifies it
############################################################################
set -e
echo "Configuring NPM authentication for public registry"
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
echo "Verifying authentication by checking current user"
npm whoami
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
############################################################################
## node_version_commit.sh
## Node.js Version Commit Management Script
##
## This script handles committing version changes to Git for Node.js projects.
## It checks if the package.json file has been modified and commits the changes if needed.
## It also pushes the changes back to the current branch.
##
## Process:
## 1. Checks if package.json has been modified
## 2. Extracts the new version from package.json
## 3. Commits the changes with skip ci flag
## 4. Pushes changes to the current branch
##
## Usage: Called by node_manage_version command
## Output: Commits and pushes version changes if package.json was modified
############################################################################
set -e
echo "Checking for package.json version changes"
if [[ -n "$(git status --porcelain package.json)" ]]; then
NEW_VERSION=$(grep '"version"' package.json | sed 's/.*"version": "//;s/".*//')
git add package.json
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
+94
View File
@@ -0,0 +1,94 @@
#!/bin/bash
set -e
# NPM Version Synchronization Script for qqq-frontend-core
# This script updates package.json version based on the current GitFlow branch and versioning policy
PACKAGE_JSON="package.json"
DRY_RUN=false
if [[ "$1" == "--dry-run" ]]; then
DRY_RUN=true
echo "DRY RUN MODE - No changes will be made"
fi
# Get current branch
CURRENT_BRANCH=$(git branch --show-current)
echo "Current branch: $CURRENT_BRANCH"
# Get current NPM version
NPM_VERSION=$(grep '"version"' $PACKAGE_JSON | sed 's/.*"version": "//;s/".*//')
echo "Current NPM version: $NPM_VERSION"
# Determine target version based on GitFlow branch
if [[ "$CURRENT_BRANCH" == "main" ]]; then
# Main branch - should be a release version (e.g., 1.0.0)
# Extract major.minor from current version
MAJOR_MINOR="${NPM_VERSION%.*}"
TARGET_VERSION="$MAJOR_MINOR.0"
echo "Main branch detected - targeting release version: $TARGET_VERSION"
elif [[ "$CURRENT_BRANCH" == "develop" ]]; then
# Develop branch - should be a snapshot version (e.g., 1.0.127-SNAPSHOT)
# Increment patch version for develop
MAJOR_MINOR_PATCH="${NPM_VERSION%-*}"
MAJOR_MINOR="${MAJOR_MINOR_PATCH%.*}"
PATCH="${MAJOR_MINOR_PATCH##*.}"
NEW_PATCH=$((PATCH + 1))
TARGET_VERSION="$MAJOR_MINOR.$NEW_PATCH-SNAPSHOT"
echo "Develop branch detected - targeting snapshot version: $TARGET_VERSION"
elif [[ "$CURRENT_BRANCH" == release/* ]]; then
# Release branch - should be a release candidate (e.g., 1.0.0-RC.1)
RELEASE_VERSION=$(echo "$CURRENT_BRANCH" | sed 's/release\///')
TARGET_VERSION="$RELEASE_VERSION-RC.1"
echo "Release branch detected - targeting RC version: $TARGET_VERSION"
elif [[ "$CURRENT_BRANCH" == hotfix/* ]]; then
# Hotfix branch - should be a patch version (e.g., 1.0.1)
HOTFIX_VERSION=$(echo "$CURRENT_BRANCH" | sed 's/hotfix\///')
TARGET_VERSION="$HOTFIX_VERSION"
echo "Hotfix branch detected - targeting patch version: $TARGET_VERSION"
else
# Feature branch - should be a snapshot version
MAJOR_MINOR_PATCH="${NPM_VERSION%-*}"
MAJOR_MINOR="${MAJOR_MINOR_PATCH%.*}"
PATCH="${MAJOR_MINOR_PATCH##*.}"
NEW_PATCH=$((PATCH + 1))
TARGET_VERSION="$MAJOR_MINOR.$NEW_PATCH-SNAPSHOT"
echo "Feature branch detected - targeting snapshot version: $TARGET_VERSION"
fi
echo "Target version: $TARGET_VERSION"
if [[ "$NPM_VERSION" == "$TARGET_VERSION" ]]; then
echo "✅ Versions are already synchronized"
exit 0
fi
if [[ "$DRY_RUN" == "true" ]]; then
echo "DRY RUN: Would update package.json version from '$NPM_VERSION' to '$TARGET_VERSION'"
echo "Command: sed -i 's/\"version\": \"$NPM_VERSION\"/\"version\": \"$TARGET_VERSION\"/' $PACKAGE_JSON"
exit 0
fi
echo "Updating package.json version from '$NPM_VERSION' to '$TARGET_VERSION'"
# Update version in package.json (macOS compatible)
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/\"version\": \"$NPM_VERSION\"/\"version\": \"$TARGET_VERSION\"/" $PACKAGE_JSON
else
sed -i "s/\"version\": \"$NPM_VERSION\"/\"version\": \"$TARGET_VERSION\"/" $PACKAGE_JSON
fi
# Verify the update
ACTUAL_NPM_VERSION=$(grep '"version"' $PACKAGE_JSON | sed 's/.*"version": "//;s/".*//')
if [[ "$ACTUAL_NPM_VERSION" == "$TARGET_VERSION" ]]; then
echo "✅ NPM version successfully updated to: $ACTUAL_NPM_VERSION"
else
echo "❌ NPM version update failed. Expected: $TARGET_VERSION, Got: $ACTUAL_NPM_VERSION"
exit 1
fi
echo ""
echo "=== NPM version synchronization complete ==="
echo "Previous: $NPM_VERSION"
echo "Current: $ACTUAL_NPM_VERSION"
echo "Branch: $CURRENT_BRANCH"