maiass 5.10.2 → 5.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ci-templates.js +92 -0
- package/lib/maiass-pipeline.js +14 -76
- package/lib/update-check.js +53 -0
- package/maiass.mjs +15 -2
- package/package.json +2 -1
- package/templates/ci/bitbucket-pipelines-excerpt.yml +43 -0
- package/templates/ci/github-version-bump.yml +66 -0
- package/templates/ci/gitlab-ci-excerpt.yml +42 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import colors from './colors.js';
|
|
5
|
+
import { SYMBOLS } from './symbols.js';
|
|
6
|
+
|
|
7
|
+
// Resolve the templates directory relative to this file (works after npm install -g)
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const TEMPLATES_DIR = path.join(__dirname, '..', 'templates', 'ci');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Copy a CI template file to the target path in the current project.
|
|
13
|
+
* Creates intermediate directories if needed.
|
|
14
|
+
* Prompts before overwriting an existing file.
|
|
15
|
+
*/
|
|
16
|
+
function copyTemplate(templateFile, targetPath, label) {
|
|
17
|
+
const src = path.join(TEMPLATES_DIR, templateFile);
|
|
18
|
+
|
|
19
|
+
// Verify the template exists in the package
|
|
20
|
+
if (!fs.existsSync(src)) {
|
|
21
|
+
console.error(colors.Red(`${SYMBOLS.CROSS} Template not found: ${src}`));
|
|
22
|
+
console.error(colors.Gray('This may indicate a broken installation — try: npm install -g maiass'));
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Warn rather than silently overwrite
|
|
27
|
+
if (fs.existsSync(targetPath)) {
|
|
28
|
+
console.warn(colors.Yellow(`${SYMBOLS.WARNING} ${targetPath} already exists — skipping.`));
|
|
29
|
+
console.warn(colors.Gray(` Delete it first if you want a fresh copy.`));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Create parent directories (e.g. .github/workflows/)
|
|
34
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
35
|
+
fs.copyFileSync(src, targetPath);
|
|
36
|
+
|
|
37
|
+
console.log(colors.BGreen(`${SYMBOLS.CHECKMARK} Created ${targetPath}`));
|
|
38
|
+
console.log(colors.Gray(` ${label}`));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Print a template to stdout so the user can copy it manually.
|
|
43
|
+
* Used for Bitbucket where the file location varies per project.
|
|
44
|
+
*/
|
|
45
|
+
function showTemplate(templateFile, label) {
|
|
46
|
+
const src = path.join(TEMPLATES_DIR, templateFile);
|
|
47
|
+
|
|
48
|
+
if (!fs.existsSync(src)) {
|
|
49
|
+
console.error(colors.Red(`${SYMBOLS.CROSS} Template not found: ${src}`));
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log(colors.BGreen(`\n${label}\n`));
|
|
54
|
+
console.log(colors.Gray('─'.repeat(60)));
|
|
55
|
+
console.log(fs.readFileSync(src, 'utf8'));
|
|
56
|
+
console.log(colors.Gray('─'.repeat(60)));
|
|
57
|
+
console.log(colors.Gray('Copy the above into your bitbucket-pipelines.yml\n'));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Handle --create-gh-action
|
|
62
|
+
* Copies the GitHub Actions version-bump workflow into .github/workflows/
|
|
63
|
+
*/
|
|
64
|
+
export function createGithubAction() {
|
|
65
|
+
copyTemplate(
|
|
66
|
+
'github-version-bump.yml',
|
|
67
|
+
path.join(process.cwd(), '.github', 'workflows', 'maiass-version-bump.yml'),
|
|
68
|
+
'Next: add a GH_PAT secret in your repo → Settings → Secrets → Actions'
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Handle --show-gl-excerpt
|
|
74
|
+
* Prints the GitLab CI excerpt to stdout — users merge it into their existing .gitlab-ci.yml
|
|
75
|
+
*/
|
|
76
|
+
export function showGitlabExcerpt() {
|
|
77
|
+
showTemplate(
|
|
78
|
+
'gitlab-ci-excerpt.yml',
|
|
79
|
+
'MAIASS — GitLab CI excerpt (merge into your .gitlab-ci.yml)'
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Handle --show-bb-excerpt
|
|
85
|
+
* Prints the Bitbucket Pipelines excerpt to stdout — users merge it into their existing bitbucket-pipelines.yml
|
|
86
|
+
*/
|
|
87
|
+
export function showBitbucketExcerpt() {
|
|
88
|
+
showTemplate(
|
|
89
|
+
'bitbucket-pipelines-excerpt.yml',
|
|
90
|
+
'MAIASS — Bitbucket Pipelines excerpt (merge into your bitbucket-pipelines.yml)'
|
|
91
|
+
);
|
|
92
|
+
}
|
package/lib/maiass-pipeline.js
CHANGED
|
@@ -15,6 +15,7 @@ import { handleVersionCommand } from './version-command.js';
|
|
|
15
15
|
import { getSingleCharInput, getLineInput } from './input-utils.js';
|
|
16
16
|
import { updateChangelog as updateChangelogNew } from './changelog.js';
|
|
17
17
|
import { displayHeader } from './header.js';
|
|
18
|
+
import { checkForUpdates } from './update-check.js';
|
|
18
19
|
import { execSync } from 'child_process';
|
|
19
20
|
import path from 'path';
|
|
20
21
|
import fs from 'fs';
|
|
@@ -723,81 +724,6 @@ async function handleReleaseBranchWorkflow(newVersion, versionInfo, developBranc
|
|
|
723
724
|
}
|
|
724
725
|
}
|
|
725
726
|
|
|
726
|
-
/**
|
|
727
|
-
* Check for MAIASS version updates from npm registry
|
|
728
|
-
* @param {string} currentVersion - Current version to compare against
|
|
729
|
-
* @returns {Promise<Object>} Update check result
|
|
730
|
-
*/
|
|
731
|
-
async function checkForUpdates(currentVersion) {
|
|
732
|
-
try {
|
|
733
|
-
// Set a timeout to prevent hanging
|
|
734
|
-
const controller = new AbortController();
|
|
735
|
-
const timeoutId = setTimeout(() => controller.abort(), 3000); // 3 second timeout
|
|
736
|
-
|
|
737
|
-
const response = await fetch('https://registry.npmjs.org/maiass-dev', {
|
|
738
|
-
headers: {
|
|
739
|
-
'Accept': 'application/vnd.npm.install-v1+json',
|
|
740
|
-
'User-Agent': 'MAIASS-Version-Checker'
|
|
741
|
-
},
|
|
742
|
-
signal: controller.signal
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
clearTimeout(timeoutId);
|
|
746
|
-
|
|
747
|
-
if (!response.ok) {
|
|
748
|
-
return { updateAvailable: false, error: `HTTP ${response.status}` };
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
const registryData = await response.json();
|
|
752
|
-
const latestVersion = registryData['dist-tags']?.latest;
|
|
753
|
-
const releaseUrl = 'https://www.npmjs.com/package/maiass-dev';
|
|
754
|
-
|
|
755
|
-
if (!latestVersion) {
|
|
756
|
-
return { updateAvailable: false, error: 'No latest version found in npm registry' };
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
// Simple version comparison (assumes semantic versioning)
|
|
760
|
-
const current = currentVersion.split('.').map(num => parseInt(num, 10));
|
|
761
|
-
const latest = latestVersion.split('.').map(num => parseInt(num, 10));
|
|
762
|
-
|
|
763
|
-
let updateAvailable = false;
|
|
764
|
-
for (let i = 0; i < Math.max(current.length, latest.length); i++) {
|
|
765
|
-
const currentPart = current[i] || 0;
|
|
766
|
-
const latestPart = latest[i] || 0;
|
|
767
|
-
if (latestPart > currentPart) {
|
|
768
|
-
updateAvailable = true;
|
|
769
|
-
break;
|
|
770
|
-
} else if (latestPart < currentPart) {
|
|
771
|
-
break;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
return {
|
|
776
|
-
updateAvailable,
|
|
777
|
-
currentVersion,
|
|
778
|
-
latestVersion,
|
|
779
|
-
releaseUrl,
|
|
780
|
-
error: null
|
|
781
|
-
};
|
|
782
|
-
} catch (error) {
|
|
783
|
-
// Handle timeout and other errors gracefully
|
|
784
|
-
const errorMsg = error.name === 'AbortError' ? 'Request timeout' : error.message;
|
|
785
|
-
return { updateAvailable: false, error: errorMsg };
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
/**
|
|
790
|
-
* Display version information and update status
|
|
791
|
-
* @param {string} currentVersion - Current MAIASS version
|
|
792
|
-
*/
|
|
793
|
-
async function displayVersionInfo(currentVersion) {
|
|
794
|
-
// Display current version
|
|
795
|
-
logger.info(SYMBOLS.INFO, `MAIASS ${colors.Cyan(currentVersion)}`);
|
|
796
|
-
|
|
797
|
-
// Note: Update checking is disabled for nodemaiass as it's in active development
|
|
798
|
-
// and not following npm registry releases. Bashmaiass uses Homebrew for updates.
|
|
799
|
-
// TODO: Re-enable when nodemaiass is published to npm with stable releases
|
|
800
|
-
}
|
|
801
727
|
|
|
802
728
|
/**
|
|
803
729
|
* Main MAIASS pipeline orchestrator
|
|
@@ -818,6 +744,10 @@ export async function runMaiassPipeline(options = {}) {
|
|
|
818
744
|
|
|
819
745
|
// Display branded header with MAIASS's own version (not project version)
|
|
820
746
|
displayHeader(MAIASS_VERSION);
|
|
747
|
+
|
|
748
|
+
// Kick off update check in the background immediately so the network request
|
|
749
|
+
// runs concurrently with the rest of the pipeline — result shown at the end
|
|
750
|
+
const updateCheckPromise = checkForUpdates(MAIASS_VERSION);
|
|
821
751
|
|
|
822
752
|
// Get git info early to show current branch
|
|
823
753
|
const originalGitInfo = getGitInfo();
|
|
@@ -944,7 +874,15 @@ export async function runMaiassPipeline(options = {}) {
|
|
|
944
874
|
const topupEndpoint = process.env.MAIASS_TOPUP_ENDPOINT || 'https://maiass.net/top-up';
|
|
945
875
|
console.log(`${colors.BMagenta('Credit top-up link:')} ${colors.Blue(`${topupEndpoint}/${subscriptionId}`)}`);
|
|
946
876
|
}
|
|
947
|
-
|
|
877
|
+
|
|
878
|
+
// Show update notice if a newer version was found (check started at pipeline top)
|
|
879
|
+
const updateInfo = await updateCheckPromise;
|
|
880
|
+
if (updateInfo.updateAvailable) {
|
|
881
|
+
console.log('');
|
|
882
|
+
console.log(colors.Yellow(` ⬆ Update available: ${updateInfo.currentVersion} → ${updateInfo.latestVersion}`));
|
|
883
|
+
console.log(colors.Gray(` Run: npm install -g maiass`));
|
|
884
|
+
}
|
|
885
|
+
|
|
948
886
|
return {
|
|
949
887
|
success: true,
|
|
950
888
|
branchInfo,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check npm registry for a newer version of maiass.
|
|
3
|
+
* Resolves quickly (3s timeout) and never throws — callers can fire-and-forget.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} currentVersion - The currently running version (e.g. "5.10.3")
|
|
6
|
+
* @param {Function} [fetchFn] - Optional fetch override for testing
|
|
7
|
+
* @returns {Promise<{updateAvailable: boolean, currentVersion: string, latestVersion?: string, error?: string}>}
|
|
8
|
+
*/
|
|
9
|
+
export async function checkForUpdates(currentVersion, fetchFn = fetch) {
|
|
10
|
+
try {
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
const timeoutId = setTimeout(() => controller.abort(), 3000); // 3s timeout
|
|
13
|
+
|
|
14
|
+
const response = await fetchFn('https://registry.npmjs.org/maiass', {
|
|
15
|
+
headers: {
|
|
16
|
+
'Accept': 'application/vnd.npm.install-v1+json',
|
|
17
|
+
'User-Agent': 'MAIASS-Version-Checker'
|
|
18
|
+
},
|
|
19
|
+
signal: controller.signal
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
clearTimeout(timeoutId);
|
|
23
|
+
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
return { updateAvailable: false, currentVersion, error: `HTTP ${response.status}` };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const data = await response.json();
|
|
29
|
+
const latestVersion = data['dist-tags']?.latest;
|
|
30
|
+
|
|
31
|
+
if (!latestVersion) {
|
|
32
|
+
return { updateAvailable: false, currentVersion, error: 'No latest version in registry' };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Semantic version comparison — compares each part left to right
|
|
36
|
+
const current = currentVersion.split('.').map(n => parseInt(n, 10));
|
|
37
|
+
const latest = latestVersion.split('.').map(n => parseInt(n, 10));
|
|
38
|
+
|
|
39
|
+
let updateAvailable = false;
|
|
40
|
+
for (let i = 0; i < Math.max(current.length, latest.length); i++) {
|
|
41
|
+
const c = current[i] || 0;
|
|
42
|
+
const l = latest[i] || 0;
|
|
43
|
+
if (l > c) { updateAvailable = true; break; }
|
|
44
|
+
if (l < c) { break; }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { updateAvailable, currentVersion, latestVersion };
|
|
48
|
+
|
|
49
|
+
} catch (error) {
|
|
50
|
+
const msg = error.name === 'AbortError' ? 'Request timeout' : error.message;
|
|
51
|
+
return { updateAvailable: false, currentVersion, error: msg };
|
|
52
|
+
}
|
|
53
|
+
}
|
package/maiass.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { loadEnvironmentConfig, ensureConfigDirectories } from './lib/config.js'
|
|
|
12
12
|
// consistent with the project root.
|
|
13
13
|
import { execSync } from 'child_process';
|
|
14
14
|
try {
|
|
15
|
-
const gitRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
|
|
15
|
+
const gitRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
16
16
|
if (gitRoot && gitRoot !== process.cwd()) {
|
|
17
17
|
process.chdir(gitRoot);
|
|
18
18
|
}
|
|
@@ -52,6 +52,7 @@ import { handleMaiassCommand } from './lib/maiass-command.js';
|
|
|
52
52
|
import { handleAccountInfoCommand } from './lib/account-info.js';
|
|
53
53
|
import { SYMBOLS } from './lib/symbols.js';
|
|
54
54
|
import { bootstrapProject } from './lib/bootstrap.js';
|
|
55
|
+
import { createGithubAction, showGitlabExcerpt, showBitbucketExcerpt } from './lib/ci-templates.js';
|
|
55
56
|
|
|
56
57
|
// Simple CLI setup for pkg compatibility
|
|
57
58
|
const args = process.argv.slice(2);
|
|
@@ -130,7 +131,10 @@ const validFlags = [
|
|
|
130
131
|
'--force', '-f',
|
|
131
132
|
'--silent', '-s',
|
|
132
133
|
'--json',
|
|
133
|
-
'--tag', '-t'
|
|
134
|
+
'--tag', '-t',
|
|
135
|
+
'--create-gh-action',
|
|
136
|
+
'--show-gl-excerpt',
|
|
137
|
+
'--show-bb-excerpt'
|
|
134
138
|
];
|
|
135
139
|
|
|
136
140
|
// Check for unrecognized flags
|
|
@@ -187,9 +191,18 @@ if (args.includes('--help') || args.includes('-h') || command === 'help') {
|
|
|
187
191
|
console.log(' --dry-run Run without making changes');
|
|
188
192
|
console.log(' --force Skip confirmation prompts');
|
|
189
193
|
console.log(' --silent Suppress non-essential output');
|
|
194
|
+
console.log('\nCI Setup:');
|
|
195
|
+
console.log(' --create-gh-action Create .github/workflows/maiass-version-bump.yml');
|
|
196
|
+
console.log(' --show-gl-excerpt Print GitLab CI excerpt to stdout (merge into .gitlab-ci.yml)');
|
|
197
|
+
console.log(' --show-bb-excerpt Print Bitbucket Pipelines excerpt to stdout');
|
|
190
198
|
process.exit(0);
|
|
191
199
|
}
|
|
192
200
|
|
|
201
|
+
// CI template commands — these run and exit immediately, no pipeline needed
|
|
202
|
+
if (args.includes('--create-gh-action')) { createGithubAction(); process.exit(0); }
|
|
203
|
+
if (args.includes('--show-gl-excerpt')) { showGitlabExcerpt(); process.exit(0); }
|
|
204
|
+
if (args.includes('--show-bb-excerpt')) { showBitbucketExcerpt(); process.exit(0); }
|
|
205
|
+
|
|
193
206
|
// Command routing (wrapped in async IIFE to handle async commands)
|
|
194
207
|
(async () => {
|
|
195
208
|
// --setup/--bootstrap: run the full interactive wizard and exit
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maiass",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.10.
|
|
4
|
+
"version": "5.10.5",
|
|
5
5
|
"description": "AI commit message generator, semantic versioning, and changelog automation for Git. One command stages, commits with AI, bumps version, and merges branches. Free credits on install — no sign-up needed.",
|
|
6
6
|
"main": "maiass.mjs",
|
|
7
7
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"lib/",
|
|
23
|
+
"templates/",
|
|
23
24
|
"maiass.mjs",
|
|
24
25
|
"setup-env.js",
|
|
25
26
|
"README.md",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# MAIASS — Bitbucket Pipelines: Auto Version Bump on Push to Develop
|
|
2
|
+
#
|
|
3
|
+
# What this does:
|
|
4
|
+
# Runs `maiass -a patch` whenever a commit lands on your develop branch
|
|
5
|
+
# (including merged pull requests). Bumps the patch version, commits, and pushes.
|
|
6
|
+
#
|
|
7
|
+
# ⚠️ Double-bump caveat:
|
|
8
|
+
# Unlike GitHub Actions, Bitbucket Pipelines cannot trigger exclusively on
|
|
9
|
+
# PR merge events — it fires on every push to the branch, including the
|
|
10
|
+
# version bump commit itself. The script below guards against this by checking
|
|
11
|
+
# the last commit message. If it looks like a MAIASS version bump, it exits early.
|
|
12
|
+
#
|
|
13
|
+
# Setup:
|
|
14
|
+
# 1. Merge this excerpt into your bitbucket-pipelines.yml (or use as-is)
|
|
15
|
+
# 2. In Bitbucket: Repository Settings → Pipelines → SSH Keys
|
|
16
|
+
# Add a key pair and grant write access, OR use an app password:
|
|
17
|
+
# - Create an app password with Repositories: Read & Write scope
|
|
18
|
+
# - Add it as a repository variable named BB_APP_PASSWORD (secured)
|
|
19
|
+
# - Add your Bitbucket username as BB_USERNAME
|
|
20
|
+
# 3. Set MAIASS_DEVELOPBRANCH in your .env.maiass if your branch isn't 'develop'
|
|
21
|
+
|
|
22
|
+
pipelines:
|
|
23
|
+
branches:
|
|
24
|
+
develop: # Change to match your MAIASS_DEVELOPBRANCH if different
|
|
25
|
+
- step:
|
|
26
|
+
name: MAIASS Version Bump
|
|
27
|
+
image: node:20
|
|
28
|
+
script:
|
|
29
|
+
# Guard: skip if last commit was already a version bump
|
|
30
|
+
- |
|
|
31
|
+
LAST_MSG=$(git log -1 --pretty=format:'%s')
|
|
32
|
+
if echo "$LAST_MSG" | grep -qiE '^Bumped version'; then
|
|
33
|
+
echo "Version bump commit detected — skipping to avoid loop."
|
|
34
|
+
exit 0
|
|
35
|
+
fi
|
|
36
|
+
- npm install -g maiass --no-fund --no-audit
|
|
37
|
+
- git config user.name "Bitbucket Pipelines"
|
|
38
|
+
- git config user.email "pipelines@bitbucket.org"
|
|
39
|
+
# Authenticate push via app password
|
|
40
|
+
- git remote set-url origin "https://${BB_USERNAME}:${BB_APP_PASSWORD}@bitbucket.org/${BITBUCKET_REPO_FULL_NAME}.git"
|
|
41
|
+
- maiass -a patch
|
|
42
|
+
variables:
|
|
43
|
+
MAIASS_AI_MODE: "off" # Disable AI — no credits used in CI
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# MAIASS — GitHub Actions: Auto Version Bump on PR Merge
|
|
2
|
+
#
|
|
3
|
+
# What this does:
|
|
4
|
+
# When a pull request is merged into your develop branch, this workflow
|
|
5
|
+
# automatically runs `maiass -a patch` to bump the patch version, commit
|
|
6
|
+
# the change, and push it back to develop.
|
|
7
|
+
#
|
|
8
|
+
# Setup:
|
|
9
|
+
# 1. Copy this file to .github/workflows/maiass-version-bump.yml in your repo
|
|
10
|
+
# 2. Create a fine-grained Personal Access Token (PAT) with:
|
|
11
|
+
# - Contents: Read & Write
|
|
12
|
+
# - Metadata: Read-only
|
|
13
|
+
# - Workflows: Read & Write
|
|
14
|
+
# 3. Add the PAT as a repository secret named GH_PAT
|
|
15
|
+
# 4. Set MAIASS_DEVELOPBRANCH in your .env.maiass if your branch isn't 'develop'
|
|
16
|
+
#
|
|
17
|
+
# Notes:
|
|
18
|
+
# - AI is disabled (MAIASS_AI_MODE: off) so no credits are used
|
|
19
|
+
# - The workflow reads MAIASS_DEVELOPBRANCH from your .env.maiass automatically
|
|
20
|
+
# - maiass pulls the latest develop before bumping to prevent stale version conflicts
|
|
21
|
+
|
|
22
|
+
name: Version Bump on PR Merge
|
|
23
|
+
|
|
24
|
+
on:
|
|
25
|
+
pull_request:
|
|
26
|
+
types: [closed]
|
|
27
|
+
branches:
|
|
28
|
+
- develop # Change this to match your MAIASS_DEVELOPBRANCH if different
|
|
29
|
+
|
|
30
|
+
jobs:
|
|
31
|
+
bump-version:
|
|
32
|
+
# Only run when the PR was actually merged (not just closed)
|
|
33
|
+
if: github.event.pull_request.merged == true
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
|
|
36
|
+
permissions:
|
|
37
|
+
contents: write # Required to push the version bump commit
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
with:
|
|
42
|
+
fetch-depth: 0 # Full history needed for changelog generation
|
|
43
|
+
token: ${{ secrets.GH_PAT }} # PAT allows the bot to push back to the repo
|
|
44
|
+
|
|
45
|
+
- uses: actions/setup-node@v4
|
|
46
|
+
with:
|
|
47
|
+
node-version: '20'
|
|
48
|
+
cache: 'npm'
|
|
49
|
+
|
|
50
|
+
- name: Install maiass
|
|
51
|
+
run: npm install -g maiass --no-fund --no-audit
|
|
52
|
+
|
|
53
|
+
- name: Configure git
|
|
54
|
+
run: |
|
|
55
|
+
git config user.name "github-actions[bot]"
|
|
56
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
57
|
+
|
|
58
|
+
# Explicitly check out the develop branch head (the pull_request closed
|
|
59
|
+
# event checks out a merge ref, not the branch itself)
|
|
60
|
+
- name: Checkout develop
|
|
61
|
+
run: git checkout develop
|
|
62
|
+
|
|
63
|
+
- name: Bump version
|
|
64
|
+
run: maiass -a patch
|
|
65
|
+
env:
|
|
66
|
+
MAIASS_AI_MODE: off # Disable AI — no credits used in CI
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# MAIASS — GitLab CI: Auto Version Bump on Merge to Develop
|
|
2
|
+
#
|
|
3
|
+
# What this does:
|
|
4
|
+
# Runs `maiass -a patch` whenever a commit lands on your develop branch
|
|
5
|
+
# (including merge requests). Bumps the patch version, commits, and pushes.
|
|
6
|
+
#
|
|
7
|
+
# Setup:
|
|
8
|
+
# 1. Merge this excerpt into your existing .gitlab-ci.yml, or use it as-is
|
|
9
|
+
# 2. In GitLab: Settings → Repository → Protected branches → allow pipelines to push
|
|
10
|
+
# 3. Create a project access token or personal access token with write access
|
|
11
|
+
# 4. Add it as a CI/CD variable named GITLAB_TOKEN (masked, protected)
|
|
12
|
+
# 5. Set MAIASS_DEVELOPBRANCH in your .env.maiass if your branch isn't 'develop'
|
|
13
|
+
#
|
|
14
|
+
# Double-bump protection:
|
|
15
|
+
# The script checks the last commit author and skips if it was already made
|
|
16
|
+
# by the CI bot — preventing an infinite loop of version bumps.
|
|
17
|
+
|
|
18
|
+
stages:
|
|
19
|
+
- version
|
|
20
|
+
|
|
21
|
+
maiass-version-bump:
|
|
22
|
+
stage: version
|
|
23
|
+
image: node:20
|
|
24
|
+
only:
|
|
25
|
+
- develop # Change to match your MAIASS_DEVELOPBRANCH if different
|
|
26
|
+
script:
|
|
27
|
+
# Skip if the last commit was already a version bump from this pipeline
|
|
28
|
+
- |
|
|
29
|
+
LAST_AUTHOR=$(git log -1 --pretty=format:'%an')
|
|
30
|
+
LAST_MSG=$(git log -1 --pretty=format:'%s')
|
|
31
|
+
if echo "$LAST_AUTHOR" | grep -q "GitLab CI" || echo "$LAST_MSG" | grep -qiE '^Bumped version'; then
|
|
32
|
+
echo "Version bump commit detected — skipping to avoid loop."
|
|
33
|
+
exit 0
|
|
34
|
+
fi
|
|
35
|
+
- npm install -g maiass --no-fund --no-audit
|
|
36
|
+
- git config user.name "GitLab CI"
|
|
37
|
+
- git config user.email "ci@gitlab.com"
|
|
38
|
+
# Authenticate push via HTTPS using the project token
|
|
39
|
+
- git remote set-url origin "https://oauth2:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
|
|
40
|
+
- maiass -a patch
|
|
41
|
+
variables:
|
|
42
|
+
MAIASS_AI_MODE: "off" # Disable AI — no credits used in CI
|