diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 40ee532..384b972 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -197,7 +197,6 @@ jobs: - name: Install from default registry run: | output=$(bun add is-odd --verbose --force 2>&1) - echo "$output" if echo "$output" | grep -q "HTTP/1.1 GET https://registry.npmjs.org/is-odd"; then echo "Successfully installed from default registry" @@ -208,10 +207,9 @@ jobs: - name: Install from @types registry run: | - output=$(bun add @types/bun --verbose --force) - echo "$output" + output=$(bun add @types/bun --verbose --force 2>&1) - if echo "$output" | grep -q "HTTP/1.1 GET https://registry.yarnpkg.com/@types/bun"; then + if echo "$output" | grep -q "HTTP/1.1 GET https://registry.yarnpkg.com/@types%2fbun"; then echo "Successfully installed from @types registry" else echo "Failed to install from @types registry" diff --git a/README.md b/README.md index 004ad3c..b08036c 100644 --- a/README.md +++ b/README.md @@ -18,24 +18,39 @@ Download, install, and setup [Bun](https://bun.sh) in GitHub Actions. bun-version-file: ".bun-version" ``` -### Using a custom NPM registry +## Using custom registries + +You can configure multiple package registries using the `registries` input. This supports both default and scoped registries with various authentication methods. + +### Registry configuration ```yaml - uses: oven-sh/setup-bun@v2 with: - registry-url: "https://npm.pkg.github.com/" - scope: "@foo" -``` + registries: | + https://registry.npmjs.org/ + @myorg:https://npm.pkg.github.com/|$GITHUB_TOKEN + @internal:https://username:$INTERNAL_PASSWORD@registry.internal.com/ -If you need to authenticate with a private registry, you can set the `BUN_AUTH_TOKEN` environment variable. - -```yaml -- name: Install Dependencies +- name: Install dependencies env: - BUN_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: bun install --frozen-lockfile + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + INTERNAL_PASSWORD: ${{ secrets.INTERNAL_PASSWORD }} + run: bun install ``` +#### Registry format options + +- **Default registry**: `https://registry.npmjs.org/` +- **Default registry with token**: `https://registry.npmjs.org/|$TOKEN` +- **Scoped registry**: `@scope:https://registry.example.com/` +- **Scoped registry with token**: `@scope:https://registry.example.com/|$TOKEN` +- **Scoped registry with URL credentials**: `@scope:https://username:$PASSWORD@registry.example.com/` + +> **Note**: When using authentication, make sure to set the corresponding environment variables in your workflow steps that need access to the registries. + +For more information about configuring registries in Bun, see the [official documentation](https://bun.sh/docs/install/registries). + ### Override download url If you need to override the download URL, you can use the `bun-download-url` input. diff --git a/action.yml b/action.yml index eb56910..e60cfde 100644 --- a/action.yml +++ b/action.yml @@ -17,15 +17,23 @@ inputs: bun-download-url: description: Override the URL to download Bun from. This skips version resolution and verifying AVX2 support. required: false + registries: + description: | + List of package registries with authentication support. Format: + - Default registry: https://registry.npmjs.org/ + - Default with token: https://registry.npmjs.org/|token + - Scoped registry: @scope:https://registry.example.com/ + - Scoped with token: @scope:https://registry.example.com/|token + - Scoped with credentials: @scope:https://user:pass@registry.example.com/ + required: false registry-url: required: false description: The URL of the package registry to use for installing Bun. Set the $BUN_AUTH_TOKEN environment variable to authenticate with the registry. + deprecationMessage: "Use 'registries' input instead." scope: required: false description: "The scope for authenticating with the package registry." - registries: - required: false - description: "An list of package registries for authenticating with the package registry." + deprecationMessage: "Use 'registries' input instead." no-cache: required: false type: boolean diff --git a/src/index.ts b/src/index.ts index 716755d..360eb91 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,8 @@ if (!process.env.RUNNER_TEMP) { } const registries = parseRegistries(getInput("registries")); + +// Backwards compatibility for the `registry-url` and `scope` inputs const registryUrl = getInput("registry-url"); const scope = getInput("scope");