Skip to content

Commit ef00e4a

Browse files
xhyromadeheryshautofix-ci[bot]
authored
release: v2.0 🎉 (#80)
* feat: add input bun-version-file (#76) * feat: add input for bun-version-file * docs: update example bun version file * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * refactor: reduce read from file code * [autofix.ci] apply automated fixes * feat: read from all known files if not specified * [autofix.ci] apply automated fixes * fix: just continue if file doesnt exist * [autofix.ci] apply automated fixes * fix: return output if found version * [autofix.ci] apply automated fixes * fix: make whitespace in .tool-versions optional * [autofix.ci] apply automated fixes * log loglog * [autofix.ci] apply automated fixes * log log log * [autofix.ci] apply automated fixes * better warnings, fix ci failing * [autofix.ci] apply automated fixes * feat: log obtained version * [autofix.ci] apply automated fixes * build: bump version * [autofix.ci] apply automated fixes * fix: add .zip extension if it's not present Workaround for actions/toolkit#1179 Fixes #79 * [autofix.ci] apply automated fixes * docs: add comment for easier understanding * ci: more readable version * ci: match name * docs: add package.json and .tool-versions to bun-version-file examples * ci: add cache test * ci: install another pkg for cache test * ci: install more pkgs for cache test * ci: block all trusted deps in cache test * ci: more deps for cache test * ci: cache test should cache * refactor: dont try all files if not defined * [autofix.ci] apply automated fixes * ci: remove cache test * feat: support .bunrc * [autofix.ci] apply automated fixes * refactor: .bun-version instead .bunrc * [autofix.ci] apply automated fixes * feat: add bun paths and url to output Fixes #81 * [autofix.ci] apply automated fixes * ci: test for .bun-version * feat: make .bun-version as default in bun-version-file * ci: remove cache before test * ci: remove cache before test * ci: remove cache before test * ci: remove cache before test --------- Co-authored-by: Ade Hery Shopyan <51158020+adeherysh@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 43b2dc9 commit ef00e4a

File tree

10 files changed

+228
-164
lines changed

10 files changed

+228
-164
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Compare Bun Version
2+
description: Compare the version of Bun to a specified version
3+
4+
inputs:
5+
bun-version:
6+
description: "The version of Bun to compare against"
7+
required: true
8+
default: "1.1.0"
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Get installed Bun version
14+
id: bun
15+
shell: bash
16+
run: |
17+
bun --version
18+
echo "version=$(bun --version)" >> $GITHUB_OUTPUT
19+
20+
- name: Compare versions
21+
shell: bash
22+
run: |
23+
if [[ "${{ steps.bun.outputs.version }}" == "${{ inputs.bun-version }}" ]]; then
24+
echo "Version is ${{ inputs.bun-version }}"
25+
else
26+
echo "Expected version to be ${{ inputs.bun-version }}, got ${{ steps.bun.outputs.version }}"
27+
exit 1
28+
fi

.github/workflows/test.yml

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,35 @@ on:
88
- main
99

1010
permissions:
11-
contents: read
11+
contents: write
1212

1313
jobs:
14+
remove-cache:
15+
runs-on: ubuntu-latest
16+
permissions: write-all
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Install github cli
22+
run: |
23+
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
24+
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
25+
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
26+
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
27+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
28+
&& sudo apt update \
29+
&& sudo apt install gh -y
30+
31+
- run: |
32+
gh cache delete --all || true
33+
env:
34+
GH_TOKEN: ${{ github.token }}
35+
1436
setup-bun:
1537
runs-on: ${{ matrix.os }}
1638
continue-on-error: true
39+
needs: [remove-cache]
1740
strategy:
1841
matrix:
1942
os:
@@ -46,80 +69,55 @@ jobs:
4669
run: |
4770
bun --version
4871
49-
setup-bun-from-package-json-version:
72+
setup-bun-from-file:
73+
name: setup-bun from (${{ matrix.os }}, ${{ matrix.file.name }})
5074
runs-on: ${{ matrix.os }}
75+
continue-on-error: true
76+
needs: [remove-cache]
5177
strategy:
5278
matrix:
5379
os:
5480
- ubuntu-latest
5581
- macos-latest
5682
- windows-latest
57-
packageManager:
58-
- bun@1.1.0
59-
- yarn@bun@1.1.0
83+
file:
84+
- name: package.json (bun@1.1.0)
85+
file: package.json
86+
run: |
87+
echo "$(jq '. += {"packageManager": "bun@1.1.0"}' package.json)" > package.json
88+
- name: package.json (yarn@bun@1.1.0)
89+
file: package.json
90+
run: |
91+
echo "$(jq '. += {"packageManager": "yarn@bun@1.1.0"}' package.json)" > package.json
92+
- name: .tool-versions (bun 1.1.0)
93+
file: .tool-versions
94+
run: |
95+
echo "bun 1.1.0" > .tool-versions
96+
- name: .tool-versions (bun1.1.0)
97+
file: .tool-versions
98+
run: |
99+
echo "bun1.1.0" > .tool-versions
100+
- name: .bumrc (1.1.0)
101+
file: .bumrc
102+
run: |
103+
echo "1.1.0" > .bumrc
104+
- name: .bun-version (1.1.0)
105+
file: .bun-version
106+
run: |
107+
echo "1.1.0" > .bun-version
60108
steps:
61109
- name: Checkout
62110
uses: actions/checkout@v4
63111

64-
- name: Setup package.json
65-
shell: bash
66-
run: |
67-
echo "$(jq '. += {"packageManager": "${{ matrix.packageManager }}"}' package.json)" > package.json
112+
- name: Setup file
113+
run: ${{ matrix.file.run }}
68114

69115
- name: Setup Bun
70116
uses: ./
117+
with:
118+
bun-version-file: ${{ matrix.file.file }}
71119

72-
- name: Run Bun
73-
id: bun
74-
shell: bash
75-
run: |
76-
bun --version
77-
echo "version=$(bun --version)" >> $GITHUB_OUTPUT
78-
79-
- name: Check version
80-
shell: bash
81-
run: |
82-
if [[ "${{ steps.bun.outputs.version }}" == "1.1.0" ]]; then
83-
echo "Version is 1.1.0"
84-
else
85-
echo "Expected version to be 1.1.0, got ${{ steps.bun.outputs.version }}"
86-
exit 1
87-
fi
88-
setup-bun-from-tool-versions:
89-
runs-on: ${{ matrix.os }}
90-
strategy:
91-
matrix:
92-
os:
93-
- ubuntu-latest
94-
- macos-latest
95-
- windows-latest
96-
content:
97-
- "bun 1.1.0"
98-
- "bun1.1.0"
99-
steps:
100-
- name: Checkout
101-
uses: actions/checkout@v4
102-
- name: Setup package.json
103-
shell: bash
104-
run: |
105-
echo "bun ${{ matrix.content }}" > .tool-versions
106-
107-
- name: Setup Bun
108-
uses: ./
109-
110-
- name: Run Bun
111-
id: bun
112-
shell: bash
113-
run: |
114-
bun --version
115-
echo "version=$(bun --version)" >> $GITHUB_OUTPUT
116-
117-
- name: Check version
118-
shell: bash
119-
run: |
120-
if [[ "${{ steps.bun.outputs.version }}" == "1.1.0" ]]; then
121-
echo "Version is 1.1.0"
122-
else
123-
echo "Expected version to be 1.1.0, got ${{ steps.bun.outputs.version }}"
124-
exit 1
125-
fi
120+
- name: Compare versions
121+
uses: ./.github/actions/compare-bun-version
122+
with:
123+
bun-version: "1.1.0"

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Download, install, and setup [Bun](https://bun.sh) in GitHub Actions.
1010
bun-version: latest
1111
```
1212
13+
## Using version file
14+
15+
```yaml
16+
- uses: oven-sh/setup-bun@v1
17+
with:
18+
bun-version-file: ".bumrc"
19+
```
20+
1321
### Using a custom NPM registry
1422
1523
```yaml
@@ -44,13 +52,13 @@ In most cases, you shouldn't need to use the [setup-node](https://github.com/act
4452

4553
## Inputs
4654

47-
| Name | Description | Default | Examples |
48-
| ------------------ | -------------------------------------------------- | ----------- | ------------------------------- |
49-
| `bun-version` | The version of Bun to download and install. | `latest` | `canary`, `1.0.0`, `1.0.x` |
50-
| `bun-download-url` | URL to download .zip file for Bun release | | |
51-
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
52-
| `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` |
53-
| `no-cache` | Disable caching of the downloaded executable. | `false` | `true`, `false` |
55+
| Name | Description | Default | Examples |
56+
| ------------------ | ----------------------------------------------------- | ----------- | ------------------------------- |
57+
| `bun-version` | The version of Bun to download and install. | `latest` | `canary`, `1.0.0`, `1.0.x` |
58+
| `bun-version-file` | The version of Bun to download and install from file. | `undefined` | `.bumrc` |
59+
| `bun-download-url` | URL to download .zip file for Bun release | | |
60+
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
61+
| `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` |
5462

5563
## Outputs
5664

action.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ branding:
55
icon: play-circle
66
color: white
77
inputs:
8-
bun-download-url:
9-
description: "Override the URL to download Bun from. This skips version resolution and verifying AVX2 support."
10-
required: false
118
bun-version:
129
description: 'The version of Bun to install. (e.g. "latest", "canary", "1.0.0", "1.0.x", <sha>)'
1310
required: false
11+
bun-version-file:
12+
description: 'The version of Bun to install from file. (e.g. "package.json", ".bumrc", ".tool-versions")'
13+
default: ".bun-version"
14+
required: false
15+
bun-download-url:
16+
description: "Override the URL to download Bun from. This skips version resolution and verifying AVX2 support."
17+
required: false
1418
registry-url:
1519
required: false
1620
description: "The URL of the package registry to use for installing Bun. Set the $BUN_AUTH_TOKEN environment variable to authenticate with the registry."
@@ -27,8 +31,13 @@ outputs:
2731
description: The version of Bun that was installed.
2832
bun-revision:
2933
description: The revision of Bun that was installed.
34+
bun-path:
35+
description: The path to the Bun executable.
36+
bun-download-url:
37+
description: The URL from which Bun was downloaded.
3038
cache-hit:
3139
description: If the version of Bun was cached.
40+
3241
runs:
3342
using: "node20"
3443
main: "dist/setup/index.js"

0 commit comments

Comments
 (0)