Skip to content

Commit 626829e

Browse files
committed
use bash
1 parent eb2ce7a commit 626829e

File tree

7 files changed

+115
-861
lines changed

7 files changed

+115
-861
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
os: [ubuntu-24.04, windows-latest, macos-14, macos-13]
22+
os: [ubuntu-latest, windows-latest, macos-latest]
2323
runs-on: ${{ matrix.os }}
2424
steps:
2525
- uses: actions/checkout@v3
@@ -38,10 +38,6 @@ jobs:
3838
uses: ./
3939
with:
4040
url: https://github.com/denoland/deno
41-
- name: setup ei
42-
uses: ./
43-
with:
44-
url: https://github.com/ahaoboy/easy-install
4541
- name: setup qjs-ng
4642
uses: ./
4743
with:
@@ -80,7 +76,7 @@ jobs:
8076
qjs ./test.js
8177
mujs ./test.js
8278
83-
ls -lh ~/.easy-install
79+
ls -lh ~/.ei
8480
8581
which llrt
8682
which fnm
@@ -92,7 +88,6 @@ jobs:
9288
uses: ./
9389
with:
9490
url: |-
95-
https://github.com/ahaoboy/easy-install
9691
https://github.com/ahaoboy/easy-install/raw/refs/heads/main/dist-manifest/node.json
9792
https://github.com/ahaoboy/easy-install/raw/refs/heads/main/dist-manifest/bun.json
9893
https://github.com/ahaoboy/easy-install/raw/refs/heads/main/dist-manifest/boa.json
@@ -108,4 +103,3 @@ jobs:
108103
https://github.com/ahaoboy/jerryscript-build
109104
https://github.com/ahaoboy/mujs-build
110105
https://github.com/ahaoboy/mujs-one
111-
https://github.com/ahaoboy/easy-install/raw/refs/heads/main/dist-manifest/graaljs.json

action.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
get_input() {
4+
local name="$1"
5+
local required="${2:-false}"
6+
local trim_whitespace="${3:-true}"
7+
local var_name="INPUT_$(echo "$name" | tr '[:lower:]' '[:upper:]' | tr ' ' '_')"
8+
local val="${!var_name:-}"
9+
10+
if [[ "$required" == "true" && -z "$val" ]]; then
11+
echo "Error: Input required and not supplied: $name" >&2
12+
exit 1
13+
fi
14+
15+
if [[ "$trim_whitespace" == "true" ]]; then
16+
val="$(echo "$val" | xargs)"
17+
fi
18+
19+
echo "$val"
20+
}
21+
22+
get_multiline_input() {
23+
local name="$1"
24+
local val
25+
val="$(get_input "$name")"
26+
echo "$val" | tr ',' '\n' | sed '/^[[:space:]]*$/d'
27+
}
28+
29+
main() {
30+
local urls
31+
urls=($(get_multiline_input "url"))
32+
33+
for url in "${urls[@]}"; do
34+
echo "→ Running: ei $url"
35+
ei "$url"
36+
done
37+
}
38+
39+
main "$@"

action.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ inputs:
88
url:
99
description: 'The url to install'
1010
required: true
11-
version:
12-
description: 'The version of easy-setup to install. (e.g. "latest", "0.1.4")'
13-
required: false
14-
name:
15-
description: 'The binary name'
16-
required: false
17-
outputs:
18-
version:
19-
description: The version of easy-setup that was installed.
20-
install-dir:
21-
description: The dir to the easy-setup executable.
22-
download-url:
23-
description: The URL from which easy-setup was downloaded.
2411

2512
runs:
26-
using: 'node20'
27-
main: 'bundle/action.js'
13+
using: "composite"
14+
steps:
15+
- name: Run installer
16+
shell: bash
17+
run: |
18+
curl -fsSL https://raw.githubusercontent.com/easy-install/easy-install/main/install.sh | bash
19+
20+
- name: Run installer
21+
shell: bash
22+
run: |
23+
bash "${{ github.action_path }}/action.sh"
24+
env:
25+
INPUT_URL: ${{ inputs.url }}

bundle/action.js

Lines changed: 0 additions & 833 deletions
This file was deleted.

readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Download, install, and setup in GitHub Actions.
88
- uses: easy-install/easy-setup@v1
99
with:
1010
url: https://github.com/denoland/deno
11-
version: latest
1211
env:
1312
# need for https://api.github.com/repos/denoland/deno/releases/latest
1413
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/action.ts

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,75 @@
11
// FIXME: https://github.com/actions/toolkit/issues/1959
22
// import { getMultilineInput } from '@actions/core'
3-
import { getMultilineInput } from './tool'
3+
4+
/**
5+
* Interface for getInput options
6+
*/
7+
export interface InputOptions {
8+
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
9+
required?: boolean
10+
11+
/** Optional. Whether leading/trailing whitespace will be trimmed for the input. Defaults to true */
12+
trimWhitespace?: boolean
13+
}
14+
/**
15+
* Gets the value of an input.
16+
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
17+
* Returns an empty string if the value is not defined.
18+
*
19+
* @param name name of the input to get
20+
* @param options optional. See InputOptions.
21+
* @returns string
22+
*/
23+
export function getInput(name: string, options?: InputOptions): string {
24+
const val: string =
25+
process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''
26+
if (options && options.required && !val) {
27+
throw new Error(`Input required and not supplied: ${name}`)
28+
}
29+
30+
if (options && options.trimWhitespace === false) {
31+
return val
32+
}
33+
34+
return val.trim()
35+
}
36+
/**
37+
* Gets the values of an multiline input. Each value is also trimmed.
38+
*
39+
* @param name name of the input to get
40+
* @param options optional. See InputOptions.
41+
* @returns string[]
42+
*/
43+
44+
export function getMultilineInput(
45+
name: string,
46+
options?: InputOptions,
47+
): string[] {
48+
const inputs: string[] = getInput(name, options)
49+
.replaceAll(",", "\n")
50+
.split('\n')
51+
.filter((x) => x !== '')
52+
53+
if (options && options.trimWhitespace === false) {
54+
return inputs
55+
}
56+
57+
return inputs.map((input) => input.trim())
58+
}
59+
60+
461
import { install } from '@easy-install/easy-install'
562
import { version } from '../package.json'
63+
import { exec } from 'child_process'
664

765
const urlList = getMultilineInput('url')
8-
const nameList = getMultilineInput('name')
966

1067
async function main() {
1168
console.log(`easy-setup: ${version}`)
1269
console.log(`nodejs: ${process.version}`);
1370
for (let i = 0; i < urlList.length; i++) {
1471
const url = urlList[i]
15-
const name = nameList[i]
16-
await install(url, name)
72+
exec(`ei ${url}`, )
1773
}
1874
}
1975

src/tool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function getMultilineInput(
4343
options?: InputOptions,
4444
): string[] {
4545
const inputs: string[] = getInput(name, options)
46+
.replaceAll(",", "\n")
4647
.split('\n')
4748
.filter((x) => x !== '')
4849

0 commit comments

Comments
 (0)