Skip to content

Commit 00d6355

Browse files
committed
Initial commit
0 parents  commit 00d6355

185 files changed

Lines changed: 13056 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Setup AppPack CLI
3+
4+
on: [push]
5+
6+
jobs:
7+
setup-apppack:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
13+
- name: Setup AppPack CLI
14+
id: setup-apppack-cli
15+
uses: ./
16+
17+
- name: Run AppPack
18+
run: |
19+
apppack version
20+
test "$(apppack version)" = "${{ steps.setup-apppack-cli.outputs.version }}"

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 16.19.1

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
MIT License
2+
-----------
3+
4+
Copyright (c) 2021 Lincoln Loop (https://lincolnloop.com)
5+
Permission is hereby granted, free of charge, to any person
6+
obtaining a copy of this software and associated documentation
7+
files (the "Software"), to deal in the Software without
8+
restriction, including without limitation the rights to use,
9+
copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following
12+
conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24+
OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Setup AppPack CLI GitHub Action
2+
3+
This action downloads the [AppPack](https://apppack.io) CLI from the [GitHub releases page](https://github.com/apppackio/apppack/releases).
4+
5+
## Inputs
6+
7+
### `version`
8+
9+
**Optional** Defaults to `latest`
10+
11+
## Outputs
12+
13+
### `version`
14+
15+
The version of the CLI that was setup
16+
17+
## Example usage
18+
19+
```yaml
20+
- name: AppPack CLI
21+
uses: apppackio/setup-apppack-cli@v1
22+
```

action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Setup AppPack CLI
2+
description: Downloads the latest release of the AppPack CLI tool from the apppackio/apppack repository.
3+
author: Peter Baumgartner
4+
5+
inputs:
6+
version:
7+
description: The version of the AppPack CLI to download. If not specified, the latest release will be downloaded.
8+
required: false
9+
default: ''
10+
outputs:
11+
version:
12+
description: The version of the AppPack CLI that was downloaded.
13+
14+
runs:
15+
using: 'node16'
16+
main: 'index.js'

index.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
const core = require("@actions/core");
2+
const tc = require("@actions/tool-cache");
3+
const https = require("https");
4+
const { join } = require("path");
5+
6+
async function run() {
7+
try {
8+
// Get the version input or the latest release
9+
let version = core.getInput("version") || "latest";
10+
11+
// Get the download URL for the release
12+
const releaseUrl = `https://api.github.com/repos/apppackio/apppack/releases/${version}`;
13+
const data = await downloadJson(releaseUrl);
14+
// strip the leading "v" from the tag name
15+
version = data.tag_name.slice(1);
16+
// Determine the platform-specific asset name
17+
const arch = process.arch === "x64" ? "x86_64" : process.arch;
18+
const platform =
19+
process.platform.charAt(0).toUpperCase() +
20+
process.platform.slice(1) +
21+
"_" +
22+
arch;
23+
const assetName = `apppack_${version}_${platform}.tar.gz`;
24+
const asset = data.assets.find((a) => a.name === assetName);
25+
26+
if (!asset) {
27+
throw new Error(
28+
`Could not find AppPack CLI asset in release ${data.tag_name}`
29+
);
30+
}
31+
32+
// Download and cache the AppPack CLI tool
33+
const downloadUrl = asset.browser_download_url;
34+
const pathToTarball = await tc.downloadTool(downloadUrl);
35+
const tmpDir = process.env.RUNNER_TEMP || os.tmpdir();
36+
const pathToCLI = await tc.extractTar(pathToTarball, tmpDir);
37+
38+
// Cache the downloaded tool
39+
const toolPath = await tc.cacheFile(
40+
join(pathToCLI, "apppack"),
41+
"apppack",
42+
"apppack",
43+
data.tag_name
44+
);
45+
46+
// Add the AppPack CLI directory to the PATH
47+
core.addPath(toolPath);
48+
// Set the version output
49+
core.setOutput("version", version);
50+
} catch (error) {
51+
core.setFailed(error.message);
52+
}
53+
}
54+
55+
// Download a JSON file from a URL
56+
async function downloadJson(url) {
57+
return new Promise((resolve, reject) => {
58+
const req = https.get(
59+
url,
60+
{ headers: { "User-Agent": "apppackio/setup-apppack" } },
61+
(res) => {
62+
let data = "";
63+
res.on("data", (chunk) => (data += chunk));
64+
res.on("end", () => resolve(JSON.parse(data)));
65+
}
66+
);
67+
req.on("error", reject);
68+
});
69+
}
70+
71+
run();

node_modules/.bin/semver

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.package-lock.json

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/LICENSE.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)