Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0f9c413e5 | ||
|
|
d744239ce1 | ||
|
|
bfac95679f | ||
|
|
640630d09e | ||
|
|
70b6cfe9d1 | ||
|
|
933334b350 | ||
|
|
c52f1f18be | ||
|
|
08cc23c06e | ||
|
|
baf23f03bc | ||
|
|
3868f53a52 | ||
|
|
627e67fd7b | ||
|
|
62d40e4bee | ||
|
|
e838800258 | ||
|
|
37657f4f9f | ||
|
|
633e7abe1e | ||
|
|
4e76ddea17 | ||
|
|
5a78c10e01 | ||
|
|
6dae544af4 | ||
|
|
054bb2f631 | ||
|
|
9f7c2a5c23 | ||
|
|
81ecfb54f4 |
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -14,16 +14,20 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest]
|
||||||
bun-version:
|
bun-version:
|
||||||
["latest", "0.1.3"]
|
["latest", "0.1.3", "latest"]
|
||||||
|
misc-test-builds:
|
||||||
|
[false]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun - Test Builds * ${{ matrix.misc-test-builds }}
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
bun-version: ${{ matrix.bun-version }}
|
bun-version: ${{ matrix.bun-version }}
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
misc-test-builds: ${{ matrix.misc-test-builds }}
|
||||||
|
|
||||||
- name: Try bun
|
- name: Try bun
|
||||||
run: bun --version
|
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.
|
||||||
13
README.md
13
README.md
@@ -8,7 +8,7 @@ Set up your GitHub Actions workflow with a specific version of Bun.
|
|||||||
### Latest stable
|
### Latest stable
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: xhyrom/setup-bun@v0.1.2
|
- uses: xhyrom/setup-bun@v0.1.3
|
||||||
with:
|
with:
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
```
|
```
|
||||||
@@ -16,7 +16,16 @@ Set up your GitHub Actions workflow with a specific version of Bun.
|
|||||||
### Specific version
|
### Specific version
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: xhyrom/setup-bun@v0.1.2
|
- uses: xhyrom/setup-bun@v0.1.3
|
||||||
with:
|
with:
|
||||||
bun-version: "0.1.3"
|
bun-version: "0.1.3"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Test builds
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: xhyrom/setup-bun@v0.1.3
|
||||||
|
with:
|
||||||
|
bun-version: latest
|
||||||
|
misc-test-builds: true
|
||||||
|
```
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ inputs:
|
|||||||
default: "latest"
|
default: "latest"
|
||||||
github-token:
|
github-token:
|
||||||
description: "The github token secret can be passed in using {{ secrets.GITHUB_TOKEN }}"
|
description: "The github token secret can be passed in using {{ secrets.GITHUB_TOKEN }}"
|
||||||
|
misc-test-builds:
|
||||||
|
description: "Install builds from https://github.com/oven-sh/misc-test-builds (not recommended!)"
|
||||||
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
bun-version:
|
bun-version:
|
||||||
|
|||||||
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 getGithubRelease from './utils/getGithubRelease.js';
|
||||||
import install from './utils/install.js';
|
import install from './utils/install.js';
|
||||||
const exit = (error) => {
|
export const exit = (error, miscTestBuilds) => {
|
||||||
setFailed(error);
|
if (miscTestBuilds) {
|
||||||
process.exit();
|
warning(error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setFailed(error);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
try {
|
try {
|
||||||
const version = getInput('bun-version');
|
const version = getInput('bun-version');
|
||||||
const token = getInput('github-token');
|
const token = getInput('github-token');
|
||||||
|
const miscTestBuilds = (getInput('misc-test-builds') === 'true');
|
||||||
if (!version)
|
if (!version)
|
||||||
return exit('Invalid bun 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')
|
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}`);
|
info(`Going to install release ${release.version}`);
|
||||||
await install(release);
|
await install(release);
|
||||||
setOutput('bun-version', release.tag_name);
|
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) => {
|
export default (assets) => {
|
||||||
let arch;
|
let arch;
|
||||||
switch (process.arch) {
|
switch (process.arch) {
|
||||||
@@ -12,6 +13,10 @@ export default (assets) => {
|
|||||||
}
|
}
|
||||||
if (!['linux', 'darwin'].some(platform => process.platform === platform))
|
if (!['linux', 'darwin'].some(platform => process.platform === platform))
|
||||||
throw new Error(`Unsupported platform ${process.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 {
|
return {
|
||||||
name: `bun-${process.platform}-${arch}`,
|
name: `bun-${process.platform}-${arch}`,
|
||||||
asset: assets.find(asset => asset.name === `bun-${process.platform}-${arch}.zip`),
|
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';
|
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;
|
let url;
|
||||||
if (version === 'latest')
|
if (version === 'latest' || miscTestBuilds)
|
||||||
url = 'https://api.github.com/repos/oven-sh/bun/releases/latest';
|
url = `https://api.github.com/repos/${repository}/releases/latest`;
|
||||||
else
|
else
|
||||||
url = `https://api.github.com/repos/oven-sh/bun/releases/tags/bun-v${version}`;
|
url = `https://api.github.com/repos/${repository}/releases/tags/bun-v${version}`;
|
||||||
const release = await (await fetch(url, {
|
const release = await (await fetch(url, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'User-Agent': 'setup-bun-github-action',
|
'User-Agent': 'setup-bun-github-action',
|
||||||
'Authorization': token
|
'Authorization': `token ${token}`
|
||||||
}
|
}
|
||||||
})).json();
|
})).json();
|
||||||
return {
|
return {
|
||||||
...release,
|
...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.4",
|
||||||
"name": "setup-bun",
|
"name": "setup-bun",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
|
||||||
"bun-types": "^0.0.83",
|
|
||||||
"typescript": "^4.7.4"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p ."
|
"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": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.0",
|
"@actions/cache": "^3.0.0",
|
||||||
"@actions/core": "^1.9.0",
|
"@actions/core": "^1.9.0",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"node-fetch": "^3.2.6"
|
"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 getGithubRelease from './utils/getGithubRelease.js';
|
||||||
import install from './utils/install.js';
|
import install from './utils/install.js';
|
||||||
|
|
||||||
const exit = (error: string) => {
|
export const exit = (error: string, miscTestBuilds?: boolean) => {
|
||||||
setFailed(error);
|
if (miscTestBuilds) {
|
||||||
process.exit();
|
warning(error);
|
||||||
|
} else {
|
||||||
|
setFailed(error);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const main = async() => {
|
const main = async() => {
|
||||||
try {
|
try {
|
||||||
const version = getInput('bun-version');
|
const version = getInput('bun-version');
|
||||||
const token = getInput('github-token');
|
const token = getInput('github-token');
|
||||||
|
const miscTestBuilds = (getInput('misc-test-builds') === 'true');
|
||||||
|
|
||||||
if (!version) return exit('Invalid bun version.');
|
if (!version) return exit('Invalid bun version.');
|
||||||
|
|
||||||
const release = await getGithubRelease(version, token);
|
const release = await getGithubRelease(version, token, miscTestBuilds);
|
||||||
if (release?.message === 'Not Found') return exit('Invalid bun version.');
|
if (release?.message === 'Not Found') return exit('Invalid bun version.', miscTestBuilds);
|
||||||
|
|
||||||
info(`Going to install release ${release.version}`);
|
info(`Going to install release ${release.version}`);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { exit } from '../index.js';
|
||||||
import { Asset } from './getGithubRelease.js';
|
import { Asset } from './getGithubRelease.js';
|
||||||
|
|
||||||
export default (assets: Asset[]) => {
|
export default (assets: Asset[]) => {
|
||||||
@@ -16,6 +17,11 @@ export default (assets: Asset[]) => {
|
|||||||
if (!['linux', 'darwin'].some(platform => process.platform === platform))
|
if (!['linux', 'darwin'].some(platform => process.platform === platform))
|
||||||
throw new Error(`Unsupported platform ${process.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 {
|
return {
|
||||||
name: `bun-${process.platform}-${arch}`,
|
name: `bun-${process.platform}-${arch}`,
|
||||||
asset: assets.find(asset => asset.name === `bun-${process.platform}-${arch}.zip`),
|
asset: assets.find(asset => asset.name === `bun-${process.platform}-${arch}.zip`),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { getInput } from '@actions/core';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
|
|
||||||
export interface Asset {
|
export interface Asset {
|
||||||
@@ -6,6 +7,7 @@ export interface Asset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Release {
|
export interface Release {
|
||||||
|
name: string;
|
||||||
html_url: string;
|
html_url: string;
|
||||||
tag_name: string;
|
tag_name: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
@@ -13,21 +15,22 @@ export interface Release {
|
|||||||
version: string;
|
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;
|
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}`;
|
else url = `https://api.github.com/repos/${repository}/releases/tags/bun-v${version}`;
|
||||||
|
|
||||||
const release: any = await (await fetch(url, {
|
const release: any = await (await fetch(url, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'User-Agent': 'setup-bun-github-action',
|
'User-Agent': 'setup-bun-github-action',
|
||||||
'Authorization': token
|
'Authorization': `token ${token}`
|
||||||
}
|
}
|
||||||
})).json();
|
})).json();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...release,
|
...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