Imported AI generated TypeScript action skeleton.

This commit is contained in:
2026-01-10 22:04:18 +01:00
commit e7d0039424
7 changed files with 291 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
node_modules/
dist/
lib/
*.log
.DS_Store
Notes.md

19
README.md Normal file
View File

@@ -0,0 +1,19 @@
# Setup Tool Action
This GitHub/Gitea Action downloads a tool from a specified URL and adds it to the system PATH.
## Usage
```yaml
- uses: ./
with:
tool-url: 'https://example.com/tool.tar.gz'
tool-name: 'mytool'
version: '1.0.0'
```
## Developing
1. Install dependencies: `npm install`
2. Build the action: `npm run build`
3. Test locally: (add tests if needed)

17
action.yml Normal file
View File

@@ -0,0 +1,17 @@
name: 'Setup Tool'
description: 'Download and setup a tool'
author: 'GitHub Copilot'
inputs:
tool-url:
description: 'The URL of the tool to download'
required: true
tool-name:
description: 'The name of the tool'
required: true
version:
description: 'The version of the tool'
required: false
default: 'latest'
runs:
using: 'node24'
main: 'dist/index.js'

153
package-lock.json generated Normal file
View File

@@ -0,0 +1,153 @@
{
"name": "setup-github-release",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "setup-github-release",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.11.0",
"@actions/tool-cache": "^2.0.2"
},
"devDependencies": {
"@types/node": "^25.0.0",
"@vercel/ncc": "^0.38.4",
"typescript": "^5.9.0"
},
"engines": {
"node": ">=24"
}
},
"node_modules/@actions/core": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz",
"integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==",
"license": "MIT",
"dependencies": {
"@actions/exec": "^1.1.1",
"@actions/http-client": "^2.0.1"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"license": "MIT",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/http-client": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.3.tgz",
"integrity": "sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==",
"license": "MIT",
"dependencies": {
"tunnel": "^0.0.6",
"undici": "^5.25.4"
}
},
"node_modules/@actions/io": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==",
"license": "MIT"
},
"node_modules/@actions/tool-cache": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz",
"integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/exec": "^1.0.0",
"@actions/http-client": "^2.0.1",
"@actions/io": "^1.1.1",
"semver": "^6.1.0"
}
},
"node_modules/@fastify/busboy": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
"license": "MIT",
"engines": {
"node": ">=14"
}
},
"node_modules/@types/node": {
"version": "25.0.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.6.tgz",
"integrity": "sha512-NNu0sjyNxpoiW3YuVFfNz7mxSQ+S4X2G28uqg2s+CzoqoQjLPsWSbsFFyztIAqt2vb8kfEAsJNepMGPTxFDx3Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~7.16.0"
}
},
"node_modules/@vercel/ncc": {
"version": "0.38.4",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.4.tgz",
"integrity": "sha512-8LwjnlP39s08C08J5NstzriPvW1SP8Zfpp1BvC2sI35kPeZnHfxVkCwu4/+Wodgnd60UtT1n8K8zw+Mp7J9JmQ==",
"dev": true,
"license": "MIT",
"bin": {
"ncc": "dist/ncc/cli.js"
}
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"license": "MIT",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz",
"integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==",
"license": "MIT",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
"engines": {
"node": ">=14.0"
}
},
"node_modules/undici-types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
"dev": true,
"license": "MIT"
}
}
}

34
package.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "setup-github-release",
"version": "1.0.0",
"description": "A GitHub Action to download a tool",
"main": "dist/index.js",
"scripts": {
"build": "ncc build src/index.ts -o dist --source-map --license res.txt",
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'",
"lint": "eslint src/**/*.ts",
"package": "ncc build src/index.ts -o dist --source-map --license res.txt",
"test": "jest",
"all": "npm run format && npm run lint && npm run test && npm run package"
},
"keywords": [
"actions",
"node",
"setup"
],
"author": "",
"license": "MIT",
"engines": {
"node": ">=24"
},
"dependencies": {
"@actions/core": "^1.11.0",
"@actions/tool-cache": "^2.0.2"
},
"devDependencies": {
"@types/node": "^25.0.0",
"@vercel/ncc": "^0.38.4",
"typescript": "^5.9.0"
}
}

49
src/index.ts Normal file
View File

@@ -0,0 +1,49 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import * as path from 'path';
async function run() {
try {
const toolUrl = core.getInput('tool-url', { required: true });
const toolName = core.getInput('tool-name', { required: true });
const version = core.getInput('version') || 'latest';
core.info(`Downloading ${toolName} from ${toolUrl}...`);
// Download the tool
const downloadPath = await tc.downloadTool(toolUrl);
core.info(`Downloaded to ${downloadPath}`);
// If it's an archive, we might need to extract it.
// For simplicity, let's assume it's just a binary for now,
// or we can add extraction logic if the URL ends in .tar.gz, .zip etc.
let toolDir: string;
if (toolUrl.endsWith('.tar.gz')) {
toolDir = await tc.extractTar(downloadPath);
} else if (toolUrl.endsWith('.zip')) {
toolDir = await tc.extractZip(downloadPath);
} else {
// Treat as a direct binary download
// We might need to make it executable and put it in a directory
toolDir = path.dirname(downloadPath);
// Optional: rename if needed, but downloadTool usually gives a random name
}
core.info(`Tool extracted/located at ${toolDir}`);
// Add to path
core.addPath(toolDir);
core.info(`Added ${toolDir} to PATH`);
// In a real scenario, we'd use tc.cacheDir to cache it for future runs
// cachedPath = await tc.cacheDir(toolDir, toolName, version);
// core.addPath(cachedPath);
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
}
}
}
run();

13
tsconfig.json Normal file
View File

@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"outDir": "lib",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"rootDir": "src"
},
"include": ["src/**/*"]
}