Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# setup-cue

A GitHub Action which installs a CUE release on a runner and adds it to `PATH`.
The action is TypeScript, bundled into a single JavaScript file which GitHub
runs directly from this repository.

## Layout

src/run.ts the action's implementation
__tests__/ jest tests
dist/index.js the bundle GitHub actually runs; generated, committed
action.cue the action definition; generates action.yml
workflows.cue the CI workflow definition; generates .github/workflows/
*_tool.cue the cue commands which write the generated files

`dist/index.js`, `action.yml` and `.github/workflows/*.yml` are all generated.
Never edit them by hand; change the source and re-run the generator below.

## Developing

npm ci
npm test
npm run dist # regenerate dist/index.js
cue cmd genaction # regenerate action.yml from action.cue
cue cmd genworkflows # regenerate .github/workflows from workflows.cue

CI runs all of the above and then fails if the tree is dirty, so any commit
touching `src/` or a `.cue` file must include its regenerated output.

Inputs and outputs are declared in `action.cue` and consumed by name in
`src/run.ts`; nothing enforces that the two agree at build time, so a test
reads the names back out of `action.yml`. Keep it that way.

## Versioning

Follow semver, and bump the major version whenever a workflow which worked on
the previous tag might stop working:

* raising the node runtime in `action.cue`, since it requires a newer Actions
Runner than some self-hosted and Enterprise Server installations have
* renaming or removing an input or output
* dropping support for a CUE version or platform

Each major version has a moving tag, `v1` and `v2`, pointing at the newest
release of that major. Users are expected to reference those rather than exact
tags. `v1` is pinned to v1.0.1 and runs on node20, which runners no longer
provide as of 2026-09-23; it is kept only so existing references resolve.

## Releasing

1. Check CI is green on `main`.
2. Update the README's `uses:` line and `package.json`'s version.
3. Tag the release and move the major tag:

git tag -a vX.Y.Z -m vX.Y.Z && git push origin vX.Y.Z
git tag -f vX vX.Y.Z && git push -f origin vX

4. Publish a GitHub release whose notes lead with anything breaking, naming
the runner version required if the node runtime changed.

Issues and discussions live in the main cue-lang/cue repository, not here.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ the latest release of `cue`. Releases and pre-releases of `cue` are listed
[here](https://github.com/cue-lang/cue/releases).

```
- uses: cue-lang/setup-cue@v1.0.0
- uses: cue-lang/setup-cue@v2
with:
version: '<version>' # default is latest
id: install
```

This action runs on Node 24, which requires Actions Runner v2.327.1 or later.
GitHub-hosted runners are new enough; self-hosted runners and GitHub Enterprise
Server installations may need updating.

The input and output schemas are best described using CUE itself:

```cue
Expand All @@ -27,15 +31,15 @@ The input and output schemas are best described using CUE itself:

#outputs: {
// Path to the cached CUE binary
"cuectl-path": string
"cue-path": string
}
```

Please refer to [`action.yml`](action.yml) for more details.

The cached `cue` binary path is prepended to the `PATH` environment variable and
can be executed directly in later workflow steps. It is also stored in the
`cuectl-path` output variable.
`cue-path` output variable.

## Issues/Discussions

Expand Down
9 changes: 8 additions & 1 deletion __tests__/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import * as path from 'path';
import * as core from '@actions/core';
import * as util from 'util';

// action.yml declares the outputs available to workflows, so run() must set
// exactly those names. Read it here, before any test mocks out fs.
const declaredOutputs = [...fs.readFileSync(path.join(__dirname, '..', 'action.yml'), 'utf8')
.match(/^outputs:\n(?:[ ].*\n)*/m)![0]
.matchAll(/^ ([\w-]+):$/gm)].map(m => m[1]);

describe('Testing all functions in run file.', () => {
test('run() must download specified cuectl version and set output', async () => {
jest.spyOn(core, 'getInput').mockReturnValue('v0.4.0');
Expand All @@ -33,7 +39,8 @@ describe('Testing all functions in run file.', () => {
expect(await run.run()).toBeUndefined();
expect(core.getInput).toHaveBeenCalledWith('version', { 'required': true });
expect(core.addPath).toHaveBeenCalledWith('pathToCachedTool');
expect(core.setOutput).toHaveBeenCalledWith('cuectl-path', path.join('pathToCachedTool', 'cue'));
expect(declaredOutputs).toEqual(['cue-path']);
expect(core.setOutput).toHaveBeenCalledWith('cue-path', path.join('pathToCachedTool', 'cue'));
});

test('getExecutableExtension() must return .exe file extension when os equals Windows', () => {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34118,7 +34118,7 @@ function run() {
let cachedCuectlPath = yield downloadCuectl(version);
core.addPath(path.dirname(cachedCuectlPath));
console.log(`CUE binary version: '${version}' has been cached at ${cachedCuectlPath}`);
core.setOutput('cuectl-path', cachedCuectlPath);
core.setOutput('cue-path', cachedCuectlPath);
});
}
if (require.main === require.cache[eval('__filename')]) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-cue",
"version": "0.0.0",
"version": "2.0.0",
"description": "Install CUE on your runner using Github Actions",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export async function run() {
core.addPath(path.dirname(cachedCuectlPath));

console.log(`CUE binary version: '${version}' has been cached at ${cachedCuectlPath}`);
core.setOutput('cuectl-path', cachedCuectlPath);
core.setOutput('cue-path', cachedCuectlPath);
}


Expand Down
Loading