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
5 changes: 5 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
inheritance: true
reviews:
auto_approvals:
enabled: true
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-node@v6
with:
node-version-file: package.json
node-version: "24"
cache: yarn

- name: Install Dependencies
Expand Down
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,47 @@ steps:
atmos-version: 0.15.0
````
After checkout, setup reads the first version listed for `atmos` or `cloudposse/atmos` in the workspace’s `.tool-versions`.
If the file or Atmos entry is absent, setup uses `latest`. Set `atmos-version-file` to select another file, such as `.atmos-version`.

```yaml
steps:
- uses: actions/checkout@v4
- name: Setup atmos
uses: cloudposse/github-action-setup-atmos@v3
with:
install-toolchain: true
```

Set `install-toolchain: true` to run `atmos toolchain install` after setup. This option defaults to `false` and works independently of `atmos-version-file`.

When both `atmos-version` and `atmos-version-file` are set, `atmos-version` takes precedence.

To select a job container from `.tool-versions`, resolve the image in a preceding job.
Setting `install: false` skips both Atmos and toolchain installation.

```yaml
jobs:
setup:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.atmos.outputs.atmos-image }}
steps:
- uses: actions/checkout@v6
- id: atmos
uses: cloudposse/github-action-setup-atmos@v3
with:
install: false
plan:
needs: setup
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
steps:
- run: atmos version
```

The wrapper script installation can be skipped by setting the `install-wrapper` input to `false`:

```yaml
Expand Down Expand Up @@ -117,8 +158,11 @@ steps:
<!-- markdownlint-disable -->
| Name | Description | Default | Required |
|------|-------------|---------|----------|
| atmos-version | Version Spec of the version to use. Examples: 1.x, 10.15.1, >=10.15.0. | latest | false |
| atmos-version | Version Spec of the version to use. Defaults to the workspace .tool-versions pin, then latest. Examples: 1.x, 10.15.1, >=10.15.0. | | false |
| atmos-version-file | Optional override for the automatically discovered workspace .tool-versions file. Supports the asdf/mise `.tool-versions` format (the first version listed for `atmos` or `cloudposse/atmos`) and a plain version file whose contents are the version (e.g. `.atmos-version`). When both `atmos-version` and `atmos-version-file` are set, `atmos-version` takes precedence. | | false |
| checksum-validation | Controls SHA256SUMS validation. Use `warn` to validate when checksums are published and warn when they are missing, `enforce` to fail when checksums are missing, or `skip` to disable checksum validation. Checksum mismatches always fail when validation runs. | warn | false |
| install | Install Atmos on the runner. Set to false to return the version and container image and skip all installation. | true | false |
| install-toolchain | Run `atmos toolchain install` after setting up Atmos to install tools declared in the repository’s `.tool-versions` file. | false | false |
| install-wrapper | Flag to indicate if the wrapper script will be installed to wrap subsequent calls of the `atmos` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`. | true | false |
| token | Used to pull atmos distributions from Cloud Posse's GitHub repository. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. | ${{ github.server\_url == 'https://github.com' && github.token \|\| '' }} | false |
<!-- markdownlint-restore -->
Expand All @@ -128,7 +172,8 @@ steps:
<!-- markdownlint-disable -->
| Name | Description |
|------|-------------|
| atmos-version | The installed atmos version. |
| atmos-image | The official Atmos container image reference for the resolved version. |
| atmos-version | The resolved Atmos release version. |
<!-- markdownlint-restore -->


Expand Down
41 changes: 41 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,47 @@ usage: |-
atmos-version: 0.15.0
````
After checkout, setup reads the first version listed for `atmos` or `cloudposse/atmos` in the workspace’s `.tool-versions`.
If the file or Atmos entry is absent, setup uses `latest`. Set `atmos-version-file` to select another file, such as `.atmos-version`.
```yaml
steps:
- uses: actions/checkout@v4
- name: Setup atmos
uses: cloudposse/github-action-setup-atmos@v3
with:
install-toolchain: true
```
Set `install-toolchain: true` to run `atmos toolchain install` after setup. This option defaults to `false` and works independently of `atmos-version-file`.
When both `atmos-version` and `atmos-version-file` are set, `atmos-version` takes precedence.
To select a job container from `.tool-versions`, resolve the image in a preceding job.
Setting `install: false` skips both Atmos and toolchain installation.
```yaml
jobs:
setup:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.atmos.outputs.atmos-image }}
steps:
- uses: actions/checkout@v6
- id: atmos
uses: cloudposse/github-action-setup-atmos@v3
with:
install: false
plan:
needs: setup
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.image }}
steps:
- run: atmos version
```
The wrapper script installation can be skipped by setting the `install-wrapper` input to `false`:
```yaml
Expand Down
20 changes: 17 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ branding:
color: "blue"
inputs:
atmos-version:
description: "Version Spec of the version to use. Examples: 1.x, 10.15.1, >=10.15.0."
default: "latest"
description: "Version Spec of the version to use. Defaults to the workspace .tool-versions pin, then latest. Examples: 1.x, 10.15.1, >=10.15.0."
atmos-version-file:
description:
Optional override for the automatically discovered workspace .tool-versions file. Supports the asdf/mise `.tool-versions` format (the first
version listed for `atmos` or `cloudposse/atmos`) and a plain version file whose contents are the version (e.g. `.atmos-version`). When both
`atmos-version` and `atmos-version-file` are set, `atmos-version` takes precedence.
required: false
install:
description: "Install Atmos on the runner. Set to false to return the version and container image and skip all installation."
default: "true"
install-toolchain:
description: "Run `atmos toolchain install` after setting up Atmos to install tools declared in the repository’s `.tool-versions` file."
required: false
default: "false"
install-wrapper:
description:
Flag to indicate if the wrapper script will be installed to wrap subsequent calls of the `atmos` binary and expose
Expand All @@ -29,8 +41,10 @@ inputs:
GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
outputs:
atmos-image:
description: "The official Atmos container image reference for the resolved version."
atmos-version:
description: "The installed atmos version."
description: "The resolved Atmos release version."
runs:
using: "node24"
main: "dist/index.js"
130 changes: 110 additions & 20 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49015,25 +49015,19 @@ var __webpack_exports__ = {};
// ESM COMPAT FLAG
__nccwpck_require__.r(__webpack_exports__);

// EXTERNAL MODULE: external "os"
var external_os_ = __nccwpck_require__(2037);
var external_os_default = /*#__PURE__*/__nccwpck_require__.n(external_os_);
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
var core = __nccwpck_require__(2186);
// EXTERNAL MODULE: external "crypto"
var external_crypto_ = __nccwpck_require__(6113);
var external_crypto_default = /*#__PURE__*/__nccwpck_require__.n(external_crypto_);
// EXTERNAL MODULE: external "child_process"
var external_child_process_ = __nccwpck_require__(2081);
// EXTERNAL MODULE: external "fs"
var external_fs_ = __nccwpck_require__(7147);
var external_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_fs_);
// EXTERNAL MODULE: external "os"
var external_os_ = __nccwpck_require__(2037);
var external_os_default = /*#__PURE__*/__nccwpck_require__.n(external_os_);
// EXTERNAL MODULE: external "path"
var external_path_ = __nccwpck_require__(1017);
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
var io = __nccwpck_require__(7436);
// EXTERNAL MODULE: ./node_modules/@actions/tool-cache/lib/tool-cache.js
var tool_cache = __nccwpck_require__(7784);
// EXTERNAL MODULE: ./node_modules/octokit/dist-node/index.js
var dist_node = __nccwpck_require__(7467);
var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_);
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
var core = __nccwpck_require__(2186);
// EXTERNAL MODULE: ./node_modules/semver/index.js
var semver = __nccwpck_require__(1383);
;// CONCATENATED MODULE: ./src/system.ts
Expand Down Expand Up @@ -49068,6 +49062,15 @@ const getAtmosBinaryName = (wrapped = false) => {
const getAtmosWrappedBinaryName = () => getAtmosBinaryName(true);
const getAtmosWrappedPath = () => [process.env.ATMOS_CLI_PATH, getAtmosWrappedBinaryName()].join(sep);

// EXTERNAL MODULE: external "crypto"
var external_crypto_ = __nccwpck_require__(6113);
var external_crypto_default = /*#__PURE__*/__nccwpck_require__.n(external_crypto_);
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
var io = __nccwpck_require__(7436);
// EXTERNAL MODULE: ./node_modules/@actions/tool-cache/lib/tool-cache.js
var tool_cache = __nccwpck_require__(7784);
// EXTERNAL MODULE: ./node_modules/octokit/dist-node/index.js
var dist_node = __nccwpck_require__(7467);
;// CONCATENATED MODULE: ./src/installer.ts


Expand Down Expand Up @@ -49357,6 +49360,13 @@ const installAtmosVersion = async (info, auth, arch, installWrapper, checksumVal
core.info(`Successfully installed atmos to ${atmosInstallPath}`);
return atmosInstallPath;
};
const resolveAtmosVersion = async (versionSpec, auth, arch) => {
const info = await getMatchingVersion(versionSpec, auth, arch);
if (!info) {
throw new Error(`Unable to find atmos version '${versionSpec}' for platform ${external_os_default().platform()} and architecture ${arch}.`);
}
return info;
};
const getAtmos = async (versionSpec, auth, arch = external_os_default().arch(), installWrapper, checksumValidation = "warn") => {
const osPlat = external_os_default().platform();
const toolCacheName = getToolCacheName(installWrapper);
Expand All @@ -49376,10 +49386,7 @@ const getAtmos = async (versionSpec, auth, arch = external_os_default().arch(),
});
}
}
const info = await getMatchingVersion(versionSpec, auth, arch);
if (!info) {
throw new Error(`Unable to find atmos version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`);
}
const info = await resolveAtmosVersion(versionSpec, auth, arch);
const { resolvedVersion } = info;
const cachedPath = tool_cache.find(toolCacheName, resolvedVersion, arch);
if (cachedPath) {
Expand All @@ -49401,18 +49408,101 @@ const getAtmos = async (versionSpec, auth, arch = external_os_default().arch(),








// Parses `.tool-versions` content (asdf/mise format) and returns the atmos
// version, or an empty string when none is declared. Lines look like
// `atmos 1.15.0`; comments (`#`) and blank lines are ignored.
const parseToolVersions = (content) => {
for (const line of content.split(/\r?\n/)) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith("#")) {
continue;
}
const [tool, version] = trimmed.split("#", 1)[0].trim().split(/\s+/);
if ((tool === "atmos" || tool === "cloudposse/atmos") && version) {
return version;
}
}
return "";
};
// Returns the first non-empty, non-comment line of a plain version file
// (e.g. `.atmos-version`), or an empty string when there is none.
const parsePlainVersion = (content) => {
for (const line of content.split(/\r?\n/)) {
const trimmed = line.trim();
if (trimmed && !trimmed.startsWith("#")) {
return trimmed === "latest" || semver.validRange(trimmed) ? trimmed : "";
}
}
return "";
};
// Reads an atmos version from a version file. Supports the asdf/mise
// `.tool-versions` format (an `atmos <version>` line) and a plain version file
// whose contents are the version string (e.g. `.atmos-version`).
const getVersionFromFile = (filePath, required = true) => {
let content;
try {
content = external_fs_default().readFileSync(filePath, "utf8");
}
catch (error) {
if (error.code === "ENOENT") {
if (!required)
return "";
throw new Error(`The atmos-version-file '${filePath}' does not exist`);
}
throw error;
}
let version = parseToolVersions(content);
if (!version && external_path_default().basename(filePath) !== ".tool-versions") {
version = parsePlainVersion(content);
}
if (!version && required) {
throw new Error(`No atmos version found in '${filePath}'`);
}
return version;
};
const setVersionOutputs = (version) => {
core.setOutput("atmos-version", version);
core.setOutput("atmos-image", `ghcr.io/cloudposse/atmos:${version.replace(/^v/, "")}`);
};
const run = async () => {
try {
const versionSpec = core.getInput("atmos-version");
let versionSpec = core.getInput("atmos-version");
const versionFile = core.getInput("atmos-version-file");
if (versionSpec && versionFile) {
core.warning("Both 'atmos-version' and 'atmos-version-file' inputs are specified, only 'atmos-version' will be used.");
}
if (!versionSpec) {
const file = versionFile || external_path_default().resolve(process.env.GITHUB_WORKSPACE || ".", ".tool-versions");
versionSpec = getVersionFromFile(file, Boolean(versionFile));
if (versionSpec)
core.info(`Resolved atmos version '${versionSpec}' from '${file}'`);
}
versionSpec ||= "latest";
core.info(`Setup atmos version spec ${versionSpec}`);
const arch = core.getInput("architecture") || external_os_default().arch();
const installWrapper = core.getInput("install-wrapper") === "true";
const checksumValidation = parseChecksumValidationMode(core.getInput("checksum-validation"));
const token = core.getInput("token");
const auth = !token ? undefined : `token ${token}`;
if (!core.getBooleanInput("install")) {
const info = await resolveAtmosVersion(versionSpec, auth, arch);
setVersionOutputs(info.resolvedVersion);
return;
}
const { toolPath, info } = await getAtmos(versionSpec, auth, arch, installWrapper, checksumValidation);
core.info(`Successfully set up Atmos version ${versionSpec} in ${toolPath}`);
core.setOutput("atmos-version", info?.resolvedVersion);
if (core.getBooleanInput("install-toolchain")) {
core.info("Running atmos toolchain install");
(0,external_child_process_.execFileSync)(external_path_default().join(toolPath, getAtmosBinaryName(installWrapper)), ["toolchain", "install"], {
stdio: "inherit"
});
}
setVersionOutputs(info.resolvedVersion);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}
catch (error) {
Expand Down
Loading
Loading