diff --git a/README.md b/README.md index 3777974..75d4907 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,15 @@ # action-setup-bun -Setup GitHub Actions workflow with a specific version of Bun +Setup GitHub Actions workflow with a specific version of Bun and adds `BUN_INSTALL` to the `$PATH`. ## Usage ```yaml - name: Setup Bun Runtime - uses: antongolub/action-setup-bun@v0 + uses: antongolub/action-setup-bun@v1.x.x with: version: 0.1.2 + +- name: Run script + run: bun index.js ``` ## License diff --git a/src/main/js/index.js b/src/main/js/index.js deleted file mode 100644 index 6182183..0000000 --- a/src/main/js/index.js +++ /dev/null @@ -1,20 +0,0 @@ -const exec = require('@actions/exec') -const path = require('path') - -const installSh = path.resolve(__dirname, '../../main/sh/install.sh') -const setup = async (version) => { - const args = [installSh] - if (version) args.push(version) - - const res = await exec.getExecOutput('bash', args, { ignoreReturnCode: true}) - - await exec.exec('echo "/home/runner/.bun/bin:" >> $GITHUB_PATH') - - // if (res.stderr) throw res.stderr - - // cp.execSync('exec bash') -} - -module.exports = { - setup -} diff --git a/src/main/js/main.js b/src/main/js/main.js index 8b98dbb..252f524 100644 --- a/src/main/js/main.js +++ b/src/main/js/main.js @@ -1,11 +1,23 @@ const core = require('@actions/core') -const {setup} = require('./index.js') +const exec = require("@actions/exec"); +const path = require('path') + +const installSh = path.resolve(__dirname, '../../main/sh/install.sh') +const setup = async (version) => { + const args = [installSh] + if (version) args.push(version) + + const res = await exec.getExecOutput('bash', args, { ignoreReturnCode: true}) + + return /.+BUN_INSTALL="([^"]+)"/.match(res.stderr)[1] +} async function main() { try { const version = core.getInput('version') - await setup(version) + const BUN_INSTALL = await setup(version) + core.addPath(path.join(BUN_INSTALL, 'bin')) } catch (e) { core.setOutput("error_message", e.message) core.setFailed(e.message)