docs: update README to document automatic package.json version detection
Co-authored-by: xhyrom <56601352+xhyrom@users.noreply.github.com>
This commit is contained in:
parent
f1e7007589
commit
158bfff365
30
README.md
30
README.md
@ -4,6 +4,18 @@ Download, install, and setup [Bun](https://bun.sh) in GitHub Actions.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: oven-sh/setup-bun@v2
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, if no version is specified, the action will:
|
||||||
|
|
||||||
|
1. Check `package.json` for the `packageManager` field (e.g., `"packageManager": "bun@1.0.25"`)
|
||||||
|
2. If `packageManager` doesn't exist, check `package.json` for `engines.bun`
|
||||||
|
3. If neither exists or `package.json` is not found, use `latest`
|
||||||
|
|
||||||
|
You can also explicitly specify a version:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: oven-sh/setup-bun@v2
|
- uses: oven-sh/setup-bun@v2
|
||||||
with:
|
with:
|
||||||
@ -66,15 +78,15 @@ If you need to override the download URL, you can use the `bun-download-url` inp
|
|||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
| Name | Description | Default | Examples |
|
| Name | Description | Default | Examples |
|
||||||
| ------------------ | --------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------ |
|
| ------------------ | --------------------------------------------------------------------------------- | ---------------------------------------- | ------------------------------------------------ |
|
||||||
| `bun-version` | The version of Bun to download and install. | `latest` | `canary`, `1.0.0`, `1.0.x` |
|
| `bun-version` | The version of Bun to download and install. | Version from `package.json`, or `latest` | `canary`, `1.0.0`, `1.0.x` |
|
||||||
| `bun-version-file` | The version of Bun to download and install from file. | `undefined` | `package.json`, `.bun-version`, `.tool-versions` |
|
| `bun-version-file` | The version of Bun to download and install from file. | `undefined` | `package.json`, `.bun-version`, `.tool-versions` |
|
||||||
| `bun-download-url` | URL to download .zip file for Bun release | | |
|
| `bun-download-url` | URL to download .zip file for Bun release | | |
|
||||||
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
|
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
|
||||||
| `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` |
|
| `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` |
|
||||||
| `no-cache` | Disable caching of the downloaded executable. | `false` | `true`, `false` |
|
| `no-cache` | Disable caching of the downloaded executable. | `false` | `true`, `false` |
|
||||||
| `token` | Personal access token (PAT) used to fetch tags from the `oven-sh/bun` repository. | `${{ github.token }}` | `${{ secrets.GITHUB_TOKEN }}` |
|
| `token` | Personal access token (PAT) used to fetch tags from the `oven-sh/bun` repository. | `${{ github.token }}` | `${{ secrets.GITHUB_TOKEN }}` |
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,10 @@ const FILE_VERSION_READERS = {
|
|||||||
".bun-version": (content: string) => content,
|
".bun-version": (content: string) => content,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function readVersionFromFile(file: string, silent = false): string | undefined {
|
export function readVersionFromFile(
|
||||||
|
file: string,
|
||||||
|
silent = false,
|
||||||
|
): string | undefined {
|
||||||
const cwd = process.env.GITHUB_WORKSPACE;
|
const cwd = process.env.GITHUB_WORKSPACE;
|
||||||
if (!cwd) {
|
if (!cwd) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user