pipecraft 0.29.3 → 0.36.2
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 +98 -34
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +66 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts +4 -4
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +310 -83
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts +9 -9
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +33 -24
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +7 -4
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +16 -9
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +9 -6
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.js +9 -6
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +9 -6
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +24 -52
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +281 -108
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +9 -6
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +27 -76
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/run-nx-affected.yml.tpl.d.ts +33 -0
- package/dist/templates/actions/run-nx-affected.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/run-nx-affected.yml.tpl.js +346 -0
- package/dist/templates/actions/run-nx-affected.yml.tpl.js.map +1 -0
- package/dist/templates/release-it.cjs.tpl.d.ts +1 -1
- package/dist/templates/release-it.cjs.tpl.d.ts.map +1 -1
- package/dist/templates/release-it.cjs.tpl.js +24 -26
- package/dist/templates/release-it.cjs.tpl.js.map +1 -1
- package/dist/templates/workflows/enforce-pr-target.yml.tpl.d.ts +1 -1
- package/dist/templates/workflows/enforce-pr-target.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/enforce-pr-target.yml.tpl.js +2 -3
- package/dist/templates/workflows/enforce-pr-target.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline-nx.yml.tpl.d.ts +2 -2
- package/dist/templates/workflows/pipeline-nx.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline-nx.yml.tpl.js +300 -93
- package/dist/templates/workflows/pipeline-nx.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline.yml.tpl.d.ts +2 -2
- package/dist/templates/workflows/pipeline.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline.yml.tpl.js +347 -74
- package/dist/templates/workflows/pipeline.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pr-title-check.yml.tpl.d.ts +1 -1
- package/dist/templates/workflows/pr-title-check.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pr-title-check.yml.tpl.js +101 -22
- package/dist/templates/workflows/pr-title-check.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/shared/index.d.ts +3 -2
- package/dist/templates/workflows/shared/index.d.ts.map +1 -1
- package/dist/templates/workflows/shared/index.js +3 -2
- package/dist/templates/workflows/shared/index.js.map +1 -1
- package/dist/templates/workflows/shared/operations-changes.d.ts +13 -2
- package/dist/templates/workflows/shared/operations-changes.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-changes.js +47 -16
- package/dist/templates/workflows/shared/operations-changes.js.map +1 -1
- package/dist/templates/workflows/shared/operations-domain-jobs.d.ts +18 -1
- package/dist/templates/workflows/shared/operations-domain-jobs.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-domain-jobs.js +142 -17
- package/dist/templates/workflows/shared/operations-domain-jobs.js.map +1 -1
- package/dist/templates/workflows/shared/operations-gate.d.ts +32 -0
- package/dist/templates/workflows/shared/operations-gate.d.ts.map +1 -0
- package/dist/templates/workflows/shared/operations-gate.js +77 -0
- package/dist/templates/workflows/shared/operations-gate.js.map +1 -0
- package/dist/templates/workflows/shared/operations-header.d.ts +1 -1
- package/dist/templates/workflows/shared/operations-header.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-header.js +46 -6
- package/dist/templates/workflows/shared/operations-header.js.map +1 -1
- package/dist/templates/workflows/shared/operations-tag-promote.d.ts +5 -1
- package/dist/templates/workflows/shared/operations-tag-promote.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-tag-promote.js +138 -31
- package/dist/templates/workflows/shared/operations-tag-promote.js.map +1 -1
- package/dist/templates/workflows/shared/operations-version.d.ts +3 -1
- package/dist/templates/workflows/shared/operations-version.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-version.js +18 -10
- package/dist/templates/workflows/shared/operations-version.js.map +1 -1
- package/dist/templates/yaml-format-utils.d.ts.map +1 -1
- package/dist/templates/yaml-format-utils.js.map +1 -1
- package/dist/types/index.d.ts +57 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/action-reference.d.ts +73 -0
- package/dist/utils/action-reference.d.ts.map +1 -0
- package/dist/utils/action-reference.js +120 -0
- package/dist/utils/action-reference.js.map +1 -0
- package/dist/utils/ast-path-operations.d.ts +3 -3
- package/dist/utils/ast-path-operations.d.ts.map +1 -1
- package/dist/utils/ast-path-operations.js +58 -17
- package/dist/utils/ast-path-operations.js.map +1 -1
- package/dist/utils/config.d.ts +11 -5
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +33 -8
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +4 -4
- package/dist/utils/github-setup.d.ts.map +1 -1
- package/dist/utils/github-setup.js +57 -36
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/messaging.d.ts.map +1 -1
- package/dist/utils/messaging.js +7 -3
- package/dist/utils/messaging.js.map +1 -1
- package/dist/utils/preflight.d.ts +2 -2
- package/dist/utils/preflight.d.ts.map +1 -1
- package/dist/utils/preflight.js +43 -41
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/versioning.d.ts +1 -1
- package/dist/utils/versioning.d.ts.map +1 -1
- package/dist/utils/versioning.js +10 -10
- package/dist/utils/versioning.js.map +1 -1
- package/package.json +11 -4
- package/src/generators/init.tpl.ts +374 -102
- package/src/generators/workflows.tpl.ts +54 -45
- package/dist/templates/actions/detect-changes-nx.yml.tpl.d.ts +0 -32
- package/dist/templates/actions/detect-changes-nx.yml.tpl.d.ts.map +0 -1
- package/dist/templates/actions/detect-changes-nx.yml.tpl.js +0 -227
- package/dist/templates/actions/detect-changes-nx.yml.tpl.js.map +0 -1
- package/dist/utils/idempotency.d.ts +0 -187
- package/dist/utils/idempotency.d.ts.map +0 -1
- package/dist/utils/idempotency.js +0 -304
- package/dist/utils/idempotency.js.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate Job Operation
|
|
3
|
+
*
|
|
4
|
+
* Creates a gate job that enforces "at least one success AND no failures" pattern
|
|
5
|
+
* for all test jobs. This provides a single point of control for gating downstream
|
|
6
|
+
* jobs like tag, promote, and deploy.
|
|
7
|
+
*/
|
|
8
|
+
import { type PathOperationConfig } from '../../../utils/ast-path-operations.js';
|
|
9
|
+
export interface GateJobContext {
|
|
10
|
+
testJobNames: string[];
|
|
11
|
+
deployJobNames?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* All jobs by prefix (from getDomainJobNames)
|
|
14
|
+
* Allows gating on any custom prefix jobs (e.g., lint, build, etc.)
|
|
15
|
+
*/
|
|
16
|
+
allJobsByPrefix?: Record<string, string[]>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a gate job operation that runs after all test jobs
|
|
20
|
+
*
|
|
21
|
+
* The gate job:
|
|
22
|
+
* - Runs on ALL events (PRs, push to any branch)
|
|
23
|
+
* - Depends on all test jobs
|
|
24
|
+
* - Uses "at least one success AND no failures" pattern
|
|
25
|
+
* - Provides a single gate point for downstream jobs (tag, deploy, etc.)
|
|
26
|
+
* - Always runs (even if tests are skipped) using always()
|
|
27
|
+
*
|
|
28
|
+
* @param ctx - Context containing test job names
|
|
29
|
+
* @returns Path operation config for the gate job
|
|
30
|
+
*/
|
|
31
|
+
export declare function createGateJobOperation(ctx: GateJobContext): PathOperationConfig;
|
|
32
|
+
//# sourceMappingURL=operations-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations-gate.d.ts","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-gate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uCAAuC,CAAA;AAE9C,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CAC3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,mBAAmB,CA2D/E"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate Job Operation
|
|
3
|
+
*
|
|
4
|
+
* Creates a gate job that enforces "at least one success AND no failures" pattern
|
|
5
|
+
* for all test jobs. This provides a single point of control for gating downstream
|
|
6
|
+
* jobs like tag, promote, and deploy.
|
|
7
|
+
*/
|
|
8
|
+
import { createValueFromString } from '../../../utils/ast-path-operations.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create a gate job operation that runs after all test jobs
|
|
11
|
+
*
|
|
12
|
+
* The gate job:
|
|
13
|
+
* - Runs on ALL events (PRs, push to any branch)
|
|
14
|
+
* - Depends on all test jobs
|
|
15
|
+
* - Uses "at least one success AND no failures" pattern
|
|
16
|
+
* - Provides a single gate point for downstream jobs (tag, deploy, etc.)
|
|
17
|
+
* - Always runs (even if tests are skipped) using always()
|
|
18
|
+
*
|
|
19
|
+
* @param ctx - Context containing test job names
|
|
20
|
+
* @returns Path operation config for the gate job
|
|
21
|
+
*/
|
|
22
|
+
export function createGateJobOperation(ctx) {
|
|
23
|
+
const { testJobNames, deployJobNames = [], allJobsByPrefix = {} } = ctx;
|
|
24
|
+
// Collect all jobs from all prefixes
|
|
25
|
+
const allPrefixJobs = Object.values(allJobsByPrefix).flat();
|
|
26
|
+
// Combine test jobs, deploy jobs, and all prefix-based jobs
|
|
27
|
+
// Use Set to deduplicate (test/deploy jobs might also be in allJobsByPrefix)
|
|
28
|
+
const allGateJobs = Array.from(new Set([...testJobNames, ...deployJobNames, ...allPrefixJobs]));
|
|
29
|
+
if (allGateJobs.length === 0) {
|
|
30
|
+
// No jobs to gate - return a minimal gate that always succeeds
|
|
31
|
+
return {
|
|
32
|
+
path: 'jobs.gate',
|
|
33
|
+
operation: 'overwrite',
|
|
34
|
+
spaceBefore: true,
|
|
35
|
+
commentBefore: `
|
|
36
|
+
=============================================================================
|
|
37
|
+
GATE (⚠️ Managed by Pipecraft - do not modify)
|
|
38
|
+
=============================================================================
|
|
39
|
+
Gate job that ensures tests pass before allowing tag/promote/deploy.
|
|
40
|
+
Uses pattern: at least ONE success AND NO failures (skipped is OK).
|
|
41
|
+
`,
|
|
42
|
+
value: createValueFromString(`
|
|
43
|
+
needs: [ version ]
|
|
44
|
+
if: \${{ always() && needs.version.result == 'success' }}
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
steps:
|
|
47
|
+
- name: Gate passed
|
|
48
|
+
run: echo "No test jobs configured - gate passes"
|
|
49
|
+
`)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Build the "at least one success AND no failures" condition
|
|
53
|
+
const noFailures = allGateJobs.map(job => `needs.${job}.result != 'failure'`).join(' && ');
|
|
54
|
+
const atLeastOneSuccess = allGateJobs.map(job => `needs.${job}.result == 'success'`).join(' || ');
|
|
55
|
+
const gateCondition = `always() && needs.version.result == 'success' && (${noFailures}) && (${atLeastOneSuccess})`;
|
|
56
|
+
return {
|
|
57
|
+
path: 'jobs.gate',
|
|
58
|
+
operation: 'overwrite',
|
|
59
|
+
spaceBefore: true,
|
|
60
|
+
commentBefore: `
|
|
61
|
+
=============================================================================
|
|
62
|
+
GATE (⚠️ Managed by Pipecraft - do not modify)
|
|
63
|
+
=============================================================================
|
|
64
|
+
Gate job that ensures tests pass before allowing tag/promote/deploy.
|
|
65
|
+
Uses pattern: at least ONE success AND NO failures (skipped is OK).
|
|
66
|
+
`,
|
|
67
|
+
value: createValueFromString(`
|
|
68
|
+
needs: [ version, ${allGateJobs.join(', ')} ]
|
|
69
|
+
if: \${{ ${gateCondition} }}
|
|
70
|
+
runs-on: ubuntu-latest
|
|
71
|
+
steps:
|
|
72
|
+
- name: Gate passed
|
|
73
|
+
run: echo "All tests passed - gate allows progression"
|
|
74
|
+
`)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=operations-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations-gate.js","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-gate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,qBAAqB,EAEtB,MAAM,uCAAuC,CAAA;AAY9C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAmB;IACxD,MAAM,EAAE,YAAY,EAAE,cAAc,GAAG,EAAE,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,GAAG,CAAA;IAEvE,qCAAqC;IACrC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAA;IAE3D,4DAA4D;IAC5D,6EAA6E;IAC7E,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,YAAY,EAAE,GAAG,cAAc,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;IAE/F,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,+DAA+D;QAC/D,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,WAAW;YACtB,WAAW,EAAE,IAAI;YACjB,aAAa,EAAE;;;;;;CAMpB;YACK,KAAK,EAAE,qBAAqB,CAAC;;;;;;;GAOhC,CAAC;SACC,CAAA;IACH,CAAC;IAED,6DAA6D;IAC7D,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,GAAG,sBAAsB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC1F,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,GAAG,sBAAsB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACjG,MAAM,aAAa,GAAG,qDAAqD,UAAU,SAAS,iBAAiB,GAAG,CAAA;IAElH,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,WAAW;QACtB,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE;;;;;;CAMlB;QACG,KAAK,EAAE,qBAAqB,CAAC;wBACT,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;eAC/B,aAAa;;;;;GAKzB,CAAC;KACD,CAAA;AACH,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Generates workflow header operations (name, run-name, on triggers) that are
|
|
5
5
|
* common to both Nx and path-based pipeline templates.
|
|
6
6
|
*/
|
|
7
|
-
import { PathOperationConfig } from '../../../utils/ast-path-operations.js';
|
|
7
|
+
import type { PathOperationConfig } from '../../../utils/ast-path-operations.js';
|
|
8
8
|
export interface HeaderContext {
|
|
9
9
|
branchFlow: string[];
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations-header.d.ts","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-header.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"operations-header.d.ts","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-header.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAEhF,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,aAAa,GAAG,mBAAmB,EAAE,CAsMhF"}
|
|
@@ -11,7 +11,7 @@ import { Scalar } from 'yaml';
|
|
|
11
11
|
export function createHeaderOperations(ctx) {
|
|
12
12
|
const { branchFlow } = ctx;
|
|
13
13
|
// Provide sensible defaults if branchFlow is invalid
|
|
14
|
-
const validBranchFlow =
|
|
14
|
+
const validBranchFlow = branchFlow && Array.isArray(branchFlow) && branchFlow.length > 0 ? branchFlow : ['main'];
|
|
15
15
|
const branchList = validBranchFlow.join(',');
|
|
16
16
|
return [
|
|
17
17
|
// =============================================================================
|
|
@@ -20,11 +20,7 @@ export function createHeaderOperations(ctx) {
|
|
|
20
20
|
{
|
|
21
21
|
path: 'name',
|
|
22
22
|
operation: 'preserve',
|
|
23
|
-
value: (
|
|
24
|
-
const nameScalar = new Scalar('Pipeline');
|
|
25
|
-
nameScalar.type = Scalar.QUOTE_DOUBLE;
|
|
26
|
-
return nameScalar;
|
|
27
|
-
})(),
|
|
23
|
+
value: new Scalar('Pipeline'),
|
|
28
24
|
required: true
|
|
29
25
|
},
|
|
30
26
|
// =============================================================================
|
|
@@ -36,12 +32,56 @@ export function createHeaderOperations(ctx) {
|
|
|
36
32
|
value: (() => {
|
|
37
33
|
const runNameScalar = new Scalar(`\${{ github.event_name == 'pull_request' && !contains('${branchList}', github.head_ref) && github.event.pull_request.title || github.ref_name }} #\${{ inputs.run_number || github.run_number }}\${{ inputs.version && format(' - {0}', inputs.version) || '' }}`);
|
|
38
34
|
runNameScalar.type = Scalar.QUOTE_DOUBLE;
|
|
35
|
+
runNameScalar.type = 'QUOTE_DOUBLE';
|
|
39
36
|
return runNameScalar;
|
|
40
37
|
})(),
|
|
41
38
|
required: true,
|
|
42
39
|
spaceBefore: true
|
|
43
40
|
},
|
|
44
41
|
// =============================================================================
|
|
42
|
+
// ENVIRONMENT VARIABLES
|
|
43
|
+
// =============================================================================
|
|
44
|
+
{
|
|
45
|
+
path: 'env',
|
|
46
|
+
operation: 'preserve',
|
|
47
|
+
value: {},
|
|
48
|
+
required: true,
|
|
49
|
+
spaceBefore: true,
|
|
50
|
+
commentBefore: `Git fetch depth configuration
|
|
51
|
+
- FETCH_DEPTH_AFFECTED: For change detection and Nx affected analysis
|
|
52
|
+
Lower values (50-100) improve performance, higher values (200+) improve accuracy
|
|
53
|
+
Use 0 for complete history if your branches diverge significantly
|
|
54
|
+
- FETCH_DEPTH_VERSIONING: For semantic version calculation (needs git tags)
|
|
55
|
+
Should almost always be 0 to access all tags
|
|
56
|
+
|
|
57
|
+
Runtime versions
|
|
58
|
+
Update these to match your project's requirements without regenerating workflows`
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
path: 'env.FETCH_DEPTH_AFFECTED',
|
|
62
|
+
operation: 'preserve',
|
|
63
|
+
value: new Scalar('100'),
|
|
64
|
+
required: true
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
path: 'env.FETCH_DEPTH_VERSIONING',
|
|
68
|
+
operation: 'preserve',
|
|
69
|
+
value: new Scalar('0'),
|
|
70
|
+
required: true
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
path: 'env.NODE_VERSION',
|
|
74
|
+
operation: 'preserve',
|
|
75
|
+
value: new Scalar('24'),
|
|
76
|
+
required: true
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
path: 'env.PNPM_VERSION',
|
|
80
|
+
operation: 'preserve',
|
|
81
|
+
value: new Scalar('10'),
|
|
82
|
+
required: true
|
|
83
|
+
},
|
|
84
|
+
// =============================================================================
|
|
45
85
|
// WORKFLOW TRIGGERS
|
|
46
86
|
// =============================================================================
|
|
47
87
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations-header.js","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-header.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"operations-header.js","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-header.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAO7B;;GAEG;AACH,MAAM,UAAU,sBAAsB,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CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,6BAA6B;YAC1D,QAAQ,EAAE,IAAI;SACf;KACF,CAAA;AACH,CAAC"}
|
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates the tag creation, branch promotion, and GitHub release jobs.
|
|
5
5
|
*/
|
|
6
|
-
import { PathOperationConfig } from '../../../utils/ast-path-operations.js';
|
|
6
|
+
import { type PathOperationConfig } from '../../../utils/ast-path-operations.js';
|
|
7
|
+
import type { PipecraftConfig } from '../../../types/index.js';
|
|
7
8
|
export interface TagPromoteContext {
|
|
8
9
|
branchFlow: string[];
|
|
9
10
|
deployJobNames: string[];
|
|
10
11
|
remoteTestJobNames: string[];
|
|
12
|
+
testJobNames?: string[];
|
|
13
|
+
autoMerge?: Record<string, boolean>;
|
|
14
|
+
config?: Partial<PipecraftConfig>;
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* Create tag, promote, and release job operations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations-tag-promote.d.ts","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-tag-promote.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"operations-tag-promote.d.ts","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-tag-promote.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE9D,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;CAClC;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,GAAG,EAAE,iBAAiB,GAAG,mBAAmB,EAAE,CAsJ/F"}
|
|
@@ -4,50 +4,88 @@
|
|
|
4
4
|
* Generates the tag creation, branch promotion, and GitHub release jobs.
|
|
5
5
|
*/
|
|
6
6
|
import { createValueFromString } from '../../../utils/ast-path-operations.js';
|
|
7
|
+
import { getActionReference } from '../../../utils/action-reference.js';
|
|
7
8
|
/**
|
|
8
9
|
* Create tag, promote, and release job operations
|
|
9
10
|
*/
|
|
10
11
|
export function createTagPromoteReleaseOperations(ctx) {
|
|
11
|
-
const { branchFlow, deployJobNames, remoteTestJobNames } = ctx;
|
|
12
|
+
const { branchFlow, deployJobNames, remoteTestJobNames, testJobNames = [], config = {} } = ctx;
|
|
12
13
|
// Provide sensible defaults if branchFlow is invalid
|
|
13
|
-
const validBranchFlow =
|
|
14
|
-
const allDeploymentJobs = [...deployJobNames, ...remoteTestJobNames];
|
|
14
|
+
const validBranchFlow = branchFlow && Array.isArray(branchFlow) && branchFlow.length > 0 ? branchFlow : ['main'];
|
|
15
15
|
const initialBranch = validBranchFlow[0];
|
|
16
|
+
// Get action references based on configuration
|
|
17
|
+
const tagActionRef = getActionReference('create-tag', config);
|
|
18
|
+
const promoteActionRef = getActionReference('promote-branch', config);
|
|
19
|
+
const releaseActionRef = getActionReference('create-release', config);
|
|
16
20
|
// Build tag job conditional (should only run on initial branch, not on PRs)
|
|
21
|
+
// Now depends on the gate job instead of individual test jobs
|
|
17
22
|
const tagConditions = [
|
|
18
23
|
'always()',
|
|
19
|
-
|
|
24
|
+
"github.event_name != 'pull_request'",
|
|
20
25
|
`github.ref_name == '${initialBranch}'`,
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
"needs.version.result == 'success'",
|
|
27
|
+
"needs.version.outputs.version != ''",
|
|
28
|
+
"needs.gate.result == 'success'" // Gate job must succeed
|
|
23
29
|
];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
tagConditions.push(`(${noFailures})`);
|
|
28
|
-
tagConditions.push(`(${atLeastOneSuccess})`);
|
|
29
|
-
}
|
|
30
|
-
const tagNeedsArray = ['version', ...allDeploymentJobs];
|
|
30
|
+
// Default needs: version + gate (gate already checks all test jobs)
|
|
31
|
+
const tagNeedsArray = ['version', 'gate'];
|
|
32
|
+
const defaultTagIfCondition = tagConditions.join(' && ');
|
|
31
33
|
return [
|
|
32
|
-
// TAG JOB
|
|
34
|
+
// TAG JOB - Ensure the job key exists with comment (but don't overwrite existing job)
|
|
33
35
|
{
|
|
34
36
|
path: 'jobs.tag',
|
|
35
|
-
operation: '
|
|
37
|
+
operation: 'preserve',
|
|
38
|
+
spaceBefore: true,
|
|
36
39
|
commentBefore: `
|
|
37
40
|
=============================================================================
|
|
38
|
-
TAG
|
|
41
|
+
TAG (⚠️ Managed by Pipecraft - customizable needs and if)
|
|
39
42
|
=============================================================================
|
|
40
|
-
Creates git tags and promotes code through branch flow.
|
|
43
|
+
Creates git tags and promotes code through branch flow.
|
|
44
|
+
The 'needs' and 'if' fields are customizable and will be preserved.
|
|
45
|
+
All other fields (runs-on, steps) are managed by Pipecraft.
|
|
41
46
|
`,
|
|
47
|
+
value: {} // Empty object - just ensures the job exists with the comment
|
|
48
|
+
},
|
|
49
|
+
// TAG JOB NEEDS - Preserve user customizations, default to version + gate
|
|
50
|
+
{
|
|
51
|
+
path: 'jobs.tag.needs',
|
|
52
|
+
operation: 'preserve',
|
|
53
|
+
value: tagNeedsArray
|
|
54
|
+
},
|
|
55
|
+
// TAG JOB IF - Preserve user customizations, default to standard conditions
|
|
56
|
+
//
|
|
57
|
+
// Now simplified: just check that gate job succeeded (gate already validates all tests)
|
|
58
|
+
//
|
|
59
|
+
// Pattern:
|
|
60
|
+
// if: ${{
|
|
61
|
+
// always() &&
|
|
62
|
+
// github.event_name != 'pull_request' &&
|
|
63
|
+
// github.ref_name == 'develop' &&
|
|
64
|
+
// needs.version.result == 'success' &&
|
|
65
|
+
// needs.version.outputs.version != '' &&
|
|
66
|
+
// needs.gate.result == 'success'
|
|
67
|
+
// }}
|
|
68
|
+
{
|
|
69
|
+
path: 'jobs.tag.if',
|
|
70
|
+
operation: 'preserve',
|
|
71
|
+
value: createValueFromString(`\${{ ${defaultTagIfCondition} }}`)
|
|
72
|
+
},
|
|
73
|
+
// TAG JOB RUNS-ON - Always managed
|
|
74
|
+
{
|
|
75
|
+
path: 'jobs.tag.runs-on',
|
|
76
|
+
operation: 'overwrite',
|
|
77
|
+
value: 'ubuntu-latest'
|
|
78
|
+
},
|
|
79
|
+
// TAG JOB STEPS - Always managed
|
|
80
|
+
{
|
|
81
|
+
path: 'jobs.tag.steps',
|
|
82
|
+
operation: 'overwrite',
|
|
42
83
|
value: createValueFromString(`
|
|
43
|
-
if: \${{ ${tagConditions.join(' && ')} }}
|
|
44
|
-
needs: [ ${tagNeedsArray.join(', ')} ]
|
|
45
|
-
runs-on: ubuntu-latest
|
|
46
|
-
steps:
|
|
47
84
|
- uses: actions/checkout@v4
|
|
48
85
|
with:
|
|
49
86
|
ref: \${{ inputs.commitSha || github.sha }}
|
|
50
|
-
|
|
87
|
+
fetch-depth: \${{ env.FETCH_DEPTH_VERSIONING }}
|
|
88
|
+
- uses: ${tagActionRef}
|
|
51
89
|
with:
|
|
52
90
|
version: \${{ needs.version.outputs.version }}
|
|
53
91
|
commitSha: \${{ inputs.commitSha || github.sha }}
|
|
@@ -57,35 +95,52 @@ Creates git tags and promotes code through branch flow.
|
|
|
57
95
|
{
|
|
58
96
|
path: 'jobs.promote',
|
|
59
97
|
operation: 'overwrite',
|
|
98
|
+
spaceBefore: true,
|
|
99
|
+
commentBefore: `
|
|
100
|
+
=============================================================================
|
|
101
|
+
PROMOTE (⚠️ Managed by Pipecraft - do not modify)
|
|
102
|
+
=============================================================================
|
|
103
|
+
Promotes code from develop to staging or main via PR.
|
|
104
|
+
`,
|
|
60
105
|
value: createValueFromString(`
|
|
61
|
-
if: \${{ always() && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.version.result == 'success' && needs.version.outputs.version != '' && (needs.tag.result == 'success' || needs.tag.result == 'skipped') && (${buildPromotableBranchesCondition(validBranchFlow)}) }}
|
|
62
106
|
needs: [ version, tag ]
|
|
107
|
+
if: \${{ always() && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.version.result == 'success' && needs.version.outputs.version != '' && (needs.tag.result == 'success' || needs.tag.result == 'skipped') && (${buildPromotableBranchesCondition(validBranchFlow)}) }}
|
|
63
108
|
runs-on: ubuntu-latest
|
|
64
109
|
steps:
|
|
65
110
|
- uses: actions/checkout@v4
|
|
66
111
|
with:
|
|
67
112
|
ref: \${{ inputs.commitSha || github.sha }}
|
|
68
|
-
|
|
113
|
+
fetch-depth: \${{ env.FETCH_DEPTH_VERSIONING }}
|
|
114
|
+
- uses: ${promoteActionRef}
|
|
69
115
|
with:
|
|
70
116
|
version: \${{ needs.version.outputs.version }}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
117
|
+
sourceBranch: \${{ github.ref_name }}
|
|
118
|
+
targetBranch: \${{ ${buildTargetBranchExpression(validBranchFlow)} }}
|
|
119
|
+
autoMerge: \${{ ${buildAutoMergeExpression(validBranchFlow, ctx.autoMerge)} }}
|
|
120
|
+
run_number: \${{ inputs.run_number || github.run_number }}
|
|
74
121
|
`)
|
|
75
122
|
},
|
|
76
123
|
// RELEASE JOB
|
|
77
124
|
{
|
|
78
125
|
path: 'jobs.release',
|
|
79
126
|
operation: 'overwrite',
|
|
127
|
+
spaceBefore: true,
|
|
128
|
+
commentBefore: `
|
|
129
|
+
=============================================================================
|
|
130
|
+
RELEASE (⚠️ Managed by Pipecraft - do not modify)
|
|
131
|
+
=============================================================================
|
|
132
|
+
Creates a release for the version.
|
|
133
|
+
`,
|
|
80
134
|
value: createValueFromString(`
|
|
81
|
-
if: \${{ always() && github.ref_name == '${validBranchFlow[validBranchFlow.length - 1]}' && needs.version.result == 'success' && needs.version.outputs.version != '' && needs.tag.result == 'success' }}
|
|
82
135
|
needs: [ tag, version ]
|
|
136
|
+
if: \${{ always() && github.ref_name == '${validBranchFlow[validBranchFlow.length - 1]}' && needs.version.result == 'success' && needs.version.outputs.version != '' && needs.tag.result == 'success' }}
|
|
83
137
|
runs-on: ubuntu-latest
|
|
84
138
|
steps:
|
|
85
139
|
- uses: actions/checkout@v4
|
|
86
140
|
with:
|
|
87
141
|
ref: \${{ inputs.commitSha || github.sha }}
|
|
88
|
-
|
|
142
|
+
fetch-depth: \${{ env.FETCH_DEPTH_VERSIONING }}
|
|
143
|
+
- uses: ${releaseActionRef}
|
|
89
144
|
with:
|
|
90
145
|
version: \${{ needs.version.outputs.version }}
|
|
91
146
|
commitSha: \${{ inputs.commitSha || github.sha }}
|
|
@@ -93,6 +148,39 @@ Creates git tags and promotes code through branch flow.
|
|
|
93
148
|
}
|
|
94
149
|
];
|
|
95
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Builds a condition that ensures at least ONE success AND NO failures for a set of jobs.
|
|
153
|
+
*
|
|
154
|
+
* This is the standard pattern for gating jobs (like tag) that depend on multiple test/deploy jobs.
|
|
155
|
+
*
|
|
156
|
+
* Pattern:
|
|
157
|
+
* - NO failures: All jobs must not be 'failure' (skipped is OK, failure is not)
|
|
158
|
+
* - AT LEAST ONE success: At least one job must be 'success' (skipped doesn't count as success)
|
|
159
|
+
*
|
|
160
|
+
* @param jobNames - Array of job names to check (e.g., ['test-cicd', 'test-core', 'deploy-docs'])
|
|
161
|
+
* @returns Condition string like: "(needs.job1.result != 'failure' && needs.job2.result != 'failure') && (needs.job1.result == 'success' || needs.job2.result == 'success')"
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* // For test jobs
|
|
166
|
+
* buildAtLeastOneSuccessNoFailuresCondition(['test-cicd', 'test-core', 'test-docs'])
|
|
167
|
+
* // Returns: "(needs.test-cicd.result != 'failure' && needs.test-core.result != 'failure' && needs.test-docs.result != 'failure') && (needs.test-cicd.result == 'success' || needs.test-core.result == 'success' || needs.test-docs.result == 'success')"
|
|
168
|
+
*
|
|
169
|
+
* // For deployment jobs
|
|
170
|
+
* buildAtLeastOneSuccessNoFailuresCondition(['deploy-staging', 'deploy-prod'])
|
|
171
|
+
* // Returns: "(needs.deploy-staging.result != 'failure' && needs.deploy-prod.result != 'failure') && (needs.deploy-staging.result == 'success' || needs.deploy-prod.result == 'success')"
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
function buildAtLeastOneSuccessNoFailuresCondition(jobNames) {
|
|
175
|
+
if (jobNames.length === 0) {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
// Ensure NO failures (skipped is OK, but failure is not)
|
|
179
|
+
const noFailures = jobNames.map(job => `needs.${job}.result != 'failure'`).join(' && ');
|
|
180
|
+
// Ensure AT LEAST ONE success (skipped jobs don't count as success)
|
|
181
|
+
const atLeastOneSuccess = jobNames.map(job => `needs.${job}.result == 'success'`).join(' || ');
|
|
182
|
+
return `(${noFailures}) && (${atLeastOneSuccess})`;
|
|
183
|
+
}
|
|
96
184
|
/**
|
|
97
185
|
* Helper to build promotable branches condition
|
|
98
186
|
* Returns a condition that checks if current branch is promotable (all except final branch)
|
|
@@ -102,14 +190,33 @@ function buildPromotableBranchesCondition(branchFlow) {
|
|
|
102
190
|
return promotableBranches.map(branch => `github.ref_name == '${branch}'`).join(' || ');
|
|
103
191
|
}
|
|
104
192
|
/**
|
|
105
|
-
* Helper to build the
|
|
193
|
+
* Helper to build the targetBranch expression
|
|
194
|
+
* Maps each source branch to its target branch
|
|
106
195
|
*/
|
|
107
|
-
function
|
|
196
|
+
function buildTargetBranchExpression(branchFlow) {
|
|
108
197
|
if (branchFlow.length === 1)
|
|
109
198
|
return `''`;
|
|
110
199
|
if (branchFlow.length === 2)
|
|
111
200
|
return `'${branchFlow[1]}'`;
|
|
112
201
|
// For 3+ branches: develop → staging, staging → main
|
|
202
|
+
// github.ref_name == 'develop' && 'staging' || 'main'
|
|
113
203
|
return `github.ref_name == '${branchFlow[0]}' && '${branchFlow[1]}' || '${branchFlow[branchFlow.length - 1]}'`;
|
|
114
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Helper to build the autoMerge expression
|
|
207
|
+
* Maps each target branch to its autoMerge setting
|
|
208
|
+
*/
|
|
209
|
+
function buildAutoMergeExpression(branchFlow, autoMerge) {
|
|
210
|
+
if (!autoMerge || branchFlow.length === 1)
|
|
211
|
+
return `'false'`;
|
|
212
|
+
if (branchFlow.length === 2) {
|
|
213
|
+
const target = branchFlow[1];
|
|
214
|
+
return `'${autoMerge[target] ? 'true' : 'false'}'`;
|
|
215
|
+
}
|
|
216
|
+
// For 3+ branches: develop → staging (check staging autoMerge), staging → main (check main autoMerge)
|
|
217
|
+
// github.ref_name == 'develop' && 'true' || 'false'
|
|
218
|
+
const stagingTarget = branchFlow[1];
|
|
219
|
+
const mainTarget = branchFlow[branchFlow.length - 1];
|
|
220
|
+
return `github.ref_name == '${branchFlow[0]}' && '${autoMerge[stagingTarget] ? 'true' : 'false'}' || '${autoMerge[mainTarget] ? 'true' : 'false'}'`;
|
|
221
|
+
}
|
|
115
222
|
//# sourceMappingURL=operations-tag-promote.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations-tag-promote.js","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-tag-promote.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"operations-tag-promote.js","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-tag-promote.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,qBAAqB,EAEtB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAYvE;;GAEG;AAC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AO,SAAS,CAAA;IAC3D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;QAC5B,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAA;IACpD,CAAC;IAED,sGAAsG;IACtG,oDAAoD;IACpD,MAAM,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;IACnC,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACpD,OAAO,uBAAuB,UAAU,CAAC,CAAC,CAAC,SACzC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OACtC,SAAS,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAA;AACtD,CAAC"}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates the version calculation job that determines the next semantic version.
|
|
5
5
|
*/
|
|
6
|
-
import { PathOperationConfig } from '../../../utils/ast-path-operations.js';
|
|
6
|
+
import { type PathOperationConfig } from '../../../utils/ast-path-operations.js';
|
|
7
|
+
import type { PipecraftConfig } from '../../../types/index.js';
|
|
7
8
|
export interface VersionContext {
|
|
8
9
|
testJobNames: string[];
|
|
9
10
|
nxEnabled?: boolean;
|
|
10
11
|
baseRef?: string;
|
|
12
|
+
config?: Partial<PipecraftConfig>;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Create the version calculation job operation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations-version.d.ts","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"operations-version.d.ts","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE9D,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;CAClC;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,cAAc,GAAG,mBAAmB,CA2DlF"}
|
|
@@ -4,16 +4,19 @@
|
|
|
4
4
|
* Generates the version calculation job that determines the next semantic version.
|
|
5
5
|
*/
|
|
6
6
|
import { createValueFromString } from '../../../utils/ast-path-operations.js';
|
|
7
|
+
import { getActionReference } from '../../../utils/action-reference.js';
|
|
7
8
|
/**
|
|
8
9
|
* Create the version calculation job operation
|
|
9
10
|
*/
|
|
10
11
|
export function createVersionJobOperation(ctx) {
|
|
11
|
-
const { testJobNames, nxEnabled = false, baseRef = 'main' } = ctx;
|
|
12
|
+
const { testJobNames, nxEnabled = false, baseRef = 'main', config = {} } = ctx;
|
|
13
|
+
// Get the action reference based on configuration
|
|
14
|
+
const actionRef = getActionReference('calculate-version', config);
|
|
12
15
|
// Build the needs array
|
|
13
|
-
const nxJobName = nxEnabled ? 'nx
|
|
16
|
+
const nxJobName = nxEnabled ? 'test-nx' : null;
|
|
14
17
|
const needsArray = ['changes', nxJobName, ...testJobNames].filter(Boolean);
|
|
15
18
|
// Build the conditional logic
|
|
16
|
-
const nxCondition = nxEnabled ?
|
|
19
|
+
const nxCondition = nxEnabled ? "needs.test-nx.result == 'success'" : '';
|
|
17
20
|
const testConditions = testJobNames.length > 0
|
|
18
21
|
? [
|
|
19
22
|
`(${testJobNames.map(job => `needs.${job}.result == 'success'`).join(' || ')})`,
|
|
@@ -22,33 +25,38 @@ export function createVersionJobOperation(ctx) {
|
|
|
22
25
|
: [];
|
|
23
26
|
const allConditions = [
|
|
24
27
|
'always()',
|
|
25
|
-
|
|
28
|
+
"github.event_name != 'pull_request'",
|
|
26
29
|
nxCondition,
|
|
27
30
|
...testConditions
|
|
28
|
-
]
|
|
31
|
+
]
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join(' && ');
|
|
29
34
|
return {
|
|
30
35
|
path: 'jobs.version',
|
|
31
36
|
operation: 'overwrite',
|
|
37
|
+
spaceBefore: true,
|
|
32
38
|
commentBefore: `
|
|
33
39
|
=============================================================================
|
|
34
|
-
VERSIONING (⚠️ Managed by Pipecraft - do not modify)
|
|
40
|
+
VERSIONING (⚠️ Managed by Pipecraft - do not modify)
|
|
35
41
|
=============================================================================
|
|
36
|
-
Calculates the next semantic version based on conventional commits.
|
|
37
|
-
Only runs on push events (skipped on pull requests).
|
|
42
|
+
Calculates the next semantic version based on conventional commits.
|
|
43
|
+
Only runs on push events (skipped on pull requests).
|
|
38
44
|
`,
|
|
39
45
|
value: createValueFromString(`
|
|
40
|
-
if: \${{ ${allConditions} }}
|
|
41
46
|
needs: [ ${needsArray.join(', ')} ]
|
|
47
|
+
if: \${{ ${allConditions} }}
|
|
42
48
|
runs-on: ubuntu-latest
|
|
43
49
|
steps:
|
|
44
50
|
- uses: actions/checkout@v4
|
|
45
51
|
with:
|
|
46
52
|
ref: \${{ inputs.commitSha || github.sha }}
|
|
47
|
-
|
|
53
|
+
fetch-depth: \${{ env.FETCH_DEPTH_VERSIONING }}
|
|
54
|
+
- uses: ${actionRef}
|
|
48
55
|
id: version
|
|
49
56
|
with:
|
|
50
57
|
baseRef: \${{ inputs.baseRef || '${baseRef}' }}
|
|
51
58
|
commitSha: \${{ inputs.commitSha || github.sha }}
|
|
59
|
+
node-version: \${{ env.NODE_VERSION }}
|
|
52
60
|
outputs:
|
|
53
61
|
version: \${{ steps.version.outputs.version }}
|
|
54
62
|
`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations-version.js","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"operations-version.js","sourceRoot":"","sources":["../../../../src/templates/workflows/shared/operations-version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,qBAAqB,EAEtB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAUvE;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAAmB;IAC3D,MAAM,EAAE,YAAY,EAAE,SAAS,GAAG,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG,CAAA;IAE9E,kDAAkD;IAClD,MAAM,SAAS,GAAG,kBAAkB,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA;IAEjE,wBAAwB;IACxB,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAA;IAC9C,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAE1E,8BAA8B;IAC9B,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,EAAE,CAAA;IACxE,MAAM,cAAc,GAClB,YAAY,CAAC,MAAM,GAAG,CAAC;QACrB,CAAC,CAAC;YACE,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,GAAG,sBAAsB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;YAC/E,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,GAAG,sBAAsB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;SACzE;QACH,CAAC,CAAC,EAAE,CAAA;IAER,MAAM,aAAa,GAAG;QACpB,UAAU;QACV,qCAAqC;QACrC,WAAW;QACX,GAAG,cAAc;KAClB;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,MAAM,CAAC,CAAA;IAEf,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,WAAW;QACtB,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE;;;;;;CAMlB;QACG,KAAK,EAAE,qBAAqB,CAAC;eAClB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;eACrB,aAAa;;;;;;;gBAOZ,SAAS;;;6CAGoB,OAAO;;;;;GAKjD,CAAC;KACD,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-format-utils.d.ts","sourceRoot":"","sources":["../../src/templates/yaml-format-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,GAAE,MAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"yaml-format-utils.d.ts","sourceRoot":"","sources":["../../src/templates/yaml-format-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,GAAE,MAAW,GAAG,MAAM,CA+BtF"}
|