Commit 2609f62 1 parent 194c60e commit 2609f62 Copy full SHA for 2609f62
File tree 2 files changed +56
-1
lines changed
2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 76
76
echo "Expected version to be 1.0.0, got ${{ steps.bun.outputs.version }}"
77
77
exit 1
78
78
fi
79
+ setup-bun-from-tool-versions :
80
+ runs-on : ${{ matrix.os }}
81
+ strategy :
82
+ matrix :
83
+ os :
84
+ - ubuntu-latest
85
+ - macos-latest
86
+ content :
87
+ - " bun 1.0.0"
88
+ - " bun1.0.0"
89
+ steps :
90
+ - name : Checkout
91
+ uses : actions/checkout@v4
92
+ - name : Setup package.json
93
+ run : |
94
+ echo "bun ${{ matrix.content }}" > .tool-versions
95
+ - name : Setup Bun
96
+ uses : ./
97
+ - name : Run Bun
98
+ id : bun
99
+ run : |
100
+ bun --version
101
+ echo "version=$(bun --version)" >> $GITHUB_OUTPUT
102
+ - name : Check version
103
+ run : |
104
+ if [[ "${{ steps.bun.outputs.version }}" == "1.0.0" ]]; then
105
+ echo "Version is 1.0.0"
106
+ else
107
+ echo "Expected version to be 1.0.0, got ${{ steps.bun.outputs.version }}"
108
+ exit 1
109
+ fi
Original file line number Diff line number Diff line change @@ -36,8 +36,32 @@ function readVersionFromPackageJson(): string | undefined {
36
36
}
37
37
}
38
38
39
+ function readVersionFromToolVersions ( ) : string | undefined {
40
+ const cwd = process . env . GITHUB_WORKSPACE ;
41
+ if ( ! cwd ) {
42
+ return ;
43
+ }
44
+ const path = join ( cwd , ".tool-versions" ) ;
45
+ try {
46
+ if ( ! existsSync ( path ) ) {
47
+ return ;
48
+ }
49
+
50
+ const match = readFileSync ( path , "utf8" ) . match ( / ^ b u n \s (?< version > .* ?) $ / m) ;
51
+
52
+ return match ?. groups ?. version ;
53
+ } catch ( error ) {
54
+ const { message } = error as Error ;
55
+ warning ( `Failed to read .tool-versions: ${ message } ` ) ;
56
+ }
57
+ }
58
+
39
59
runAction ( {
40
- version : getInput ( "bun-version" ) || readVersionFromPackageJson ( ) || undefined ,
60
+ version :
61
+ getInput ( "bun-version" ) ||
62
+ readVersionFromPackageJson ( ) ||
63
+ readVersionFromToolVersions ( ) ||
64
+ undefined ,
41
65
customUrl : getInput ( "bun-download-url" ) || undefined ,
42
66
registryUrl : getInput ( "registry-url" ) || undefined ,
43
67
scope : getInput ( "scope" ) || undefined ,
You can’t perform that action at this time.
0 commit comments