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
|
@@ -1,6 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate Version Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that calculates the next semantic version based on
|
|
5
|
+
* conventional commits. Uses `release-it` to analyze commit history and determine
|
|
6
|
+
* the appropriate version bump (major, minor, or patch).
|
|
7
|
+
*
|
|
8
|
+
* ## Purpose
|
|
9
|
+
*
|
|
10
|
+
* Automates semantic versioning in the CI/CD pipeline by:
|
|
11
|
+
* - Analyzing conventional commit messages since the last tag
|
|
12
|
+
* - Determining the appropriate version bump (feat→minor, fix→patch, BREAKING→major)
|
|
13
|
+
* - Installing and running release-it for version calculation
|
|
14
|
+
* - Outputting the calculated version for use in subsequent jobs
|
|
15
|
+
*
|
|
16
|
+
* ## Generated Action Location
|
|
17
|
+
*
|
|
18
|
+
* `.github/actions/calculate-version/action.yml`
|
|
19
|
+
*
|
|
20
|
+
* ## Usage in Workflows
|
|
21
|
+
*
|
|
22
|
+
* ```yaml
|
|
23
|
+
* jobs:
|
|
24
|
+
* version:
|
|
25
|
+
* runs-on: ubuntu-latest
|
|
26
|
+
* outputs:
|
|
27
|
+
* version: ${{ steps.calc.outputs.version }}
|
|
28
|
+
* steps:
|
|
29
|
+
* - uses: ./.github/actions/calculate-version
|
|
30
|
+
* id: calc
|
|
31
|
+
* with:
|
|
32
|
+
* baseRef: main
|
|
33
|
+
*
|
|
34
|
+
* tag:
|
|
35
|
+
* needs: version
|
|
36
|
+
* steps:
|
|
37
|
+
* - run: echo "Next version: ${{ needs.version.outputs.version }}"
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @module templates/actions/calculate-version.yml.tpl
|
|
41
|
+
*/
|
|
1
42
|
import { toFile, renderTemplate } from '@featherscloud/pinion';
|
|
2
43
|
import fs from 'fs';
|
|
3
|
-
|
|
44
|
+
import { logger } from '../../utils/logger.js';
|
|
45
|
+
/**
|
|
46
|
+
* Generates the calculate-version composite action YAML content.
|
|
47
|
+
*
|
|
48
|
+
* @param {any} ctx - Context (not currently used, included for consistency)
|
|
49
|
+
* @returns {string} YAML content for the composite action
|
|
50
|
+
*/
|
|
4
51
|
const versionActionTemplate = (ctx) => {
|
|
5
52
|
return `name: 'Calculate Version'
|
|
6
53
|
description: 'Calculate semantic version using release-it and conventional commits'
|
|
@@ -36,6 +83,22 @@ runs:
|
|
|
36
83
|
git config --global user.name "github-actions[bot]"
|
|
37
84
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
38
85
|
|
|
86
|
+
- name: Ensure on branch (not detached HEAD)
|
|
87
|
+
shell: bash
|
|
88
|
+
run: |
|
|
89
|
+
# release-it requires a branch ref, not detached HEAD
|
|
90
|
+
# If we're in detached HEAD, create a temporary branch
|
|
91
|
+
if ! git symbolic-ref -q HEAD > /dev/null; then
|
|
92
|
+
echo "⚠️ In detached HEAD state, creating temporary branch"
|
|
93
|
+
TEMP_BRANCH="temp-release-it-$(git rev-parse --short HEAD)"
|
|
94
|
+
git checkout -b "$TEMP_BRANCH"
|
|
95
|
+
# Set upstream to track the branch we're calculating version for
|
|
96
|
+
git branch --set-upstream-to=origin/\${{ github.ref_name }} "$TEMP_BRANCH" 2>/dev/null || true
|
|
97
|
+
echo "✅ Created temporary branch: $TEMP_BRANCH"
|
|
98
|
+
else
|
|
99
|
+
echo "✅ Already on a branch: $(git branch --show-current)"
|
|
100
|
+
fi
|
|
101
|
+
|
|
39
102
|
- name: Get existing version tag
|
|
40
103
|
id: get_version_old
|
|
41
104
|
shell: bash
|
|
@@ -47,7 +110,7 @@ runs:
|
|
|
47
110
|
echo "Current commit hash: $COMMIT_HASH"
|
|
48
111
|
|
|
49
112
|
# Check for tags on the current commit
|
|
50
|
-
TAG=$(git tag --points-at $COMMIT_HASH | grep -E '^v[0-9]+\\.[0-9]+\\.[0-9]
|
|
113
|
+
TAG=$(git tag --points-at $COMMIT_HASH | grep -E '^v[0-9]+\\.[0-9]+\\.[0-9]+$' || true)
|
|
51
114
|
echo "Tags found: $TAG"
|
|
52
115
|
|
|
53
116
|
if [ -z "$TAG" ]; then
|
|
@@ -109,13 +172,19 @@ runs:
|
|
|
109
172
|
run: |
|
|
110
173
|
echo "Version determined: \${{ steps.set_version.outputs.version }}"`;
|
|
111
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* Generator entry point for calculate-version composite action.
|
|
177
|
+
*
|
|
178
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
179
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
180
|
+
*/
|
|
112
181
|
export const generate = (ctx) => Promise.resolve(ctx)
|
|
113
182
|
.then((ctx) => {
|
|
114
183
|
// Check if file exists to determine merge status
|
|
115
184
|
const filePath = '.github/actions/calculate-version/action.yml';
|
|
116
185
|
const exists = fs.existsSync(filePath);
|
|
117
186
|
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
118
|
-
|
|
187
|
+
logger.verbose(`${status} ${filePath}`);
|
|
119
188
|
return ctx;
|
|
120
189
|
})
|
|
121
190
|
.then(renderTemplate(versionActionTemplate, toFile('.github/actions/calculate-version/action.yml')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-version.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/calculate-version.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"calculate-version.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/calculate-version.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACzC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6EAyHoE,CAAA;AAC7E,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,8CAA8C,CAAA;IAC/D,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,qBAAqB,EAAE,MAAM,CAAC,8CAA8C,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Pull Request Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that creates pull requests between branches, used for
|
|
5
|
+
* automating branch promotion in trunk-based development workflows.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/actions/create-pr.yml.tpl
|
|
8
|
+
*/
|
|
1
9
|
import { PinionContext } from '@featherscloud/pinion';
|
|
10
|
+
/**
|
|
11
|
+
* Generator entry point for create-pr composite action.
|
|
12
|
+
*
|
|
13
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
14
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
15
|
+
*/
|
|
2
16
|
export declare const generate: (ctx: PinionContext) => Promise<any>;
|
|
3
17
|
//# sourceMappingURL=create-pr.yml.tpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-pr.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/create-pr.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"create-pr.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/create-pr.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AA8I7E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAUsD,CAAA"}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Pull Request Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that creates pull requests between branches, used for
|
|
5
|
+
* automating branch promotion in trunk-based development workflows.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/actions/create-pr.yml.tpl
|
|
8
|
+
*/
|
|
1
9
|
import { toFile, renderTemplate } from '@featherscloud/pinion';
|
|
2
10
|
import fs from 'fs';
|
|
3
11
|
import dedent from 'dedent';
|
|
4
|
-
|
|
12
|
+
import { logger } from '../../utils/logger.js';
|
|
13
|
+
/**
|
|
14
|
+
* Generates the create-pr composite action YAML content.
|
|
15
|
+
*
|
|
16
|
+
* @param {any} ctx - Context (not currently used)
|
|
17
|
+
* @returns {string} YAML content for the composite action
|
|
18
|
+
*/
|
|
5
19
|
const createprActionTemplate = (ctx) => {
|
|
6
20
|
return dedent `name: 'Create Pull Request'
|
|
7
21
|
description: 'Create a pull request between source and target branches'
|
|
@@ -132,13 +146,19 @@ const createprActionTemplate = (ctx) => {
|
|
|
132
146
|
echo "❌ No PR created or found"
|
|
133
147
|
fi`;
|
|
134
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Generator entry point for create-pr composite action.
|
|
151
|
+
*
|
|
152
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
153
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
154
|
+
*/
|
|
135
155
|
export const generate = (ctx) => Promise.resolve(ctx)
|
|
136
156
|
.then((ctx) => {
|
|
137
157
|
// Check if file exists to determine merge status
|
|
138
158
|
const filePath = '.github/actions/create-pr/action.yml';
|
|
139
159
|
const exists = fs.existsSync(filePath);
|
|
140
160
|
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
141
|
-
|
|
161
|
+
logger.verbose(`${status} ${filePath}`);
|
|
142
162
|
return ctx;
|
|
143
163
|
})
|
|
144
164
|
.then(renderTemplate(createprActionTemplate, toFile('.github/actions/create-pr/action.yml')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-pr.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/create-pr.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"create-pr.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/create-pr.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,CAAC,GAAQ,EAAE,EAAE;IAC1C,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA+HA,CAAA;AACf,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,sCAAsC,CAAA;IACvD,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,sBAAsB,EAAE,MAAM,CAAC,sCAAsC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Release Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that creates GitHub releases with auto-generated
|
|
5
|
+
* release notes from commit history. Used on the final branch (typically main)
|
|
6
|
+
* after successful version calculation and tagging.
|
|
7
|
+
*
|
|
8
|
+
* @module templates/actions/create-release.yml.tpl
|
|
9
|
+
*/
|
|
10
|
+
import { PinionContext } from '@featherscloud/pinion';
|
|
11
|
+
/**
|
|
12
|
+
* Generator entry point for create-release composite action.
|
|
13
|
+
*
|
|
14
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
15
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
16
|
+
*/
|
|
17
|
+
export declare const generate: (ctx: PinionContext) => Promise<any>;
|
|
18
|
+
//# sourceMappingURL=create-release.yml.tpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-release.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/create-release.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAqH7E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAU0D,CAAA"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Release Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that creates GitHub releases with auto-generated
|
|
5
|
+
* release notes from commit history. Used on the final branch (typically main)
|
|
6
|
+
* after successful version calculation and tagging.
|
|
7
|
+
*
|
|
8
|
+
* @module templates/actions/create-release.yml.tpl
|
|
9
|
+
*/
|
|
10
|
+
import { toFile, renderTemplate } from '@featherscloud/pinion';
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
import dedent from 'dedent';
|
|
13
|
+
import { logger } from '../../utils/logger.js';
|
|
14
|
+
/**
|
|
15
|
+
* Generates the create-release composite action YAML content.
|
|
16
|
+
*
|
|
17
|
+
* @param {any} ctx - Context (not currently used)
|
|
18
|
+
* @returns {string} YAML content for the composite action
|
|
19
|
+
*/
|
|
20
|
+
const releaseActionTemplate = (ctx) => {
|
|
21
|
+
return dedent `name: 'Create Release'
|
|
22
|
+
description: 'Create a GitHub release with auto-generated release notes'
|
|
23
|
+
author: 'PipeCraft'
|
|
24
|
+
|
|
25
|
+
inputs:
|
|
26
|
+
version:
|
|
27
|
+
description: 'Version to release (e.g., v1.2.3)'
|
|
28
|
+
required: true
|
|
29
|
+
token:
|
|
30
|
+
description: 'GitHub token for authentication'
|
|
31
|
+
required: false
|
|
32
|
+
default: \${{ github.token }}
|
|
33
|
+
publish-workflow:
|
|
34
|
+
description: 'Name of the publish workflow file to trigger (e.g., publish.yml)'
|
|
35
|
+
required: false
|
|
36
|
+
default: 'publish.yml'
|
|
37
|
+
|
|
38
|
+
outputs:
|
|
39
|
+
release_url:
|
|
40
|
+
description: 'The URL of the created release'
|
|
41
|
+
value: \${{ steps.create.outputs.release_url }}
|
|
42
|
+
release_id:
|
|
43
|
+
description: 'The ID of the created release'
|
|
44
|
+
value: \${{ steps.create.outputs.release_id }}
|
|
45
|
+
|
|
46
|
+
runs:
|
|
47
|
+
using: 'composite'
|
|
48
|
+
steps:
|
|
49
|
+
- name: Checkout Code
|
|
50
|
+
uses: actions/checkout@v4
|
|
51
|
+
with:
|
|
52
|
+
fetch-depth: 0
|
|
53
|
+
token: \${{ inputs.token }}
|
|
54
|
+
|
|
55
|
+
- name: Create GitHub Release
|
|
56
|
+
id: create
|
|
57
|
+
shell: bash
|
|
58
|
+
env:
|
|
59
|
+
GH_TOKEN: \${{ inputs.token }}
|
|
60
|
+
run: |
|
|
61
|
+
VERSION="\${{ inputs.version }}"
|
|
62
|
+
echo "📦 Creating GitHub release for $VERSION"
|
|
63
|
+
|
|
64
|
+
# Generate release notes from commits since last tag
|
|
65
|
+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
66
|
+
|
|
67
|
+
if [ -n "$PREVIOUS_TAG" ]; then
|
|
68
|
+
echo "📝 Generating release notes from $PREVIOUS_TAG to HEAD"
|
|
69
|
+
RELEASE_NOTES=$(git log $PREVIOUS_TAG..HEAD --pretty=format:"- %s" --no-merges)
|
|
70
|
+
else
|
|
71
|
+
echo "📝 Generating release notes from all commits"
|
|
72
|
+
RELEASE_NOTES=$(git log --pretty=format:"- %s" --no-merges)
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Create release with notes
|
|
76
|
+
RELEASE_OUTPUT=$(gh release create "$VERSION" \\
|
|
77
|
+
--title "Release $VERSION" \\
|
|
78
|
+
--notes "$RELEASE_NOTES" \\
|
|
79
|
+
--latest 2>&1)
|
|
80
|
+
|
|
81
|
+
RELEASE_EXIT_CODE=$?
|
|
82
|
+
|
|
83
|
+
if [ $RELEASE_EXIT_CODE -eq 0 ]; then
|
|
84
|
+
# Extract release URL from output
|
|
85
|
+
RELEASE_URL=$(echo "$RELEASE_OUTPUT" | grep -oE 'https://github.com/.*/releases/.*')
|
|
86
|
+
echo "release_url=$RELEASE_URL" >> $GITHUB_OUTPUT
|
|
87
|
+
|
|
88
|
+
# Get release ID using gh api
|
|
89
|
+
RELEASE_ID=$(gh api repos/\${{ github.repository }}/releases/tags/$VERSION --jq '.id')
|
|
90
|
+
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
|
|
91
|
+
|
|
92
|
+
echo "✅ Release created successfully"
|
|
93
|
+
echo "🔗 URL: $RELEASE_URL"
|
|
94
|
+
else
|
|
95
|
+
echo "❌ Failed to create release"
|
|
96
|
+
echo "$RELEASE_OUTPUT"
|
|
97
|
+
exit 1
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
- name: Trigger Publish Workflow (if exists)
|
|
101
|
+
shell: bash
|
|
102
|
+
env:
|
|
103
|
+
GH_TOKEN: \${{ inputs.token }}
|
|
104
|
+
run: |
|
|
105
|
+
VERSION="\${{ inputs.version }}"
|
|
106
|
+
PUBLISH_WORKFLOW="\${{ inputs.publish-workflow }}"
|
|
107
|
+
|
|
108
|
+
# Check if publish workflow file exists
|
|
109
|
+
if [ -f ".github/workflows/$PUBLISH_WORKFLOW" ]; then
|
|
110
|
+
echo "🔄 Triggering $PUBLISH_WORKFLOW for $VERSION"
|
|
111
|
+
|
|
112
|
+
# Trigger the publish workflow with the release tag
|
|
113
|
+
# This is necessary because GITHUB_TOKEN release creation doesn't trigger workflows
|
|
114
|
+
if gh workflow run "$PUBLISH_WORKFLOW" --field tag="$VERSION" 2>&1; then
|
|
115
|
+
echo "✅ Publish workflow triggered for $VERSION"
|
|
116
|
+
else
|
|
117
|
+
echo "⚠️ Failed to trigger publish workflow, but continuing"
|
|
118
|
+
echo " Check that $PUBLISH_WORKFLOW accepts workflow_dispatch with a 'tag' input"
|
|
119
|
+
fi
|
|
120
|
+
else
|
|
121
|
+
echo "ℹ️ No $PUBLISH_WORKFLOW workflow found - skipping publish trigger"
|
|
122
|
+
echo " This is normal if you don't have a separate publish workflow"
|
|
123
|
+
fi`;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Generator entry point for create-release composite action.
|
|
127
|
+
*
|
|
128
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
129
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
130
|
+
*/
|
|
131
|
+
export const generate = (ctx) => Promise.resolve(ctx)
|
|
132
|
+
.then((ctx) => {
|
|
133
|
+
// Check if file exists to determine merge status
|
|
134
|
+
const filePath = '.github/actions/create-release/action.yml';
|
|
135
|
+
const exists = fs.existsSync(filePath);
|
|
136
|
+
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
137
|
+
logger.verbose(`${status} ${filePath}`);
|
|
138
|
+
return ctx;
|
|
139
|
+
})
|
|
140
|
+
.then(renderTemplate(releaseActionTemplate, toFile('.github/actions/create-release/action.yml')));
|
|
141
|
+
//# sourceMappingURL=create-release.yml.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-release.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/create-release.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACzC,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAsGA,CAAA;AACf,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,2CAA2C,CAAA;IAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,qBAAqB,EAAE,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Tag Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that creates and pushes git tags, and optionally creates
|
|
5
|
+
* GitHub releases. Used after version calculation to tag the codebase with semantic versions.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/actions/create-tag.yml.tpl
|
|
8
|
+
*/
|
|
1
9
|
import { PinionContext } from '@featherscloud/pinion';
|
|
10
|
+
/**
|
|
11
|
+
* Generator entry point for create-tag composite action.
|
|
12
|
+
*
|
|
13
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
14
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
15
|
+
*/
|
|
2
16
|
export declare const generate: (ctx: PinionContext) => Promise<any>;
|
|
3
17
|
//# sourceMappingURL=create-tag.yml.tpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-tag.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/create-tag.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"create-tag.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/create-tag.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AA4G7E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAUkD,CAAA"}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Tag Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that creates and pushes git tags, and optionally creates
|
|
5
|
+
* GitHub releases. Used after version calculation to tag the codebase with semantic versions.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/actions/create-tag.yml.tpl
|
|
8
|
+
*/
|
|
1
9
|
import { toFile, renderTemplate } from '@featherscloud/pinion';
|
|
2
10
|
import fs from 'fs';
|
|
3
11
|
import dedent from 'dedent';
|
|
4
|
-
|
|
12
|
+
import { logger } from '../../utils/logger.js';
|
|
13
|
+
/**
|
|
14
|
+
* Generates the create-tag composite action YAML content.
|
|
15
|
+
*
|
|
16
|
+
* @param {any} ctx - Context (not currently used)
|
|
17
|
+
* @returns {string} YAML content for the composite action
|
|
18
|
+
*/
|
|
5
19
|
const tagActionTemplate = (ctx) => {
|
|
6
20
|
return dedent `name: 'Tag Version'
|
|
7
21
|
description: 'Create and push a Git tag for a given version'
|
|
@@ -98,13 +112,19 @@ const tagActionTemplate = (ctx) => {
|
|
|
98
112
|
echo "❌ Failed to create tag: \${{ steps.tag.outputs.tag_name }}"
|
|
99
113
|
fi`;
|
|
100
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Generator entry point for create-tag composite action.
|
|
117
|
+
*
|
|
118
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
119
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
120
|
+
*/
|
|
101
121
|
export const generate = (ctx) => Promise.resolve(ctx)
|
|
102
122
|
.then((ctx) => {
|
|
103
123
|
// Check if file exists to determine merge status
|
|
104
124
|
const filePath = '.github/actions/create-tag/action.yml';
|
|
105
125
|
const exists = fs.existsSync(filePath);
|
|
106
126
|
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
107
|
-
|
|
127
|
+
logger.verbose(`${status} ${filePath}`);
|
|
108
128
|
return ctx;
|
|
109
129
|
})
|
|
110
130
|
.then(renderTemplate(tagActionTemplate, toFile('.github/actions/create-tag/action.yml')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-tag.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/create-tag.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,
|
|
1
|
+
{"version":3,"file":"create-tag.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/create-tag.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACrC,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA6FA,CAAA;AACf,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,uCAAuC,CAAA;IACxD,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,MAAM,CAAC,uCAAuC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect Changes Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a GitHub composite action that detects which domains (application areas)
|
|
5
|
+
* have changes in a pull request. This is the foundation for PipeCraft's path-based
|
|
6
|
+
* conditional workflow execution.
|
|
7
|
+
*
|
|
8
|
+
* ## Purpose
|
|
9
|
+
*
|
|
10
|
+
* In monorepos or multi-domain projects, not every change affects every part of the
|
|
11
|
+
* system. This action uses GitHub's `dorny/paths-filter` to detect which domains
|
|
12
|
+
* have modifications, allowing subsequent jobs to run conditionally.
|
|
13
|
+
*
|
|
14
|
+
* ## How It Works
|
|
15
|
+
*
|
|
16
|
+
* 1. Checks out the repository with full history
|
|
17
|
+
* 2. Uses paths-filter action to check each domain's file patterns
|
|
18
|
+
* 3. Outputs a boolean for each domain (true if changed, false if not)
|
|
19
|
+
* 4. Logs results for debugging
|
|
20
|
+
*
|
|
21
|
+
* ## Generated Action Location
|
|
22
|
+
*
|
|
23
|
+
* `.github/actions/detect-changes/action.yml`
|
|
24
|
+
*
|
|
25
|
+
* ## Usage in Workflows
|
|
26
|
+
*
|
|
27
|
+
* ```yaml
|
|
28
|
+
* jobs:
|
|
29
|
+
* changes:
|
|
30
|
+
* runs-on: ubuntu-latest
|
|
31
|
+
* outputs:
|
|
32
|
+
* api: ${{ steps.changes.outputs.api }}
|
|
33
|
+
* web: ${{ steps.changes.outputs.web }}
|
|
34
|
+
* steps:
|
|
35
|
+
* - uses: ./.github/actions/detect-changes
|
|
36
|
+
* id: changes
|
|
37
|
+
* with:
|
|
38
|
+
* baseRef: main
|
|
39
|
+
*
|
|
40
|
+
* test-api:
|
|
41
|
+
* needs: changes
|
|
42
|
+
* if: needs.changes.outputs.api == 'true'
|
|
43
|
+
* # Only runs if API domain changed
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @module templates/actions/detect-changes.yml.tpl
|
|
47
|
+
*/
|
|
1
48
|
import { PinionContext } from '@featherscloud/pinion';
|
|
49
|
+
/**
|
|
50
|
+
* Generator entry point for detect-changes composite action.
|
|
51
|
+
*
|
|
52
|
+
* Generates the `.github/actions/detect-changes/action.yml` file with domain-specific
|
|
53
|
+
* change detection logic. This action is used by the main pipeline to determine which
|
|
54
|
+
* domains have changes and need to run tests/deployment.
|
|
55
|
+
*
|
|
56
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
57
|
+
* @param {Record<string, DomainConfig>} ctx.domains - Domain configurations
|
|
58
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* await generate({
|
|
63
|
+
* cwd: '/path/to/project',
|
|
64
|
+
* domains: {
|
|
65
|
+
* api: { paths: ['src/api/**'], description: 'API' },
|
|
66
|
+
* web: { paths: ['src/web/**'], description: 'Web' }
|
|
67
|
+
* }
|
|
68
|
+
* })
|
|
69
|
+
* // Creates: .github/actions/detect-changes/action.yml
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
2
72
|
export declare const generate: (ctx: PinionContext) => Promise<any>;
|
|
3
73
|
//# sourceMappingURL=detect-changes.yml.tpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-changes.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/detect-changes.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"detect-changes.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/detect-changes.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAsG7E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAU0D,CAAA"}
|
|
@@ -1,6 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect Changes Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a GitHub composite action that detects which domains (application areas)
|
|
5
|
+
* have changes in a pull request. This is the foundation for PipeCraft's path-based
|
|
6
|
+
* conditional workflow execution.
|
|
7
|
+
*
|
|
8
|
+
* ## Purpose
|
|
9
|
+
*
|
|
10
|
+
* In monorepos or multi-domain projects, not every change affects every part of the
|
|
11
|
+
* system. This action uses GitHub's `dorny/paths-filter` to detect which domains
|
|
12
|
+
* have modifications, allowing subsequent jobs to run conditionally.
|
|
13
|
+
*
|
|
14
|
+
* ## How It Works
|
|
15
|
+
*
|
|
16
|
+
* 1. Checks out the repository with full history
|
|
17
|
+
* 2. Uses paths-filter action to check each domain's file patterns
|
|
18
|
+
* 3. Outputs a boolean for each domain (true if changed, false if not)
|
|
19
|
+
* 4. Logs results for debugging
|
|
20
|
+
*
|
|
21
|
+
* ## Generated Action Location
|
|
22
|
+
*
|
|
23
|
+
* `.github/actions/detect-changes/action.yml`
|
|
24
|
+
*
|
|
25
|
+
* ## Usage in Workflows
|
|
26
|
+
*
|
|
27
|
+
* ```yaml
|
|
28
|
+
* jobs:
|
|
29
|
+
* changes:
|
|
30
|
+
* runs-on: ubuntu-latest
|
|
31
|
+
* outputs:
|
|
32
|
+
* api: ${{ steps.changes.outputs.api }}
|
|
33
|
+
* web: ${{ steps.changes.outputs.web }}
|
|
34
|
+
* steps:
|
|
35
|
+
* - uses: ./.github/actions/detect-changes
|
|
36
|
+
* id: changes
|
|
37
|
+
* with:
|
|
38
|
+
* baseRef: main
|
|
39
|
+
*
|
|
40
|
+
* test-api:
|
|
41
|
+
* needs: changes
|
|
42
|
+
* if: needs.changes.outputs.api == 'true'
|
|
43
|
+
* # Only runs if API domain changed
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @module templates/actions/detect-changes.yml.tpl
|
|
47
|
+
*/
|
|
1
48
|
import { toFile, renderTemplate } from '@featherscloud/pinion';
|
|
2
49
|
import fs from 'fs';
|
|
3
|
-
|
|
50
|
+
import { logger } from '../../utils/logger.js';
|
|
51
|
+
/**
|
|
52
|
+
* Generates the detect-changes composite action YAML content.
|
|
53
|
+
*
|
|
54
|
+
* Creates a GitHub Actions composite action that:
|
|
55
|
+
* - Accepts a base branch reference for comparison
|
|
56
|
+
* - Defines outputs for each configured domain
|
|
57
|
+
* - Uses dorny/paths-filter to detect file changes
|
|
58
|
+
* - Merges filter outputs into domain-specific outputs
|
|
59
|
+
* - Logs detection results
|
|
60
|
+
*
|
|
61
|
+
* @param {any} ctx - Context containing domains configuration
|
|
62
|
+
* @param {Record<string, DomainConfig>} ctx.domains - Domain configurations with path patterns
|
|
63
|
+
* @returns {string} YAML content for the composite action
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const yaml = changesActionTemplate({
|
|
68
|
+
* domains: {
|
|
69
|
+
* api: { paths: ['src/api/**'] },
|
|
70
|
+
* web: { paths: ['src/web/**'] }
|
|
71
|
+
* }
|
|
72
|
+
* })
|
|
73
|
+
* // Generates action with 'api' and 'web' outputs
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
4
76
|
const changesActionTemplate = (ctx) => {
|
|
5
77
|
const domainOutputs = Object.entries(ctx.domains).map((entry) => {
|
|
6
78
|
const [domainName, domainConfig] = entry;
|
|
@@ -20,6 +92,7 @@ const changesActionTemplate = (ctx) => {
|
|
|
20
92
|
const [domainName, domainConfig] = entry;
|
|
21
93
|
return ` echo " ${domainName}: \${{ contains(steps.filter.outputs.changes, '${domainName}') }}"`;
|
|
22
94
|
}).join('\n');
|
|
95
|
+
// Generate the composite action YAML
|
|
23
96
|
return `name: 'Detect Changes'
|
|
24
97
|
description: 'Detect changes in different application domains based on file paths'
|
|
25
98
|
author: 'Pipecraft'
|
|
@@ -66,13 +139,36 @@ ${domainEchoes}
|
|
|
66
139
|
echo "📋 Change Detection Results:"
|
|
67
140
|
${domainResults}`;
|
|
68
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Generator entry point for detect-changes composite action.
|
|
144
|
+
*
|
|
145
|
+
* Generates the `.github/actions/detect-changes/action.yml` file with domain-specific
|
|
146
|
+
* change detection logic. This action is used by the main pipeline to determine which
|
|
147
|
+
* domains have changes and need to run tests/deployment.
|
|
148
|
+
*
|
|
149
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
150
|
+
* @param {Record<string, DomainConfig>} ctx.domains - Domain configurations
|
|
151
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* await generate({
|
|
156
|
+
* cwd: '/path/to/project',
|
|
157
|
+
* domains: {
|
|
158
|
+
* api: { paths: ['src/api/**'], description: 'API' },
|
|
159
|
+
* web: { paths: ['src/web/**'], description: 'Web' }
|
|
160
|
+
* }
|
|
161
|
+
* })
|
|
162
|
+
* // Creates: .github/actions/detect-changes/action.yml
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
69
165
|
export const generate = (ctx) => Promise.resolve(ctx)
|
|
70
166
|
.then((ctx) => {
|
|
71
167
|
// Check if file exists to determine merge status
|
|
72
168
|
const filePath = '.github/actions/detect-changes/action.yml';
|
|
73
169
|
const exists = fs.existsSync(filePath);
|
|
74
170
|
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
75
|
-
|
|
171
|
+
logger.verbose(`${status} ${filePath}`);
|
|
76
172
|
return ctx;
|
|
77
173
|
})
|
|
78
174
|
.then(renderTemplate(changesActionTemplate, toFile('.github/actions/detect-changes/action.yml')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-changes.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/detect-changes.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"detect-changes.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/detect-changes.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AAGnB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACzC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9D,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,KAA+B,CAAC;QACnE,OAAO,KAAK,UAAU;4BACE,UAAU;sCACA,UAAU,KAAK,CAAC;IACpD,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9D,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,KAA+B,CAAC;QACnE,OAAO,aAAa,UAAU,qBAAqB,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC;IACvG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7D,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,KAA+B,CAAC;QACnE,OAAO,iBAAiB,UAAU,iDAAiD,UAAU,0BAA0B,CAAA;IACzH,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9D,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,KAA+B,CAAC;QACnE,OAAO,mBAAmB,UAAU,kDAAkD,UAAU,QAAQ,CAAA;IAC1G,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,qCAAqC;IACrC,OAAO;;;;;;;;;;;EAWP,aAAa;;;;;;;;;;;;;;;;;;;;;;;;EAwBb,aAAa;;;;;;EAMb,YAAY;;;EAGZ,aAAa,EAAE,CAAA;AACjB,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,2CAA2C,CAAA;IAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,qBAAqB,EAAE,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAA"}
|