Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bump-packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
58 changes: 58 additions & 0 deletions bump-packages/action.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
]);
});
});
32 changes: 22 additions & 10 deletions bump-packages/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Comment on lines +23 to +26

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is now auto-detected: do we need this option/input at all?

runs:
using: composite
steps:
Expand All @@ -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 }}