gagen 0.1.0 → 0.1.1
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 +23 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
# `
|
|
1
|
+
# `gagen`
|
|
2
2
|
|
|
3
3
|
[](https://jsr.io/@david/gagen)
|
|
4
4
|
[](http://www.npmjs.com/package/gagen)
|
|
5
5
|
|
|
6
6
|
Generate complex GitHub Actions YAML files using a declarative API.
|
|
7
7
|
|
|
8
|
+
Gagen lets you define workflows in TypeScript with a fluent, declarative API
|
|
9
|
+
that automatically resolves step ordering and propagates conditions. The
|
|
10
|
+
condition propagation helps skip unnecessary setup steps and eliminates needing
|
|
11
|
+
to repeat condition text over and over again.
|
|
12
|
+
|
|
8
13
|
## Basic usage
|
|
9
14
|
|
|
10
15
|
```ts
|
|
@@ -14,7 +19,7 @@ import {
|
|
|
14
19
|
createWorkflow,
|
|
15
20
|
step,
|
|
16
21
|
steps,
|
|
17
|
-
} from "
|
|
22
|
+
} from "gagen";
|
|
18
23
|
|
|
19
24
|
const checkout = step({
|
|
20
25
|
uses: "actions/checkout@v6",
|
|
@@ -38,7 +43,10 @@ const lint = steps(
|
|
|
38
43
|
name: "Deno Lint",
|
|
39
44
|
run: "deno lint",
|
|
40
45
|
}).dependsOn(installDeno),
|
|
41
|
-
)
|
|
46
|
+
)
|
|
47
|
+
.dependsOn(checkout)
|
|
48
|
+
// this condition gets propagated to installDeno, but not checkout
|
|
49
|
+
.if(conditions.isBranch("main").not());
|
|
42
50
|
|
|
43
51
|
// only specify the leaf steps — the other steps are pulled in automatically
|
|
44
52
|
createWorkflow({
|
|
@@ -63,9 +71,11 @@ existing file and compares the parsed YAML — exiting with a non-zero code if
|
|
|
63
71
|
they differ. This lets you add a CI step to verify the generated file is up to
|
|
64
72
|
date:
|
|
65
73
|
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
```ts
|
|
75
|
+
const lintStep = step({
|
|
76
|
+
name: "Lint CI generation",
|
|
77
|
+
run: "./.github/workflows/ci.generate.ts --lint",
|
|
78
|
+
});
|
|
69
79
|
```
|
|
70
80
|
|
|
71
81
|
## Conditions
|
|
@@ -73,7 +83,7 @@ date:
|
|
|
73
83
|
Build type-safe GitHub Actions expressions with a fluent API:
|
|
74
84
|
|
|
75
85
|
```ts
|
|
76
|
-
import { expr } from "
|
|
86
|
+
import { expr } from "gagen";
|
|
77
87
|
|
|
78
88
|
const ref = expr("github.ref");
|
|
79
89
|
const os = expr("matrix.os");
|
|
@@ -103,7 +113,7 @@ The `conditions` object provides composable helpers for common GitHub Actions
|
|
|
103
113
|
patterns:
|
|
104
114
|
|
|
105
115
|
```ts
|
|
106
|
-
import { conditions } from "
|
|
116
|
+
import { conditions } from "gagen";
|
|
107
117
|
|
|
108
118
|
const { status, isTag, isBranch, isEvent } = conditions;
|
|
109
119
|
|
|
@@ -235,7 +245,7 @@ Steps can declare outputs. When a job references another job's outputs, the
|
|
|
235
245
|
`needs` dependency is inferred automatically.
|
|
236
246
|
|
|
237
247
|
```ts
|
|
238
|
-
import { createWorkflow, job, step } from "
|
|
248
|
+
import { createWorkflow, job, step } from "gagen";
|
|
239
249
|
|
|
240
250
|
const checkStep = step({
|
|
241
251
|
id: "check",
|
|
@@ -331,7 +341,7 @@ Error: Cycle detected in step ordering: A → B → A
|
|
|
331
341
|
`defineMatrix()` gives you typed access to matrix values:
|
|
332
342
|
|
|
333
343
|
```ts
|
|
334
|
-
import { defineMatrix } from "
|
|
344
|
+
import { defineMatrix } from "gagen";
|
|
335
345
|
|
|
336
346
|
const matrix = defineMatrix({
|
|
337
347
|
include: [
|
|
@@ -387,7 +397,7 @@ const matrix = defineMatrix({
|
|
|
387
397
|
Type-safe workflow and job permissions:
|
|
388
398
|
|
|
389
399
|
```ts
|
|
390
|
-
import { createWorkflow } from "
|
|
400
|
+
import { createWorkflow } from "gagen";
|
|
391
401
|
|
|
392
402
|
const wf = createWorkflow({
|
|
393
403
|
name: "ci",
|
|
@@ -425,7 +435,7 @@ Define reusable workflows with `workflow_call` triggers and call them from other
|
|
|
425
435
|
jobs:
|
|
426
436
|
|
|
427
437
|
```ts
|
|
428
|
-
import { createWorkflow } from "
|
|
438
|
+
import { createWorkflow } from "gagen";
|
|
429
439
|
|
|
430
440
|
// define a reusable workflow
|
|
431
441
|
const wf = createWorkflow({
|
|
@@ -480,7 +490,7 @@ import {
|
|
|
480
490
|
createWorkflow,
|
|
481
491
|
defineArtifact,
|
|
482
492
|
step,
|
|
483
|
-
} from "
|
|
493
|
+
} from "gagen";
|
|
484
494
|
|
|
485
495
|
const artifact = defineArtifact("build-output");
|
|
486
496
|
|