Skip to content

Commit

Permalink
feat: allow user to specify nix packages to be installed with `crosup…
Browse files Browse the repository at this point in the history
… install [packages]...`

update action example
  • Loading branch information
tsirysndr committed Jun 22, 2023
1 parent 666c7fe commit bedd825
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,13 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Crosup
uses: ./
with:
packages: |
deno
zig
- name: Verify Crosup
run: crosup --version
- name: Verify Node
run: deno --version
- name: Verify Zig
run: zig version
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
- name: Setup Crosup
uses: tsirysndr/setup-crosup@v1
with:
version: 'v0.3.2'
version: 'v0.4.0'
packages: |
deno
zig
- name: Verify Crosup
run: crosup --version
```
Expand Down
15 changes: 14 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@ inputs:
version:
description: Crosup version to install
required: false
default: v0.3.2
default: v0.4.0
packages:
description: |
Whitespace separated, pkgs to supplement the environment. eg.
```yaml
+: |
deno
zig
```
By default tea reads your developer environment and adds those packages.
Specifying additional packages here is a way to augment that.
required: false
outputs:
version:
description: Crosup version installed
Expand Down
4 changes: 4 additions & 0 deletions dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ if (!process.env.RUNNER_TEMP) {
}
setup({
version: action.getInput("version"),
packages: action
.getInput("packages")
.split("\n")
.map((packageName) => packageName.trim()),
})
.then(({ version, cacheHit }) => {
action.setOutput("version", version);
Expand Down
6 changes: 5 additions & 1 deletion dist/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ export default async (options) => {
action.warning(`Failed to save the downloaded version of Crosup to the cache: ${error.message}`);
}
}
if (options.packages.length > 0) {
action.info(`Installing packages: ${options.packages.join(", ")}`);
await getExecOutput(path, ["install", ...options.packages]);
}
return {
version,
cacheHit,
};
};
function getDownloadUrl(options) {
const release = encodeURIComponent(options?.version ?? "v0.3.2");
const release = encodeURIComponent(options?.version ?? "v0.4.0");
const platform = {
darwin: "apple-darwin",
linux: "unknown-linux-gnu",
Expand Down
4 changes: 4 additions & 0 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ if (!process.env.RUNNER_TEMP) {

setup({
version: action.getInput("version"),
packages: action
.getInput("packages")
.split("\n")
.map((packageName) => packageName.trim()),
})
.then(({ version, cacheHit }) => {
action.setOutput("version", version);
Expand Down
7 changes: 6 additions & 1 deletion src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export default async (
}
}

if (options.packages.length > 0) {
action.info(`Installing packages: ${options.packages.join(", ")}`);
await getExecOutput(path, ["install", ...options.packages]);
}

return {
version,
cacheHit,
Expand All @@ -75,7 +80,7 @@ function getDownloadUrl(options?: {
os?: string;
arch?: string;
}): { url: string; cacheKey: string } {
const release = encodeURIComponent(options?.version ?? "v0.3.2");
const release = encodeURIComponent(options?.version ?? "v0.4.0");
const platform = {
darwin: "apple-darwin",
linux: "unknown-linux-gnu",
Expand Down

0 comments on commit bedd825

Please sign in to comment.