Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27a94d6f80 | ||
|
|
b0a04f5fb3 | ||
|
|
ddba6331f8 | ||
|
|
99221c1ae0 | ||
|
|
13923243f4 | ||
|
|
a9318b00d5 | ||
|
|
bf40fde936 | ||
|
|
92c5bc2cef | ||
|
|
37397a08ec | ||
|
|
a0f9c413e5 | ||
|
|
d744239ce1 | ||
|
|
bfac95679f | ||
|
|
640630d09e | ||
|
|
70b6cfe9d1 | ||
|
|
933334b350 | ||
|
|
c52f1f18be | ||
|
|
08cc23c06e | ||
|
|
baf23f03bc | ||
|
|
3868f53a52 | ||
|
|
627e67fd7b | ||
|
|
62d40e4bee | ||
|
|
e838800258 | ||
|
|
37657f4f9f | ||
|
|
633e7abe1e | ||
|
|
4e76ddea17 | ||
|
|
5a78c10e01 | ||
|
|
6dae544af4 | ||
|
|
054bb2f631 | ||
|
|
9f7c2a5c23 | ||
|
|
81ecfb54f4 |
33
.github/workflows/test.yml
vendored
33
.github/workflows/test.yml
vendored
@@ -14,16 +14,43 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
bun-version:
|
||||
["latest", "0.1.3"]
|
||||
["latest", "0.1.4"]
|
||||
misc-test-builds:
|
||||
[false]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Bun
|
||||
- name: Setup Bun - Test Builds * ${{ matrix.misc-test-builds }}
|
||||
uses: ./
|
||||
with:
|
||||
bun-version: ${{ matrix.bun-version }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
misc-test-builds: ${{ matrix.misc-test-builds }}
|
||||
|
||||
- name: Try bun
|
||||
run: bun --version
|
||||
run: |
|
||||
bun --version
|
||||
test-canary:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
bun-version:
|
||||
["canary"]
|
||||
misc-test-builds:
|
||||
[false]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Bun - Test Builds * ${{ matrix.misc-test-builds }}
|
||||
uses: ./
|
||||
with:
|
||||
bun-version: ${{ matrix.bun-version }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
misc-test-builds: ${{ matrix.misc-test-builds }}
|
||||
|
||||
- name: Try bun
|
||||
run: |
|
||||
bun --version
|
||||
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Jozef Steinhübl
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
17
README.md
17
README.md
@@ -8,15 +8,26 @@ Set up your GitHub Actions workflow with a specific version of Bun.
|
||||
### Latest stable
|
||||
|
||||
```yaml
|
||||
- uses: xhyrom/setup-bun@v0.1.2
|
||||
- uses: xhyrom/setup-bun@v0.1.6
|
||||
with:
|
||||
bun-version: latest
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Specific version
|
||||
|
||||
```yaml
|
||||
- uses: xhyrom/setup-bun@v0.1.2
|
||||
- uses: xhyrom/setup-bun@v0.1.6
|
||||
with:
|
||||
bun-version: "0.1.3"
|
||||
bun-version: "0.1.5"
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Canary builds
|
||||
|
||||
```yaml
|
||||
- uses: xhyrom/setup-bun@v0.1.6
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
@@ -12,6 +12,10 @@ inputs:
|
||||
default: "latest"
|
||||
github-token:
|
||||
description: "The github token secret can be passed in using {{ secrets.GITHUB_TOKEN }}"
|
||||
default: ${{ github.token }}
|
||||
misc-test-builds:
|
||||
description: "Install builds from https://github.com/oven-sh/misc-test-builds (not recommended!)"
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
bun-version:
|
||||
@@ -19,4 +23,4 @@ outputs:
|
||||
|
||||
runs:
|
||||
using: "node12"
|
||||
main: "dist/index.js"
|
||||
main: "dist/index.js"
|
||||
|
||||
18
dist/index.js
vendored
18
dist/index.js
vendored
@@ -1,19 +1,25 @@
|
||||
import { getInput, info, setFailed, setOutput } from '@actions/core';
|
||||
import { getInput, info, setFailed, setOutput, warning } from '@actions/core';
|
||||
import getGithubRelease from './utils/getGithubRelease.js';
|
||||
import install from './utils/install.js';
|
||||
const exit = (error) => {
|
||||
setFailed(error);
|
||||
process.exit();
|
||||
export const exit = (error, miscTestBuilds) => {
|
||||
if (miscTestBuilds) {
|
||||
warning(error);
|
||||
}
|
||||
else {
|
||||
setFailed(error);
|
||||
process.exit();
|
||||
}
|
||||
};
|
||||
const main = async () => {
|
||||
try {
|
||||
const version = getInput('bun-version');
|
||||
const token = getInput('github-token');
|
||||
const miscTestBuilds = (getInput('misc-test-builds') === 'true');
|
||||
if (!version)
|
||||
return exit('Invalid bun version.');
|
||||
const release = await getGithubRelease(version, token);
|
||||
const release = await getGithubRelease(version, token, miscTestBuilds);
|
||||
if ((release === null || release === void 0 ? void 0 : release.message) === 'Not Found')
|
||||
return exit('Invalid bun version.');
|
||||
return exit('Invalid bun version.', miscTestBuilds);
|
||||
info(`Going to install release ${release.version}`);
|
||||
await install(release);
|
||||
setOutput('bun-version', release.tag_name);
|
||||
|
||||
5
dist/utils/getAsset.js
vendored
5
dist/utils/getAsset.js
vendored
@@ -1,3 +1,4 @@
|
||||
import { exit } from '../index.js';
|
||||
export default (assets) => {
|
||||
let arch;
|
||||
switch (process.arch) {
|
||||
@@ -12,6 +13,10 @@ export default (assets) => {
|
||||
}
|
||||
if (!['linux', 'darwin'].some(platform => process.platform === platform))
|
||||
throw new Error(`Unsupported platform ${process.platform}.`);
|
||||
const assetName = `bun-${process.platform}-${arch}.zip`;
|
||||
const asset = assets.find(asset => asset.name === assetName);
|
||||
if (!asset)
|
||||
exit(`Invalid asset ${assetName}`);
|
||||
return {
|
||||
name: `bun-${process.platform}-${arch}`,
|
||||
asset: assets.find(asset => asset.name === `bun-${process.platform}-${arch}.zip`),
|
||||
|
||||
13
dist/utils/getGithubRelease.js
vendored
13
dist/utils/getGithubRelease.js
vendored
@@ -1,19 +1,20 @@
|
||||
import fetch from 'node-fetch';
|
||||
export default async (version, token) => {
|
||||
export default async (version, token, miscTestBuilds) => {
|
||||
const repository = miscTestBuilds ? 'oven-sh/misc-test-builds' : 'oven-sh/bun';
|
||||
let url;
|
||||
if (version === 'latest')
|
||||
url = 'https://api.github.com/repos/oven-sh/bun/releases/latest';
|
||||
if (version === 'latest' || miscTestBuilds)
|
||||
url = `https://api.github.com/repos/${repository}/releases/latest`;
|
||||
else
|
||||
url = `https://api.github.com/repos/oven-sh/bun/releases/tags/bun-v${version}`;
|
||||
url = `https://api.github.com/repos/${repository}/releases/tags/${version.includes('canary') ? version : `bun-v${version}`}`;
|
||||
const release = await (await fetch(url, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'setup-bun-github-action',
|
||||
'Authorization': token
|
||||
'Authorization': `token ${token}`
|
||||
}
|
||||
})).json();
|
||||
return {
|
||||
...release,
|
||||
version: release.tag_name.replace('bun-v', '')
|
||||
version: miscTestBuilds ? `timestamp-v${new Date(release.name).getTime().toString()}` : release.tag_name.replace('bun-v', '')
|
||||
};
|
||||
};
|
||||
|
||||
30
package.json
30
package.json
@@ -1,19 +1,37 @@
|
||||
{
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.6",
|
||||
"name": "setup-bun",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"bun-types": "^0.0.83",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc -p ."
|
||||
},
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/xHyroM/setup-bun.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/xHyroM/setup-bun/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"bun",
|
||||
"github",
|
||||
"actions",
|
||||
"setup"
|
||||
],
|
||||
"author": "xHyroM",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^3.0.0",
|
||||
"@actions/core": "^1.9.0",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"node-fetch": "^3.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bun-types": "^0.0.83",
|
||||
"typescript": "^4.7.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
src/index.ts
17
src/index.ts
@@ -1,21 +1,26 @@
|
||||
import { getInput, info, setFailed, setOutput } from '@actions/core';
|
||||
import { getInput, info, setFailed, setOutput, warning } from '@actions/core';
|
||||
import getGithubRelease from './utils/getGithubRelease.js';
|
||||
import install from './utils/install.js';
|
||||
|
||||
const exit = (error: string) => {
|
||||
setFailed(error);
|
||||
process.exit();
|
||||
export const exit = (error: string, miscTestBuilds?: boolean) => {
|
||||
if (miscTestBuilds) {
|
||||
warning(error);
|
||||
} else {
|
||||
setFailed(error);
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
|
||||
const main = async() => {
|
||||
try {
|
||||
const version = getInput('bun-version');
|
||||
const token = getInput('github-token');
|
||||
const miscTestBuilds = (getInput('misc-test-builds') === 'true');
|
||||
|
||||
if (!version) return exit('Invalid bun version.');
|
||||
|
||||
const release = await getGithubRelease(version, token);
|
||||
if (release?.message === 'Not Found') return exit('Invalid bun version.');
|
||||
const release = await getGithubRelease(version, token, miscTestBuilds);
|
||||
if (release?.message === 'Not Found') return exit('Invalid bun version.', miscTestBuilds);
|
||||
|
||||
info(`Going to install release ${release.version}`);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { exit } from '../index.js';
|
||||
import { Asset } from './getGithubRelease.js';
|
||||
|
||||
export default (assets: Asset[]) => {
|
||||
@@ -16,6 +17,11 @@ export default (assets: Asset[]) => {
|
||||
if (!['linux', 'darwin'].some(platform => process.platform === platform))
|
||||
throw new Error(`Unsupported platform ${process.platform}.`);
|
||||
|
||||
const assetName = `bun-${process.platform}-${arch}.zip`;
|
||||
const asset = assets.find(asset => asset.name === assetName);
|
||||
|
||||
if (!asset) exit(`Invalid asset ${assetName}`);
|
||||
|
||||
return {
|
||||
name: `bun-${process.platform}-${arch}`,
|
||||
asset: assets.find(asset => asset.name === `bun-${process.platform}-${arch}.zip`),
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface Asset {
|
||||
}
|
||||
|
||||
export interface Release {
|
||||
name: string;
|
||||
html_url: string;
|
||||
tag_name: string;
|
||||
message?: string;
|
||||
@@ -13,21 +14,22 @@ export interface Release {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export default async(version: string, token: string): Promise<Release> => {
|
||||
export default async(version: string, token: string, miscTestBuilds: boolean): Promise<Release> => {
|
||||
const repository = miscTestBuilds ? 'oven-sh/misc-test-builds' : 'oven-sh/bun'
|
||||
let url;
|
||||
if (version === 'latest') url = 'https://api.github.com/repos/oven-sh/bun/releases/latest';
|
||||
else url = `https://api.github.com/repos/oven-sh/bun/releases/tags/bun-v${version}`;
|
||||
if (version === 'latest' || miscTestBuilds) url = `https://api.github.com/repos/${repository}/releases/latest`;
|
||||
else url = `https://api.github.com/repos/${repository}/releases/tags/${version.includes('canary') ? version : `bun-v${version}`}`;
|
||||
|
||||
const release: any = await (await fetch(url, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'setup-bun-github-action',
|
||||
'Authorization': token
|
||||
'Authorization': `token ${token}`
|
||||
}
|
||||
})).json();
|
||||
|
||||
return {
|
||||
...release,
|
||||
version: release.tag_name.replace('bun-v', '')
|
||||
version: miscTestBuilds ? `timestamp-v${new Date(release.name).getTime().toString()}` : release.tag_name.replace('bun-v', '')
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user