30 Commits

Author SHA1 Message Date
Hyro
27a94d6f80 chore(action): fix 2022-07-27 08:20:47 +02:00
Hyro
b0a04f5fb3 chore: bump version 2022-07-27 08:18:45 +02:00
Hyro
ddba6331f8 chore: bump version 2022-07-27 08:18:27 +02:00
Hyro
99221c1ae0 fix(action): add github.token as default 2022-07-27 08:18:12 +02:00
Hyro
13923243f4 chore(README): add github token 2022-07-26 07:29:31 +02:00
xHyroM
a9318b00d5 chore(test): update 2022-07-25 22:48:11 +02:00
xHyroM
bf40fde936 chore(test): update 2022-07-25 22:36:22 +02:00
xHyroM
92c5bc2cef chore(test): add canary 2022-07-25 22:32:15 +02:00
xHyroM
37397a08ec feat: canary support 2022-07-25 22:31:43 +02:00
xHyroM
a0f9c413e5 chore(workflows): update test 2022-07-16 18:53:20 +02:00
xHyroM
d744239ce1 chore(workflows): update test 2022-07-16 18:52:25 +02:00
xHyroM
bfac95679f chore(workflows): update test 2022-07-16 18:50:53 +02:00
xHyroM
640630d09e chore: bump version 2022-07-16 18:48:17 +02:00
xHyroM
70b6cfe9d1 chore: build 2022-07-16 18:47:40 +02:00
Hyro
933334b350 fix(getGithubRelease): correct token pass 2022-07-16 18:46:00 +02:00
Hyro
c52f1f18be chore: new example 2022-07-13 09:42:54 +02:00
Hyro
08cc23c06e chore: bump version 2022-07-13 09:42:16 +02:00
Hyro
baf23f03bc chore: bump version 2022-07-13 09:42:02 +02:00
Hyro
3868f53a52 chore(CI): fix workflow 2022-07-13 07:50:55 +02:00
xHyroM
627e67fd7b chore(CI): update test 2022-07-13 07:04:23 +02:00
xHyroM
62d40e4bee chore(CI): update test 2022-07-12 22:08:16 +02:00
xHyroM
e838800258 chore(CI): change job status 2022-07-12 19:58:24 +02:00
xHyroM
37657f4f9f fix: dont fail 2022-07-12 19:56:32 +02:00
xHyroM
633e7abe1e fix: dont error when invalid asset for miscTestBuilds 2022-07-12 19:53:24 +02:00
xHyroM
4e76ddea17 fix: warn if bad version 2022-07-12 18:53:38 +02:00
xHyroM
5a78c10e01 fix: verion.trim is not function 2022-07-12 18:46:22 +02:00
xHyroM
6dae544af4 fix: correct repo for misc test builds 2022-07-12 18:43:56 +02:00
xHyroM
054bb2f631 chore: build 2022-07-12 18:42:27 +02:00
xHyroM
9f7c2a5c23 feat: add support for test builds 2022-07-12 18:39:58 +02:00
xHyroM
81ecfb54f4 chore: update package.json, license 2022-07-12 11:03:29 +02:00
11 changed files with 143 additions and 37 deletions

View File

@@ -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
View 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.

View File

@@ -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 }}
```

View File

@@ -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
View File

@@ -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);

View File

@@ -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`),

View File

@@ -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', '')
};
};

View File

@@ -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"
}
}
}

View File

@@ -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}`);

View File

@@ -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`),

View File

@@ -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', '')
};
}
}