diff --git a/Jenkinsfile b/Jenkinsfile index 3b130c5..01abc57 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,5 @@ pipeline { agent { label 'agent'} - parameters { - booleanParam(name: 'PUBLISH', defaultValue: false, description: 'Trigger publish stage') - } environment { NPM_AUTH_TOKEN = credentials('Appcircle-CLI-NPM-Cred') GITHUB_PAT = credentials('ozer-github-pat') @@ -228,9 +225,77 @@ pipeline { } } + stage('Auto Publish Alpha') { + when { + allOf { + anyOf { + branch 'develop' + branch pattern: 'pipeline/test-.*', comparator: 'REGEXP' + branch pattern: 'fixes/.*', comparator: 'REGEXP' + changeRequest() + } + not { changelog '.*\\[skip ci\\].*' } + not { buildingTag() } + } + } + steps { + sh '''#!/bin/bash + # shellcheck shell=bash + set -x + set -euo pipefail + + echo "πŸš€ Starting Auto Alpha Version Publish πŸš€" + echo "===========================================" + echo "πŸ“‹ Build Info:" + echo " Branch: ${GIT_BRANCH}" + echo " Build Number: ${BUILD_NUMBER}" + echo " Commit: ${GIT_COMMIT:0:8}" + echo "===========================================" + + # Configuration + REPO="appcircleio/appcircle-cli" + GIT_USER_EMAIL="ozer@appcircle.io" + GIT_USER_NAME="Γ–zer from Jenkins" + + # Install dependencies if needed + echo "πŸ“¦ Installing dependencies..." + [ ! -d "node_modules" ] && yarn install + + # Build the project + echo "βš™οΈ Building project..." + npm run build + + # Run tests + echo "πŸ§ͺ Running tests..." + npm test + + # Configure git + git config user.email "$GIT_USER_EMAIL" + git config user.name "$GIT_USER_NAME" + + # Bump alpha version + echo "πŸ“ˆ Bumping alpha version..." + npm run bump:version:alpha + + # Get the new version and tag + NEW_VERSION=$(node -p "require('./package.json').version") + TAG="v${NEW_VERSION}" + echo "πŸ“Œ New version: ${TAG}" + + # Push tag to trigger publish stage + echo "πŸ“€ Pushing tag ${TAG} to remote..." + git push "https://${GITHUB_PAT}@github.com/${REPO}.git" "$TAG" + + echo "βœ… Alpha version ${TAG} created and pushed!" + echo "🎯 This will trigger the Publish stage automatically." + echo "===========================================" + ''' + } + } + stage('Publish') { when { - expression { params.PUBLISH == true } + buildingTag() } steps { sh '''#!/bin/bash diff --git a/package-lock.json b/package-lock.json index ff257a8..3745926 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appcircle/cli", - "version": "2.7.6-alpha.3", + "version": "2.7.6-alpha.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appcircle/cli", - "version": "2.7.6-alpha.3", + "version": "2.7.6-alpha.4", "license": "MIT", "dependencies": { "axios": "^1.3.4", diff --git a/package.json b/package.json index db7bad0..e6d9082 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@appcircle/cli", - "version": "2.7.6-alpha.3", + "version": "2.7.6-alpha.4", "description": "CLI tool for running Appcircle services from the command line", "main": "bin/appcircle.js", "bin": {