Skip to content

Commit

Permalink
Various improvements and fixes to setup-bun (#40)
Browse files Browse the repository at this point in the history
* Do not save cache on hit
* Support Windows (canary only)
* Support `registry-url` and `scope`
  • Loading branch information
Electroid authored Nov 17, 2023
1 parent 830e319 commit a93230d
Show file tree
Hide file tree
Showing 14 changed files with 994 additions and 78,881 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: autofix.ci # Must be named this for autofix.ci to work

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install Dependencies
run: npm install
- name: Format
run: |
npm run format
npm run build
- name: Commit
uses: autofix-ci/action@d3e591514b99d0fca6779455ff8338516663f7cc
41 changes: 26 additions & 15 deletions .github/workflows/action.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
name: Setup Bun
name: Test

on:
push:
branches:
- main
workflow_dispatch:
pull_request:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
setup-bun:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
include:
- os: windows-latest
bun-version: canary
os:
- ubuntu-latest
- macos-latest
bun-version:
- latest
- canary
- "0.5.6"
- "9be68ac2350b965037f408ce4d47c3b9d9a76b63"
- "0.8.1" # last version before 1.0
- "0.x"
- "1.0.0"
- "1.x"
- "1"
- "> 1.0.0"
- "< 2"
# Disable <sha> support for now. This is because Github Artifacts
# expire after 90 days, and we don't have another source of truth yet.
# - "822a00c4d508b54f650933a73ca5f4a3af9a7983" # 1.0.0 commit
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-bun
name: Setup Bun
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: ./
with:
bun-version: ${{ matrix.bun-version }}
- id: verify-bun
name: Verify Bun
- name: Run Bun
run: |
bun --version
setup-bun-from-package-json-version:
Expand All @@ -49,6 +60,6 @@ jobs:
echo "$(jq '. += {"packageManager": "[email protected]"}' package.json)" > package.json
- name: Setup Bun
uses: ./
- name: Verify Bun
- name: Run Bun
run: |
bun --version
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ Download, install, and setup [Bun](https://bun.sh) in GitHub Actions.
bun-version: latest
```
### Setup custom registry-url and scope (for private packages)
### Using a custom NPM registry
```yaml
- uses: oven-sh/setup-bun@v1
with:
registry-url: "https://npm.pkg.github.com/"
scope: "@foo-bar"
scope: "@foo"
```
After setting up the registry-url and scope, when installing step comes, inject the env to authenticate and install all packages from the private registry
If you need to authenticate with a private registry, you can set the `BUN_AUTH_TOKEN` environment variable.

```yaml
- name: Installing dependencies
- name: Install Dependencies
env:
BUN_AUTH_TOKEN: ${{ secrets.MY_SUPER_SECRET_PAT }}
run: bun i
BUN_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: bun install
```

## Inputs

| Name | Description | Default | Examples |
| -------------- | -------------------------------------------------- | ----------- | ------------------------------- |
| `bun-version` | The version of Bun to download and install. | `latest` | `canary`, `1.0.0`, `<sha>` |
| `bun-version` | The version of Bun to download and install. | `latest` | `canary`, `1.0.0`, `1.0.x` |
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
| `scope` | Scope for private pacakages | `undefined` | `"@foo-bar"`, `"@orgname"` |
| `scope` | Scope for private pacakages. | `undefined` | `"@foo"`, `"@orgname"` |

## Outputs

| Name | Description | Example |
| -------------- | ------------------------------------------ | ------------------------------------------------ |
| `cache-hit` | If the Bun executable was read from cache. | `true` |
| `bun-version` | The output from `bun --version`. | `1.0.0` |
| `bun-revision` | The output from `bun --revision`. | `1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983` |
| Name | Description | Example |
| -------------- | ------------------------------------------ | ---------------- |
| `cache-hit` | If the Bun executable was read from cache. | `true` |
| `bun-version` | The output from `bun --version`. | `1.0.0` |
| `bun-revision` | The output from `bun --revision`. | `1.0.0+822a00c4` |
10 changes: 6 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ branding:
color: white
inputs:
bun-version:
description: 'The version of Bun to install. (e.g. "latest", "canary", "0.5.6", <sha>)'
description: 'The version of Bun to install. (e.g. "latest", "canary", "1.0.0", "1.0.x", <sha>)'
default: latest
required: false
registry-url:
required: false
description: "Optional registry to set up for auth. Will set the registry in a project level build.toml file, and set up auth to read in from env.BUN_AUTH_TOKEN."
description: "The URL of the package registry to use for installing Bun. Set the $BUN_AUTH_TOKEN environment variable to authenticate with the registry."
scope:
required: false
description: "Optional scope for authenticating against scoped registries."
description: "The scope for authenticating with the package registry."
outputs:
bun-version:
description: The version of Bun that was installed.
bun-revision:
description: The revision of Bun that was installed.
cache-hit:
description: If the version of Bun was cached.
runs:
using: node20
main: dist/action.js
main: dist/index.js
Loading

0 comments on commit a93230d

Please sign in to comment.