pipecraft 0.0.0-releaseit → 0.26.0
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/README.md +126 -108
- package/dist/cli/index.d.ts +69 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +94 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts +70 -0
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +100 -8
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts +86 -0
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +101 -9
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +47 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +72 -3
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +22 -2
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts +18 -0
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-release.yml.tpl.js +141 -0
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +22 -2
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +70 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +98 -2
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +22 -2
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +50 -7
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +114 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +479 -74
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -1
- package/dist/types/index.d.ts +231 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/ast-path-operations.d.ts.map +1 -1
- package/dist/utils/ast-path-operations.js +24 -11
- package/dist/utils/ast-path-operations.js.map +1 -1
- package/dist/utils/config.d.ts +63 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +71 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +323 -2
- package/dist/utils/github-setup.d.ts.map +1 -1
- package/dist/utils/github-setup.js +551 -23
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/idempotency.d.ts +147 -7
- package/dist/utils/idempotency.d.ts.map +1 -1
- package/dist/utils/idempotency.js +143 -15
- package/dist/utils/idempotency.js.map +1 -1
- package/dist/utils/logger.d.ts +134 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +153 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/preflight.d.ts +223 -12
- package/dist/utils/preflight.d.ts.map +1 -1
- package/dist/utils/preflight.js +216 -16
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/versioning.d.ts +160 -8
- package/dist/utils/versioning.d.ts.map +1 -1
- package/dist/utils/versioning.js +179 -15
- package/dist/utils/versioning.js.map +1 -1
- package/package.json +26 -5
- package/.claude/settings.local.json +0 -35
- package/.github/actions/calculate-version/action.yml +0 -106
- package/.github/actions/create-pr/action.yml +0 -122
- package/.github/actions/create-release/action.yml +0 -74
- package/.github/actions/create-tag/action.yml +0 -94
- package/.github/actions/detect-changes/action.yml +0 -62
- package/.github/actions/manage-branch/action.yml +0 -113
- package/.github/actions/promote-branch/action.yml +0 -352
- package/.github/example/workflows/job.analyze.code.yml +0 -26
- package/.github/example/workflows/job.analyze.docker.yml +0 -32
- package/.github/example/workflows/job.app.api.deploy.yml +0 -127
- package/.github/example/workflows/job.app.api.test.yml +0 -102
- package/.github/example/workflows/job.app.docs.deploy.yml +0 -40
- package/.github/example/workflows/job.app.docs.test.yml +0 -50
- package/.github/example/workflows/job.app.web.deploy.yml +0 -96
- package/.github/example/workflows/job.app.web.test.yml +0 -49
- package/.github/example/workflows/job.changes.yml +0 -82
- package/.github/example/workflows/job.create-pr.yml +0 -96
- package/.github/example/workflows/job.env-check.yml +0 -43
- package/.github/example/workflows/job.fast-forward.yml +0 -103
- package/.github/example/workflows/job.lint.yml +0 -64
- package/.github/example/workflows/job.pr-name.yml +0 -70
- package/.github/example/workflows/job.pr-squash-name.yml +0 -27
- package/.github/example/workflows/job.tag.yml +0 -38
- package/.github/example/workflows/job.version.yml +0 -99
- package/.github/example/workflows/lib.plugin-base.publish.yml +0 -59
- package/.github/example/workflows/pipe.yml +0 -178
- package/.github/example/workflows/scripts/fastforward.sh +0 -51
- package/.github/example/workflows/scripts/pipe-cleaner.sh +0 -70
- package/.github/scripts/fastforward.sh +0 -51
- package/.github/scripts/pipe-cleaner.sh +0 -70
- package/.github/workflows/pipeline.yml +0 -220
- package/.github/workflows/pr-title-check.yml +0 -70
- package/.github/workflows/publish.yml +0 -39
- package/.pipecraftrc.json +0 -78
- package/.release-it.cjs +0 -71
- package/PIPELINE_TESTING_PLAN.md +0 -499
- package/TRUNK_FLOW_PLAN.md +0 -401
- package/assets/logo_banner.png +0 -0
- package/assets/logo_banner.webp +0 -0
- package/docs/USER_JOURNEY_ERRORS.md +0 -352
- package/eslint.config.js +0 -77
- package/examples/basic-config.json +0 -41
- package/examples/monorepo-config.json +0 -49
- package/examples/usage.md +0 -289
- package/scripts/debug-workflows.sh +0 -339
- package/scripts/parse-pipeline.js +0 -29
- package/scripts/test-job-order.cjs +0 -140
- package/scripts/validate-pipeline.cjs +0 -379
- package/scripts/verify-job-order.sh +0 -30
- package/src/cli/index.ts +0 -414
- package/src/generators/init.tpl.ts +0 -126
- package/src/generators/workflows.tpl.ts +0 -80
- package/src/templates/actions/calculate-version.yml.tpl.ts +0 -124
- package/src/templates/actions/create-pr.yml.tpl.ts +0 -147
- package/src/templates/actions/create-tag.yml.tpl.ts +0 -112
- package/src/templates/actions/detect-changes.yml.tpl.ts +0 -87
- package/src/templates/actions/manage-branch.yml.tpl.ts +0 -132
- package/src/templates/actions/promote-branch.yml.tpl.ts +0 -364
- package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +0 -706
- package/src/types/index.ts +0 -64
- package/src/utils/README-ast-path-operations.md +0 -390
- package/src/utils/ast-path-operations.ts +0 -581
- package/src/utils/config.ts +0 -64
- package/src/utils/github-setup.ts +0 -558
- package/src/utils/idempotency.ts +0 -215
- package/src/utils/preflight.ts +0 -306
- package/src/utils/versioning.ts +0 -244
- package/tests/README.md +0 -229
- package/tests/TEST_STRUCTURE.md +0 -256
- package/tests/act/run-act-tests.sh +0 -345
- package/tests/debugging/debug-utils.ts +0 -538
- package/tests/debugging/debug-workflow.test.ts +0 -339
- package/tests/debugging/debug-workflows.sh +0 -339
- package/tests/debugging/iterative-debug.ts +0 -652
- package/tests/debugging/run-debug-tests.sh +0 -431
- package/tests/fixtures/basic-config.json +0 -51
- package/tests/fixtures/invalid-config.json +0 -9
- package/tests/fixtures/pipeline-generated.yml +0 -235
- package/tests/fixtures/pipeline-preserve-comments.yml +0 -245
- package/tests/fixtures/pipeline-user-modified.yml +0 -245
- package/tests/fixtures/test-config.json +0 -58
- package/tests/github-live/README.md +0 -250
- package/tests/github-local/JOB_WORKFLOW_TESTS.md +0 -296
- package/tests/github-local/README.md +0 -240
- package/tests/github-local/run-all-tests.sh +0 -422
- package/tests/github-local/test-job-workflows.sh +0 -631
- package/tests/github-local/test-pipeline-workflow.sh +0 -440
- package/tests/integration/generators.test.ts +0 -578
- package/tests/integration/path-based-template.test.ts +0 -510
- package/tests/integration/simple-path-based.test.ts +0 -415
- package/tests/setup.ts +0 -56
- package/tests/unit/ast-path-operations-extended.test.ts +0 -302
- package/tests/unit/cli.test.ts +0 -541
- package/tests/unit/config-extended.test.ts +0 -412
- package/tests/unit/config.test.ts +0 -152
- package/tests/unit/github-setup.test.ts +0 -189
- package/tests/unit/idempotency-isolated.test.ts +0 -297
- package/tests/unit/job-order.test.ts +0 -157
- package/tests/unit/pipeline-path-based.test.ts +0 -511
- package/tests/unit/validate-pipeline.test.ts +0 -384
- package/tests/unit/versioning-extended.test.ts +0 -279
- package/tests/unit/versioning.test.ts +0 -241
- package/tsconfig.debug.json +0 -17
- package/tsconfig.json +0 -28
- package/vitest.config.ts +0 -51
package/dist/utils/versioning.js
CHANGED
|
@@ -1,13 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version Management and Semantic Versioning Utilities
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive version management using release-it and
|
|
5
|
+
* conventional commits. It handles:
|
|
6
|
+
* - Automatic version calculation based on commit history
|
|
7
|
+
* - Generation of release-it, commitlint, and husky configurations
|
|
8
|
+
* - Git tag creation and management
|
|
9
|
+
* - Conventional commit validation
|
|
10
|
+
* - Changelog generation
|
|
11
|
+
*
|
|
12
|
+
* The VersionManager integrates with the trunk-based workflow to automatically
|
|
13
|
+
* bump versions when code is promoted through the pipeline.
|
|
14
|
+
*
|
|
15
|
+
* @module utils/versioning
|
|
16
|
+
*/
|
|
1
17
|
import { execSync } from 'child_process';
|
|
2
18
|
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
3
19
|
import { join } from 'path';
|
|
20
|
+
/**
|
|
21
|
+
* Manager for semantic versioning and release automation.
|
|
22
|
+
*
|
|
23
|
+
* This class handles all version-related operations including configuration
|
|
24
|
+
* generation, version calculation, and commit validation. It integrates with
|
|
25
|
+
* release-it for automated versioning and conventional-changelog for
|
|
26
|
+
* changelog generation.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const versionManager = new VersionManager(config)
|
|
31
|
+
*
|
|
32
|
+
* // Setup version management (creates config files)
|
|
33
|
+
* versionManager.setupVersionManagement()
|
|
34
|
+
*
|
|
35
|
+
* // Get current version from git tags
|
|
36
|
+
* const currentVersion = versionManager.getCurrentVersion()
|
|
37
|
+
*
|
|
38
|
+
* // Calculate next version based on commits
|
|
39
|
+
* const { version, type } = versionManager.calculateNextVersion()
|
|
40
|
+
* console.log(`Next version: ${version} (${type} bump)`)
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
4
43
|
export class VersionManager {
|
|
5
44
|
config;
|
|
45
|
+
/**
|
|
46
|
+
* Create a new VersionManager instance.
|
|
47
|
+
*
|
|
48
|
+
* @param config - PipeCraft configuration object
|
|
49
|
+
*/
|
|
6
50
|
constructor(config) {
|
|
7
51
|
this.config = config;
|
|
8
52
|
}
|
|
9
53
|
/**
|
|
10
|
-
* Generate release-it configuration
|
|
54
|
+
* Generate release-it configuration file content.
|
|
55
|
+
*
|
|
56
|
+
* Creates a CommonJS module exporting release-it configuration that:
|
|
57
|
+
* - Disables npm publishing (for monorepos/private packages)
|
|
58
|
+
* - Configures git tagging with conventional versioning
|
|
59
|
+
* - Sets up conventional-changelog plugin for automatic version bumping
|
|
60
|
+
* - Merges user-defined bump rules with sensible defaults
|
|
61
|
+
*
|
|
62
|
+
* The generated config uses a custom whatBump function that analyzes
|
|
63
|
+
* conventional commits to determine the appropriate version bump level
|
|
64
|
+
* (major, minor, or patch).
|
|
65
|
+
*
|
|
66
|
+
* @returns JavaScript module string ready to write to .release-it.cjs
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const config = versionManager.generateReleaseItConfig()
|
|
71
|
+
* writeFileSync('.release-it.cjs', config)
|
|
72
|
+
* ```
|
|
11
73
|
*/
|
|
12
74
|
generateReleaseItConfig() {
|
|
13
75
|
const defaultConfig = {
|
|
@@ -74,7 +136,20 @@ export class VersionManager {
|
|
|
74
136
|
return `module.exports = ${JSON.stringify(defaultConfig, null, 2)}`;
|
|
75
137
|
}
|
|
76
138
|
/**
|
|
77
|
-
* Generate commitlint configuration
|
|
139
|
+
* Generate commitlint configuration file content.
|
|
140
|
+
*
|
|
141
|
+
* Creates a CommonJS module that configures commitlint to enforce
|
|
142
|
+
* conventional commit message format. This ensures all commits follow
|
|
143
|
+
* a consistent structure that can be parsed for automatic versioning.
|
|
144
|
+
*
|
|
145
|
+
* Enforced rules include:
|
|
146
|
+
* - Valid commit types (feat, fix, docs, etc.)
|
|
147
|
+
* - Lowercase types
|
|
148
|
+
* - Non-empty subjects
|
|
149
|
+
* - Lowercase subject (except proper nouns)
|
|
150
|
+
* - No trailing period in subject
|
|
151
|
+
*
|
|
152
|
+
* @returns JavaScript module string ready to write to commitlint.config.js
|
|
78
153
|
*/
|
|
79
154
|
generateCommitlintConfig() {
|
|
80
155
|
return `module.exports = {
|
|
@@ -106,7 +181,13 @@ export class VersionManager {
|
|
|
106
181
|
}`;
|
|
107
182
|
}
|
|
108
183
|
/**
|
|
109
|
-
* Generate husky
|
|
184
|
+
* Generate husky commit-msg hook script.
|
|
185
|
+
*
|
|
186
|
+
* Creates a shell script that runs commitlint on every commit message.
|
|
187
|
+
* This hook automatically validates commit messages before they're accepted,
|
|
188
|
+
* preventing non-conventional commits from entering the repository.
|
|
189
|
+
*
|
|
190
|
+
* @returns Shell script string ready to write to .husky/commit-msg
|
|
110
191
|
*/
|
|
111
192
|
generateHuskyConfig() {
|
|
112
193
|
return `#!/usr/bin/env sh
|
|
@@ -115,7 +196,27 @@ export class VersionManager {
|
|
|
115
196
|
npx commitlint --edit $1`;
|
|
116
197
|
}
|
|
117
198
|
/**
|
|
118
|
-
* Setup version management
|
|
199
|
+
* Setup version management infrastructure.
|
|
200
|
+
*
|
|
201
|
+
* Creates all necessary configuration files and hooks for automated
|
|
202
|
+
* version management:
|
|
203
|
+
* - .release-it.cjs (release-it configuration)
|
|
204
|
+
* - commitlint.config.js (commit message linting)
|
|
205
|
+
* - .husky/commit-msg (git hook for commit validation)
|
|
206
|
+
* - package.json scripts (release, changelog commands)
|
|
207
|
+
*
|
|
208
|
+
* Only runs if versioning is enabled in configuration.
|
|
209
|
+
* Installs husky if not already present.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* versionManager.setupVersionManagement()
|
|
214
|
+
* // Files created:
|
|
215
|
+
* // - .release-it.cjs
|
|
216
|
+
* // - commitlint.config.js
|
|
217
|
+
* // - .husky/commit-msg
|
|
218
|
+
* // - Updated package.json
|
|
219
|
+
* ```
|
|
119
220
|
*/
|
|
120
221
|
setupVersionManagement() {
|
|
121
222
|
if (!this.config.versioning?.enabled) {
|
|
@@ -127,24 +228,36 @@ npx commitlint --edit $1`;
|
|
|
127
228
|
// Generate commitlint.config.js
|
|
128
229
|
const commitlintConfig = this.generateCommitlintConfig();
|
|
129
230
|
writeFileSync('commitlint.config.js', commitlintConfig);
|
|
130
|
-
//
|
|
231
|
+
// Setup husky and commit-msg hook
|
|
131
232
|
const huskyDir = '.husky';
|
|
132
233
|
if (!existsSync(huskyDir)) {
|
|
133
234
|
execSync('npx husky install', { stdio: 'inherit' });
|
|
134
|
-
// Ensure directory exists (in case husky install was mocked/failed)
|
|
235
|
+
// Ensure directory exists (in case husky install was mocked/failed in tests)
|
|
135
236
|
if (!existsSync(huskyDir)) {
|
|
136
237
|
const { mkdirSync } = require('fs');
|
|
137
238
|
mkdirSync(huskyDir, { recursive: true });
|
|
138
239
|
}
|
|
139
240
|
}
|
|
241
|
+
// Create commit-msg hook script
|
|
140
242
|
const commitMsgHook = this.generateHuskyConfig();
|
|
141
243
|
writeFileSync(join(huskyDir, 'commit-msg'), commitMsgHook);
|
|
244
|
+
// Make hook executable (required for git to run it)
|
|
142
245
|
execSync(`chmod +x ${join(huskyDir, 'commit-msg')}`);
|
|
143
|
-
// Update package.json scripts
|
|
246
|
+
// Update package.json with version management scripts
|
|
144
247
|
this.updatePackageJsonScripts();
|
|
145
248
|
}
|
|
146
249
|
/**
|
|
147
|
-
* Update package.json with version management scripts
|
|
250
|
+
* Update package.json with version management scripts.
|
|
251
|
+
*
|
|
252
|
+
* Adds npm scripts for common version management tasks:
|
|
253
|
+
* - release: Run release-it to create a new version
|
|
254
|
+
* - release:dry: Preview what release-it would do
|
|
255
|
+
* - version:check: Check what version would be bumped to
|
|
256
|
+
* - changelog: Generate CHANGELOG.md from commits
|
|
257
|
+
* - commit: Stage and commit with interactive prompting
|
|
258
|
+
* - prepare: Install husky hooks (runs automatically on npm install)
|
|
259
|
+
*
|
|
260
|
+
* @private
|
|
148
261
|
*/
|
|
149
262
|
updatePackageJsonScripts() {
|
|
150
263
|
const packageJsonPath = 'package.json';
|
|
@@ -152,6 +265,7 @@ npx commitlint --edit $1`;
|
|
|
152
265
|
return;
|
|
153
266
|
}
|
|
154
267
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
268
|
+
// Merge with existing scripts, preserving any user-defined ones
|
|
155
269
|
packageJson.scripts = {
|
|
156
270
|
...packageJson.scripts,
|
|
157
271
|
'release': 'release-it',
|
|
@@ -164,34 +278,83 @@ npx commitlint --edit $1`;
|
|
|
164
278
|
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
165
279
|
}
|
|
166
280
|
/**
|
|
167
|
-
*
|
|
281
|
+
* Validate that recent commits follow conventional commit format.
|
|
282
|
+
*
|
|
283
|
+
* Checks the last 10 commits to determine if the repository is following
|
|
284
|
+
* conventional commit conventions. This can be used as a pre-flight check
|
|
285
|
+
* before enabling versioning features.
|
|
286
|
+
*
|
|
287
|
+
* Expected format: `type(scope?): subject`
|
|
288
|
+
* Valid types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
|
289
|
+
*
|
|
290
|
+
* @returns true if all recent commits follow conventional format
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* if (!versionManager.validateConventionalCommits()) {
|
|
295
|
+
* console.warn('⚠ Some commits do not follow conventional format')
|
|
296
|
+
* console.log('Enable with: git config commit.template .gitmessage')
|
|
297
|
+
* }
|
|
298
|
+
* ```
|
|
168
299
|
*/
|
|
169
300
|
validateConventionalCommits() {
|
|
170
301
|
try {
|
|
171
|
-
const result = execSync('git log --oneline -10', {
|
|
302
|
+
const result = execSync('git log --oneline -10', {
|
|
303
|
+
encoding: 'utf8',
|
|
304
|
+
stdio: ['pipe', 'pipe', 'ignore'] // Suppress stderr to avoid "not a git repository" errors in tests
|
|
305
|
+
});
|
|
172
306
|
const commits = result.split('\n').filter(line => line.trim());
|
|
173
|
-
// Check if commits follow conventional format
|
|
307
|
+
// Check if commits follow conventional format: type(scope?): subject
|
|
174
308
|
const conventionalPattern = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: .+/;
|
|
175
309
|
return commits.every(commit => conventionalPattern.test(commit));
|
|
176
310
|
}
|
|
177
311
|
catch (error) {
|
|
312
|
+
// Not a git repository or other git error
|
|
178
313
|
return false;
|
|
179
314
|
}
|
|
180
315
|
}
|
|
181
316
|
/**
|
|
182
|
-
* Get current version from git tags
|
|
317
|
+
* Get the current version from git tags.
|
|
318
|
+
*
|
|
319
|
+
* Finds the most recent git tag matching semantic versioning format (v*.*.*)
|
|
320
|
+
* and returns it as a version string. Strips the leading 'v' if present.
|
|
321
|
+
*
|
|
322
|
+
* @returns Current version string (e.g., "1.2.3") or "0.0.0" if no tags exist
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* const currentVersion = versionManager.getCurrentVersion()
|
|
327
|
+
* console.log(`Current version: v${currentVersion}`)
|
|
328
|
+
* ```
|
|
183
329
|
*/
|
|
184
330
|
getCurrentVersion() {
|
|
185
331
|
try {
|
|
186
|
-
const result = execSync('git describe --tags --abbrev=0', {
|
|
332
|
+
const result = execSync('git describe --tags --abbrev=0', {
|
|
333
|
+
encoding: 'utf8',
|
|
334
|
+
stdio: ['pipe', 'pipe', 'ignore'] // Suppress stderr to avoid "not a git repository" errors in tests
|
|
335
|
+
});
|
|
187
336
|
return result.trim().replace('v', '');
|
|
188
337
|
}
|
|
189
338
|
catch (error) {
|
|
339
|
+
// No tags exist yet, or not a git repository
|
|
190
340
|
return '0.0.0';
|
|
191
341
|
}
|
|
192
342
|
}
|
|
193
343
|
/**
|
|
194
|
-
* Calculate next version based on conventional commits
|
|
344
|
+
* Calculate the next version based on conventional commits.
|
|
345
|
+
*
|
|
346
|
+
* Runs release-it in dry-run mode to determine what version would be
|
|
347
|
+
* created based on commits since the last tag. Analyzes conventional
|
|
348
|
+
* commit messages to determine the appropriate bump level.
|
|
349
|
+
*
|
|
350
|
+
* @returns Object containing the next version string and bump type
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* const { version, type } = versionManager.calculateNextVersion()
|
|
355
|
+
* console.log(`Next ${type} version: ${version}`)
|
|
356
|
+
* // Output: "Next minor version: 1.3.0"
|
|
357
|
+
* ```
|
|
195
358
|
*/
|
|
196
359
|
calculateNextVersion() {
|
|
197
360
|
try {
|
|
@@ -200,7 +363,7 @@ npx commitlint --edit $1`;
|
|
|
200
363
|
encoding: 'utf8',
|
|
201
364
|
stdio: 'pipe'
|
|
202
365
|
});
|
|
203
|
-
// Parse release-it output to
|
|
366
|
+
// Parse release-it output to extract version and bump type
|
|
204
367
|
const versionMatch = result.match(/version\s+(\d+\.\d+\.\d+)/);
|
|
205
368
|
const typeMatch = result.match(/bump\s+(\w+)/);
|
|
206
369
|
return {
|
|
@@ -209,6 +372,7 @@ npx commitlint --edit $1`;
|
|
|
209
372
|
};
|
|
210
373
|
}
|
|
211
374
|
catch (error) {
|
|
375
|
+
// release-it not installed, or other error
|
|
212
376
|
return {
|
|
213
377
|
version: this.getCurrentVersion(),
|
|
214
378
|
type: 'patch'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versioning.js","sourceRoot":"","sources":["../../src/utils/versioning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,MAAM,OAAO,cAAc;IACjB,MAAM,CAAiB;IAE/B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"versioning.js","sourceRoot":"","sources":["../../src/utils/versioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,cAAc;IACjB,MAAM,CAAiB;IAE/B;;;;OAIG;IACH,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;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vC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,6CAA6C;YAC7C,OAAO,OAAO,CAAA;QAChB,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,oBAAoB;QAClB,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YAC/C,MAAM,MAAM,GAAG,QAAQ,CAAC,0DAA0D,EAAE;gBAClF,QAAQ,EAAE,MAAM;gBAChB,KAAK,EAAE,MAAM;aACd,CAAC,CAAA;YAEF,2DAA2D;YAC3D,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAA;YAC9D,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;YAE9C,OAAO;gBACL,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;gBACxD,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;aACzC,CAAA;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,2CAA2C;YAC3C,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE;gBACjC,IAAI,EAAE,OAAO;aACd,CAAA;QACH,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pipecraft",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "CLI tool for managing trunk-based development workflows",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"pipecraft": "./dist/cli/index.js"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/jamesvillarrubia/pipecraft.git"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
},
|
|
10
24
|
"scripts": {
|
|
11
25
|
"build": "tsc",
|
|
12
26
|
"dev": "tsx src/cli/index.ts",
|
|
13
|
-
"test": "vitest",
|
|
27
|
+
"test": "vitest run",
|
|
14
28
|
"test:ui": "vitest --ui",
|
|
15
29
|
"test:run": "vitest run",
|
|
16
30
|
"test:coverage": "vitest run --coverage",
|
|
@@ -20,13 +34,17 @@
|
|
|
20
34
|
"lint:strict": "eslint . --ext .js,.jsx,.ts,.tsx --max-warnings=0",
|
|
21
35
|
"format": "prettier --write '**/*.{js,jsx,ts,tsx,json,css,scss,md}'",
|
|
22
36
|
"format:check": "prettier --check '**/*.{js,jsx,ts,tsx,json,css,scss,md}'",
|
|
23
|
-
"validate:pipeline": "node
|
|
37
|
+
"validate:pipeline": "node tests/tools/validation/validate-pipeline.cjs",
|
|
24
38
|
"pipecraft": "tsx src/cli/index.ts",
|
|
25
39
|
"init": "tsx src/cli/index.ts init --interactive",
|
|
26
40
|
"generate": "tsx src/cli/index.ts generate",
|
|
27
|
-
"verify": "tsx src/cli/index.ts verify"
|
|
41
|
+
"verify": "tsx src/cli/index.ts verify",
|
|
42
|
+
"docs:build": "cd docs && pnpm run build",
|
|
43
|
+
"docs:dev": "cd docs && pnpm run start",
|
|
44
|
+
"docs:serve": "cd docs && pnpm run serve",
|
|
45
|
+
"docs:typedoc": "cd docs && pnpm run typedoc",
|
|
46
|
+
"docs:deploy": "npm run build && cd docs && pnpm run typedoc && pnpm run build"
|
|
28
47
|
},
|
|
29
|
-
"private": false,
|
|
30
48
|
"devDependencies": {
|
|
31
49
|
"@eslint/eslintrc": "^3.3.1",
|
|
32
50
|
"@eslint/js": "^9.24.0",
|
|
@@ -41,6 +59,7 @@
|
|
|
41
59
|
"commander": "^14.0.1",
|
|
42
60
|
"conventional-changelog-angular": "latest",
|
|
43
61
|
"cosmiconfig": "^9.0.0",
|
|
62
|
+
"docusaurus-plugin-typedoc": "^1.4.2",
|
|
44
63
|
"eslint": "^9.24.0",
|
|
45
64
|
"eslint-plugin-import": "^2.31.0",
|
|
46
65
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
@@ -49,6 +68,8 @@
|
|
|
49
68
|
"globals": "^16.0.0",
|
|
50
69
|
"prettier": "^2.8.8",
|
|
51
70
|
"release-it": "^18.1.2",
|
|
71
|
+
"typedoc": "^0.28.14",
|
|
72
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
52
73
|
"vitest": "^2.1.8"
|
|
53
74
|
},
|
|
54
75
|
"dependencies": {
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(test:*)",
|
|
5
|
-
"Bash(git commit -m \"$(cat <<''EOF''\nrefactor: rename project from FlowCraft to PipeCraft\n\nRename the entire project to PipeCraft to better align with the -craft naming convention (matching pullcraft). The new name emphasizes pipeline crafting and CI/CD automation.\n\nChanges:\n- Rename package from ''flowcraft'' to ''pipecraft''\n- Rename CLI command from ''flowcraft'' to ''pipecraft''\n- Rename config file from .flowcraftrc.json to .pipecraftrc.json\n- Update all documentation and branding\n- Update all source code references\n- Update all test files\n- Update all script files\n- Update GitHub Actions setup messaging\n\nThe functionality remains identical - only the branding has changed.\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")",
|
|
6
|
-
"Bash(git rev-parse:*)",
|
|
7
|
-
"Bash(gh run list:*)",
|
|
8
|
-
"Bash(gh workflow list:*)",
|
|
9
|
-
"Bash(gh run view:*)",
|
|
10
|
-
"Bash(git fetch:*)",
|
|
11
|
-
"Bash(pnpm build)",
|
|
12
|
-
"Bash(node:*)",
|
|
13
|
-
"Bash(pnpm pipecraft generate:*)",
|
|
14
|
-
"Bash(git restore:*)",
|
|
15
|
-
"Bash(git add:*)",
|
|
16
|
-
"Bash(git commit -m \"$(cat <<''EOF''\nfeat: add per-branch autoMerge configuration for hybrid manual/auto workflow\n\nAdd support for configurable auto-merge behavior per target branch, allowing\nteams to choose when to automatically fast-forward branches vs requiring manual\nPR review.\n\nChanges:\n- Add autoMerge config option supporting both boolean and per-branch object\n- Update pipeline template to conditionally generate branch job based on config\n- Add branch output to manage-branch action for workflow triggering\n- Implement workflow dispatch triggering to run pipeline on target branch\n- Add logic to remove branch job when autoMerge is disabled\n\nConfiguration:\n- Set autoMerge per target branch in .pipecraftrc.json\n- Example: { \"staging\": true, \"main\": false }\n- Enables auto-merge to staging, manual review for production\n\nWorkflow behavior:\n- When autoMerge enabled: creates PR + auto fast-forward + triggers workflow\n- When autoMerge disabled: creates PR + waits for manual merge (human merge triggers workflow)\n- Uses GITHUB_TOKEN with gh workflow run (no PAT needed)\n- Branch job includes conditional if statement based on source branch\n\nThis solves the issue where GITHUB_TOKEN pushes don''t trigger workflows by\nexplicitly triggering them, while maintaining flexibility for manual review\nwhen needed (e.g., before production deploys).\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")",
|
|
17
|
-
"Bash(git push:*)",
|
|
18
|
-
"Bash(git commit:*)",
|
|
19
|
-
"Bash(gh pr list:*)",
|
|
20
|
-
"Bash(cat:*)",
|
|
21
|
-
"Read(//private/tmp/**)",
|
|
22
|
-
"Bash(pnpm test:*)",
|
|
23
|
-
"Bash(/dev/null)",
|
|
24
|
-
"Bash(gh api:*)",
|
|
25
|
-
"Bash(gh pr merge:*)",
|
|
26
|
-
"Bash(xargs -I {} git show {}:.github/workflows/pipeline.yml)",
|
|
27
|
-
"Bash(git checkout:*)",
|
|
28
|
-
"Bash(npm test)",
|
|
29
|
-
"Bash(pkill:*)",
|
|
30
|
-
"Bash(npm run build)"
|
|
31
|
-
],
|
|
32
|
-
"deny": [],
|
|
33
|
-
"ask": []
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
name: 'Calculate Version'
|
|
2
|
-
description: 'Calculate semantic version using release-it and conventional commits'
|
|
3
|
-
author: 'Pipecraft'
|
|
4
|
-
|
|
5
|
-
inputs:
|
|
6
|
-
baseRef:
|
|
7
|
-
description: 'Base reference for version calculation'
|
|
8
|
-
required: false
|
|
9
|
-
default: 'main'
|
|
10
|
-
|
|
11
|
-
outputs:
|
|
12
|
-
version:
|
|
13
|
-
description: 'The determined version'
|
|
14
|
-
value: ${{ steps.set_version.outputs.version }}
|
|
15
|
-
|
|
16
|
-
runs:
|
|
17
|
-
using: 'composite'
|
|
18
|
-
steps:
|
|
19
|
-
- name: Checkout Code
|
|
20
|
-
uses: actions/checkout@v4
|
|
21
|
-
with:
|
|
22
|
-
fetch-depth: 0
|
|
23
|
-
|
|
24
|
-
- name: Install Node.js
|
|
25
|
-
uses: actions/setup-node@v4
|
|
26
|
-
with:
|
|
27
|
-
node-version: 22
|
|
28
|
-
|
|
29
|
-
- name: Configure Git
|
|
30
|
-
shell: bash
|
|
31
|
-
run: |
|
|
32
|
-
git config --global user.name "github-actions[bot]"
|
|
33
|
-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
34
|
-
|
|
35
|
-
- name: Get existing version tag
|
|
36
|
-
id: get_version_old
|
|
37
|
-
shell: bash
|
|
38
|
-
run: |
|
|
39
|
-
set -x # Enable debugging output
|
|
40
|
-
# Get the current commit hash
|
|
41
|
-
git rev-parse HEAD
|
|
42
|
-
COMMIT_HASH=$(git rev-parse HEAD)
|
|
43
|
-
echo "Current commit hash: $COMMIT_HASH"
|
|
44
|
-
|
|
45
|
-
# Check for tags on the current commit
|
|
46
|
-
TAG=$(git tag --points-at $COMMIT_HASH | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+\$' || true)
|
|
47
|
-
echo "Tags found: $TAG"
|
|
48
|
-
|
|
49
|
-
if [ -z "$TAG" ]; then
|
|
50
|
-
echo "No existing tag found on the current commit"
|
|
51
|
-
else
|
|
52
|
-
echo "Found existing tag: $TAG"
|
|
53
|
-
echo "version=$TAG" >> $GITHUB_OUTPUT
|
|
54
|
-
fi
|
|
55
|
-
|
|
56
|
-
- name: Set up minimal package.json
|
|
57
|
-
shell: bash
|
|
58
|
-
run: |
|
|
59
|
-
echo '{
|
|
60
|
-
"name": "temporary-lib",
|
|
61
|
-
"version": "0.0.0-release-it"
|
|
62
|
-
}' > package.json
|
|
63
|
-
|
|
64
|
-
- name: Install dependencies
|
|
65
|
-
shell: bash
|
|
66
|
-
run: npm install @release-it/conventional-changelog conventional-changelog-angular
|
|
67
|
-
|
|
68
|
-
- name: Get version
|
|
69
|
-
if: steps.get_version_old.outputs.version == ''
|
|
70
|
-
id: get_version_new
|
|
71
|
-
shell: bash
|
|
72
|
-
run: |
|
|
73
|
-
# Get version and filter out warnings
|
|
74
|
-
RAW_OUTPUT=$(npx release-it --ci --release-version 2>&1 || echo "")
|
|
75
|
-
# Extract just the version number (last line that looks like a version)
|
|
76
|
-
VERSION=$(echo "$RAW_OUTPUT" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+' | tail -1 || true)
|
|
77
|
-
|
|
78
|
-
if [[ "$RAW_OUTPUT" == *"No new version to release"* || -z "$VERSION" ]]; then
|
|
79
|
-
echo "No new version to release"
|
|
80
|
-
echo "VERSION=" >> $GITHUB_ENV
|
|
81
|
-
echo "version=" >> $GITHUB_OUTPUT
|
|
82
|
-
else
|
|
83
|
-
echo "New version to release: $VERSION"
|
|
84
|
-
echo "VERSION=v$VERSION" >> $GITHUB_ENV
|
|
85
|
-
echo "version=v$VERSION" >> $GITHUB_OUTPUT
|
|
86
|
-
fi
|
|
87
|
-
|
|
88
|
-
- name: Set version output
|
|
89
|
-
id: set_version
|
|
90
|
-
shell: bash
|
|
91
|
-
run: |
|
|
92
|
-
if [ -n "${{ steps.get_version_old.outputs.version }}" ]; then
|
|
93
|
-
echo "Using old version: ${{ steps.get_version_old.outputs.version }}"
|
|
94
|
-
echo "version=${{ steps.get_version_old.outputs.version }}" >> $GITHUB_OUTPUT
|
|
95
|
-
elif [ -n "${{ steps.get_version_new.outputs.version }}" ]; then
|
|
96
|
-
echo "Using new version: ${{ steps.get_version_new.outputs.version }}"
|
|
97
|
-
echo "version=${{ steps.get_version_new.outputs.version }}" >> $GITHUB_OUTPUT
|
|
98
|
-
else
|
|
99
|
-
echo "No version determined"
|
|
100
|
-
echo "version=" >> $GITHUB_OUTPUT
|
|
101
|
-
fi
|
|
102
|
-
|
|
103
|
-
- name: Output version
|
|
104
|
-
shell: bash
|
|
105
|
-
run: |
|
|
106
|
-
echo "Version determined: ${{ steps.set_version.outputs.version }}"
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
name: 'Create Pull Request'
|
|
2
|
-
description: 'Create a pull request between source and target branches'
|
|
3
|
-
author: 'Pipecraft'
|
|
4
|
-
|
|
5
|
-
inputs:
|
|
6
|
-
sourceBranch:
|
|
7
|
-
description: 'Source branch for the PR'
|
|
8
|
-
required: true
|
|
9
|
-
targetBranch:
|
|
10
|
-
description: 'Target branch for the PR'
|
|
11
|
-
required: true
|
|
12
|
-
title:
|
|
13
|
-
description: 'Title for the PR'
|
|
14
|
-
required: true
|
|
15
|
-
body:
|
|
16
|
-
description: 'Body/description for the PR'
|
|
17
|
-
required: false
|
|
18
|
-
labels:
|
|
19
|
-
description: 'Comma-separated list of labels'
|
|
20
|
-
required: false
|
|
21
|
-
token:
|
|
22
|
-
description: 'GitHub token for authentication'
|
|
23
|
-
required: false
|
|
24
|
-
default: ${{ github.token }}
|
|
25
|
-
|
|
26
|
-
outputs:
|
|
27
|
-
prNumber:
|
|
28
|
-
description: 'The created PR number'
|
|
29
|
-
value: ${{ steps.create-pr.outputs.prNumber }}
|
|
30
|
-
prUrl:
|
|
31
|
-
description: 'The created PR URL'
|
|
32
|
-
value: ${{ steps.create-pr.outputs.prUrl }}
|
|
33
|
-
|
|
34
|
-
runs:
|
|
35
|
-
using: 'composite'
|
|
36
|
-
steps:
|
|
37
|
-
- name: Checkout Code
|
|
38
|
-
uses: actions/checkout@v4
|
|
39
|
-
with:
|
|
40
|
-
fetch-depth: 0
|
|
41
|
-
token: ${{ inputs.token }}
|
|
42
|
-
|
|
43
|
-
- name: Check if PR Already Exists
|
|
44
|
-
id: check-existing-pr
|
|
45
|
-
shell: bash
|
|
46
|
-
run: |
|
|
47
|
-
SOURCE="${{ inputs.sourceBranch }}"
|
|
48
|
-
TARGET="${{ inputs.targetBranch }}"
|
|
49
|
-
|
|
50
|
-
# Check if PR already exists
|
|
51
|
-
EXISTING_PR=$(gh pr list --head "$SOURCE" --base "$TARGET" --json number --jq '.[0].number' 2>/dev/null || echo "")
|
|
52
|
-
|
|
53
|
-
if [ -n "$EXISTING_PR" ]; then
|
|
54
|
-
echo "exists=true" >> $GITHUB_OUTPUT
|
|
55
|
-
echo "pr_number=$EXISTING_PR" >> $GITHUB_OUTPUT
|
|
56
|
-
echo "⚠️ PR already exists: #$EXISTING_PR"
|
|
57
|
-
else
|
|
58
|
-
echo "exists=false" >> $GITHUB_OUTPUT
|
|
59
|
-
echo "✅ No existing PR found"
|
|
60
|
-
fi
|
|
61
|
-
|
|
62
|
-
- name: Create Pull Request
|
|
63
|
-
if: steps.check-existing-pr.outputs.exists == 'false'
|
|
64
|
-
id: create-pr
|
|
65
|
-
shell: bash
|
|
66
|
-
run: |
|
|
67
|
-
SOURCE="${{ inputs.sourceBranch }}"
|
|
68
|
-
TARGET="${{ inputs.targetBranch }}"
|
|
69
|
-
TITLE="${{ inputs.title }}"
|
|
70
|
-
BODY="${{ inputs.body }}"
|
|
71
|
-
LABELS="${{ inputs.labels }}"
|
|
72
|
-
|
|
73
|
-
# Prepare labels array
|
|
74
|
-
LABEL_ARGS=""
|
|
75
|
-
if [ -n "$LABELS" ]; then
|
|
76
|
-
IFS=',' read -ra LABEL_ARRAY <<< "$LABELS"
|
|
77
|
-
for label in "${LABEL_ARRAY[@]}"; do
|
|
78
|
-
LABEL_ARGS="$LABEL_ARGS --label \"${label// /}\""
|
|
79
|
-
done
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
# Create the PR
|
|
83
|
-
PR_OUTPUT=$(gh pr create \--title "$TITLE" \--body "$BODY" \--head "$SOURCE" \--base "$TARGET" \$LABEL_ARGS \--json number,url --jq '.number,.url' 2>&1)
|
|
84
|
-
|
|
85
|
-
if echo "$PR_OUTPUT" | grep -q '"number":'; then
|
|
86
|
-
PR_NUMBER=$(echo "$PR_OUTPUT" | jq -r '.number')
|
|
87
|
-
PR_URL=$(echo "$PR_OUTPUT" | jq -r '.url')
|
|
88
|
-
echo "prNumber=$PR_NUMBER" >> $GITHUB_OUTPUT
|
|
89
|
-
echo "prUrl=$PR_URL" >> $GITHUB_OUTPUT
|
|
90
|
-
echo "✅ Created PR #$PR_NUMBER"
|
|
91
|
-
echo "🔗 URL: $PR_URL"
|
|
92
|
-
else
|
|
93
|
-
echo "❌ Failed to create PR"
|
|
94
|
-
echo "Error output:"
|
|
95
|
-
echo "$PR_OUTPUT"
|
|
96
|
-
exit 1
|
|
97
|
-
fi
|
|
98
|
-
|
|
99
|
-
- name: Use Existing PR
|
|
100
|
-
if: steps.check-existing-pr.outputs.exists == 'true'
|
|
101
|
-
id: use-existing-pr
|
|
102
|
-
shell: bash
|
|
103
|
-
run: |
|
|
104
|
-
PR_NUMBER="${{ steps.check-existing-pr.outputs.pr_number }}"
|
|
105
|
-
PR_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER"
|
|
106
|
-
echo "prNumber=$PR_NUMBER" >> $GITHUB_OUTPUT
|
|
107
|
-
echo "prUrl=$PR_URL" >> $GITHUB_OUTPUT
|
|
108
|
-
echo "✅ Using existing PR #$PR_NUMBER"
|
|
109
|
-
echo "🔗 URL: $PR_URL"
|
|
110
|
-
|
|
111
|
-
- name: Action Summary
|
|
112
|
-
shell: bash
|
|
113
|
-
run: |
|
|
114
|
-
if [ "${{ steps.create-pr.outputs.prNumber }}" != "" ]; then
|
|
115
|
-
echo "✅ Successfully created PR #${{ steps.create-pr.outputs.prNumber }}"
|
|
116
|
-
echo "🔗 URL: ${{ steps.create-pr.outputs.prUrl }}"
|
|
117
|
-
elif [ "${{ steps.use-existing-pr.outputs.prNumber }}" != "" ]; then
|
|
118
|
-
echo "ℹ️ Using existing PR #${{ steps.use-existing-pr.outputs.prNumber }}"
|
|
119
|
-
echo "🔗 URL: ${{ steps.use-existing-pr.outputs.prUrl }}"
|
|
120
|
-
else
|
|
121
|
-
echo "❌ No PR created or found"
|
|
122
|
-
fi
|