diff --git a/bump-packages/README.md b/bump-packages/README.md index 7ce3dc4e..d401d5cc 100644 --- a/bump-packages/README.md +++ b/bump-packages/README.md @@ -31,4 +31,7 @@ If there are no outdated packages, the Action will just exit. ... # Do not use a fork for opening PR's fork: false + # Fully-qualified names, e.g. user/tap/formula, are detected automatically. + # Set this to force --full-name for short names too. + full-name: true ``` diff --git a/bump-packages/action.test.mts b/bump-packages/action.test.mts index 54a07380..dafb4388 100644 --- a/bump-packages/action.test.mts +++ b/bump-packages/action.test.mts @@ -75,6 +75,35 @@ describe("bump-packages action", () => { ]); }); + it("bumps fully-qualified formulae with --full-name automatically", () => { + assert.deepEqual(brewBumpArgs("Bump formulae", { + INPUT_FORMULAE: "user/tap/foo", + INPUT_FORK: "false", + }), [ + "bump", + "--no-fork", + "--full-name", + "--open-pr", + "--formulae", + "user/tap/foo", + ]); + }); + + it("forces --full-name for short formula names", () => { + assert.deepEqual(brewBumpArgs("Bump formulae", { + INPUT_FORMULAE: "foo", + INPUT_FORK: "false", + INPUT_FULL_NAME: "true", + }), [ + "bump", + "--no-fork", + "--full-name", + "--open-pr", + "--formulae", + "foo", + ]); + }); + it("bumps casks with --no-fork when not using a fork", () => { assert.deepEqual(brewBumpArgs("Bump casks", { INPUT_CASKS: "baz qux", INPUT_FORK: "false" }), [ "bump", @@ -85,4 +114,33 @@ describe("bump-packages action", () => { "qux", ]); }); + + it("bumps fully-qualified casks with --full-name automatically", () => { + assert.deepEqual(brewBumpArgs("Bump casks", { + INPUT_CASKS: "user/tap/baz", + INPUT_FORK: "false", + }), [ + "bump", + "--no-fork", + "--full-name", + "--open-pr", + "--casks", + "user/tap/baz", + ]); + }); + + it("forces --full-name for short cask names", () => { + assert.deepEqual(brewBumpArgs("Bump casks", { + INPUT_CASKS: "baz", + INPUT_FORK: "false", + INPUT_FULL_NAME: "true", + }), [ + "bump", + "--no-fork", + "--full-name", + "--open-pr", + "--casks", + "baz", + ]); + }); }); diff --git a/bump-packages/action.yml b/bump-packages/action.yml index ad3ebadb..8085ffc7 100644 --- a/bump-packages/action.yml +++ b/bump-packages/action.yml @@ -20,6 +20,10 @@ inputs: description: Use a fork when opening a PR required: false default: ${{ github.repository_owner != 'Homebrew' }} + full-name: + description: Force fully-qualified package names to brew bump + required: false + default: 'false' runs: using: composite steps: @@ -30,33 +34,41 @@ runs: - name: Bump formulae run: | - if [[ "$INPUT_FORK" == "true" ]]; then - NO_FORK="" - else - NO_FORK="--no-fork" + args=() + if [[ "$INPUT_FORK" != "true" ]]; then + args+=(--no-fork) fi IFS=" " read -r -a formulae <<<"${INPUT_FORMULAE}" - brew bump $NO_FORK --open-pr --formulae "${formulae[@]}" + if [[ "$INPUT_FULL_NAME" == "true" || "${formulae[*]}" == */* ]]; then + args+=(--full-name) + fi + args+=(--open-pr) + brew bump "${args[@]}" --formulae "${formulae[@]}" shell: bash if: inputs.formulae != '' env: INPUT_FORMULAE: ${{ inputs.formulae }} INPUT_FORK: ${{ inputs.fork }} + INPUT_FULL_NAME: ${{ inputs.full-name }} HOMEBREW_DEVELOPER: "1" HOMEBREW_GITHUB_API_TOKEN: ${{ inputs.token }} - name: Bump casks run: | - if [[ "$INPUT_FORK" == "true" ]]; then - NO_FORK="" - else - NO_FORK="--no-fork" + args=() + if [[ "$INPUT_FORK" != "true" ]]; then + args+=(--no-fork) fi IFS=" " read -r -a casks <<<"${INPUT_CASKS}" - brew bump $NO_FORK --open-pr --casks "${casks[@]}" + if [[ "$INPUT_FULL_NAME" == "true" || "${casks[*]}" == */* ]]; then + args+=(--full-name) + fi + args+=(--open-pr) + brew bump "${args[@]}" --casks "${casks[@]}" shell: bash if: inputs.casks != '' env: INPUT_CASKS: ${{ inputs.casks }} INPUT_FORK: ${{ inputs.fork }} + INPUT_FULL_NAME: ${{ inputs.full-name }} HOMEBREW_DEVELOPER: "1" HOMEBREW_GITHUB_API_TOKEN: ${{ inputs.token }}