gaji 0.6.0 → 1.0.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 +75 -77
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -67,26 +67,23 @@ import { getAction, Job, Workflow } from "../generated/index.js";
|
|
|
67
67
|
const checkout = getAction("actions/checkout@v5");
|
|
68
68
|
const setupNode = getAction("actions/setup-node@v4");
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
.addStep(checkout({
|
|
72
|
-
name: "Checkout code",
|
|
73
|
-
with: { "fetch-depth": 1 },
|
|
74
|
-
}))
|
|
75
|
-
.addStep(setupNode({
|
|
76
|
-
with: { "node-version": "22" },
|
|
77
|
-
}))
|
|
78
|
-
.addStep({ name: "Install dependencies", run: "npm ci" })
|
|
79
|
-
.addStep({ name: "Run tests", run: "npm test" });
|
|
80
|
-
|
|
81
|
-
const workflow = new Workflow({
|
|
70
|
+
new Workflow({
|
|
82
71
|
name: "CI",
|
|
83
72
|
on: {
|
|
84
73
|
push: { branches: ["main"] },
|
|
85
74
|
pull_request: { branches: ["main"] },
|
|
86
75
|
},
|
|
87
|
-
}).
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
}).jobs(j => j
|
|
77
|
+
.add("build",
|
|
78
|
+
new Job("ubuntu-latest")
|
|
79
|
+
.steps(s => s
|
|
80
|
+
.add(checkout({ name: "Checkout code", with: { "fetch-depth": 1 } }))
|
|
81
|
+
.add(setupNode({ with: { "node-version": "22" } }))
|
|
82
|
+
.add({ name: "Install dependencies", run: "npm ci" })
|
|
83
|
+
.add({ name: "Run tests", run: "npm test" })
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
).build("ci");
|
|
90
87
|
```
|
|
91
88
|
|
|
92
89
|
Run `gaji build` and it outputs `.github/workflows/ci.yml`.
|
|
@@ -138,53 +135,58 @@ If you're willing to handle the complexity of GitHub Actions triggers (e.g., fil
|
|
|
138
135
|
Define reusable composite actions and reference them in workflows:
|
|
139
136
|
|
|
140
137
|
```typescript
|
|
141
|
-
import {
|
|
138
|
+
import { Action, ActionRef, Job, Workflow } from "../generated/index.js";
|
|
142
139
|
|
|
143
|
-
const action = new
|
|
140
|
+
const action = new Action({
|
|
144
141
|
name: "Setup",
|
|
145
142
|
description: "Setup the project environment",
|
|
146
143
|
inputs: {
|
|
147
144
|
"node-version": { description: "Node.js version", required: false, default: "20" },
|
|
148
145
|
},
|
|
149
|
-
})
|
|
150
|
-
|
|
146
|
+
})
|
|
147
|
+
.steps(s => s
|
|
148
|
+
.add({ name: "Install deps", run: "npm ci", shell: "bash" })
|
|
149
|
+
);
|
|
151
150
|
action.build("setup");
|
|
152
151
|
|
|
153
152
|
// Reference the composite action in a workflow
|
|
154
|
-
|
|
155
|
-
.addStep(CallAction.from(action).toJSON());
|
|
156
|
-
|
|
157
|
-
const workflow = new Workflow({
|
|
153
|
+
new Workflow({
|
|
158
154
|
name: "CI",
|
|
159
155
|
on: { push: {} },
|
|
160
|
-
}).
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
}).jobs(j => j
|
|
157
|
+
.add("build",
|
|
158
|
+
new Job("ubuntu-latest")
|
|
159
|
+
.steps(s => s
|
|
160
|
+
.add(ActionRef.from(action).toJSON())
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
).build("ci");
|
|
163
164
|
```
|
|
164
165
|
|
|
165
166
|
### Reusable Workflows
|
|
166
167
|
|
|
167
|
-
Call reusable workflows using `
|
|
168
|
+
Call reusable workflows using `WorkflowCall`:
|
|
168
169
|
|
|
169
170
|
```typescript
|
|
170
|
-
import {
|
|
171
|
-
|
|
172
|
-
const deploy = new CallJob("./.github/workflows/deploy.yml")
|
|
173
|
-
.with({ environment: "production" })
|
|
174
|
-
.secrets("inherit")
|
|
175
|
-
.needs(["build"]);
|
|
171
|
+
import { WorkflowCall, Workflow } from "../generated/index.js";
|
|
176
172
|
|
|
177
|
-
|
|
173
|
+
new Workflow({
|
|
178
174
|
name: "Release",
|
|
179
175
|
on: { push: { tags: ["v*"] } },
|
|
180
|
-
}).
|
|
181
|
-
|
|
182
|
-
|
|
176
|
+
}).jobs(j => j
|
|
177
|
+
.add("deploy",
|
|
178
|
+
new WorkflowCall("./.github/workflows/deploy.yml", {
|
|
179
|
+
with: { environment: "production" },
|
|
180
|
+
secrets: "inherit",
|
|
181
|
+
needs: ["build"],
|
|
182
|
+
})
|
|
183
|
+
)
|
|
184
|
+
).build("release");
|
|
183
185
|
```
|
|
184
186
|
|
|
185
187
|
### Job Options
|
|
186
188
|
|
|
187
|
-
The `Job` constructor accepts an optional second argument for
|
|
189
|
+
The `Job` constructor accepts an optional second argument for configuration:
|
|
188
190
|
|
|
189
191
|
```typescript
|
|
190
192
|
const job = new Job("ubuntu-latest", {
|
|
@@ -197,23 +199,13 @@ const job = new Job("ubuntu-latest", {
|
|
|
197
199
|
matrix: { node: ["18", "20", "22"] },
|
|
198
200
|
"fail-fast": false,
|
|
199
201
|
},
|
|
200
|
-
})
|
|
202
|
+
})
|
|
203
|
+
.steps(s => s
|
|
204
|
+
.add({ name: "Test", run: "npm test" })
|
|
205
|
+
);
|
|
201
206
|
```
|
|
202
207
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
```typescript
|
|
206
|
-
const job = new Job("ubuntu-latest")
|
|
207
|
-
.addStep({ name: "Test", run: "npm test" })
|
|
208
|
-
.needs(["setup"])
|
|
209
|
-
.env({ CI: "true" })
|
|
210
|
-
.when("github.event_name == 'push'")
|
|
211
|
-
.permissions({ contents: "read" })
|
|
212
|
-
.outputs({ result: "${{ steps.test.outputs.result }}" })
|
|
213
|
-
.strategy({ matrix: { os: ["ubuntu-latest", "macos-latest"] } })
|
|
214
|
-
.continueOnError(true)
|
|
215
|
-
.timeoutMinutes(30);
|
|
216
|
-
```
|
|
208
|
+
Steps are added via the `steps()` callback, and job-level settings are passed through the constructor. This keeps configuration separate from step definitions.
|
|
217
209
|
|
|
218
210
|
## Commands
|
|
219
211
|
|
|
@@ -286,40 +278,46 @@ gaji clean [OPTIONS]
|
|
|
286
278
|
|
|
287
279
|
## Configuration
|
|
288
280
|
|
|
289
|
-
###
|
|
281
|
+
### `gaji.config.ts`
|
|
290
282
|
|
|
291
283
|
Project-level configuration file. Created automatically by `gaji init`.
|
|
292
284
|
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
api_url = "https://github.example.com" # GitHub Enterprise URL
|
|
285
|
+
```typescript
|
|
286
|
+
import { defineConfig } from "./generated/index.js";
|
|
287
|
+
|
|
288
|
+
export default defineConfig({
|
|
289
|
+
workflows: "workflows", // TypeScript workflow source directory
|
|
290
|
+
output: ".github", // Output directory for generated YAML
|
|
291
|
+
generated: "generated", // Directory for generated type definitions
|
|
292
|
+
watch: {
|
|
293
|
+
debounce: 300, // Debounce delay for file watcher (ms)
|
|
294
|
+
ignore: ["node_modules", ".git", "generated"],
|
|
295
|
+
},
|
|
296
|
+
build: {
|
|
297
|
+
validate: true, // Validate workflow YAML (requires 'on' and 'jobs')
|
|
298
|
+
format: true, // Format YAML output
|
|
299
|
+
},
|
|
300
|
+
});
|
|
310
301
|
```
|
|
311
302
|
|
|
312
|
-
###
|
|
303
|
+
### `gaji.config.local.ts`
|
|
313
304
|
|
|
314
305
|
Local overrides for sensitive values. Add this to `.gitignore`.
|
|
315
306
|
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
307
|
+
```typescript
|
|
308
|
+
import { defineConfig } from "./generated/index.js";
|
|
309
|
+
|
|
310
|
+
export default defineConfig({
|
|
311
|
+
github: {
|
|
312
|
+
token: "ghp_your_token_here",
|
|
313
|
+
apiUrl: "https://github.example.com", // for GitHub Enterprise
|
|
314
|
+
},
|
|
315
|
+
});
|
|
320
316
|
```
|
|
321
317
|
|
|
322
|
-
Token resolution priority: `GITHUB_TOKEN` env var >
|
|
318
|
+
Token resolution priority: `GITHUB_TOKEN` env var > `gaji.config.local.ts` > `gaji.config.ts`
|
|
319
|
+
|
|
320
|
+
gaji also reads `.gaji.toml` / `.gaji.local.toml` as a fallback for existing projects.
|
|
323
321
|
|
|
324
322
|
## Documentation
|
|
325
323
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaji",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Type-safe GitHub Actions workflows in TypeScript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"provenance": true
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@gaji/linux-x64": "0.
|
|
37
|
-
"@gaji/linux-arm64": "0.
|
|
38
|
-
"@gaji/darwin-x64": "0.
|
|
39
|
-
"@gaji/darwin-arm64": "0.
|
|
40
|
-
"@gaji/win32-x64": "0.
|
|
36
|
+
"@gaji/linux-x64": "1.0.0",
|
|
37
|
+
"@gaji/linux-arm64": "1.0.0",
|
|
38
|
+
"@gaji/darwin-x64": "1.0.0",
|
|
39
|
+
"@gaji/darwin-arm64": "1.0.0",
|
|
40
|
+
"@gaji/win32-x64": "1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"github-actions",
|