Skip to content

Commit

Permalink
fix(badgetizr): Fix version + help + parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
aiKrice committed Dec 4, 2024
1 parent 1c8444b commit ded24d0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 33 deletions.
3 changes: 2 additions & 1 deletion Formula/badgetizr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Badgetizr < Formula
depends_on "gh"

def install
bin.install "badgetizr.sh" => "badgetizr"
libexec.install "badgetizr", "utils.sh"
bin.install_symlink libexec/"badgetizr"
end

end
Expand Down
3 changes: 1 addition & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,5 @@ runs:
options="$options --pr-build-url $pr_build_url"
fi
chmod +x ./badgetizr.sh
./badgetizr.sh -c $configuration $options
./badgetizr -c $configuration $options
shell: bash
38 changes: 8 additions & 30 deletions badgetizr.sh → badgetizr
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
#!/bin/bash

# Read config file

show_help() {
cat <<EOF
Usage: $0 [options]
Options :
-c <file>,
--configuration=<file>,
--configuration <file> (Optional) Specify the path to the configuration. Default is .badgetizr.yml
--pr-id=<id>,
--pr-id <id> (Mandatory) Specify the pull request id.
--pr-destination-branch=<branch>,
--pr-destination-branch <branch> (Mandatory when branch badge is enabled) Specify the pull request destination branch.
--pr-build-number=<number>,
--pr-build-number <number> (Mandatory when CI badge is enabled) Specify the pull request build number.
--pr-build-url=<url>,
--pr-build-url <url> (Mandatory when CI badge is enabled) Specify the pull request build url.
--version, -v Display the version of Badgetizr.
-h, --help Display this help.
EOF
}
# Use local utils.sh during development
if [ -f "$(dirname "$0")/../libexec/utils.sh" ]; then
UTILS_PATH="$(dirname "$0")/../libexec/utils.sh"
else
UTILS_PATH="$(dirname "$0")/utils.sh"
fi
source "$UTILS_PATH"

config_file=".badgetizr.yml"
BADGETIZR_VERSION=$(git tag --sort=-creatordate | head -n 1)

while getopts "c:-:" opt; do
while getopts "c:hv-:" opt; do
case $opt in
c)
config_file="$OPTARG"
Expand Down
6 changes: 6 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
REPOSITORY="aiKrice/homebrew-badgetizr"
FORMULA_PATH="Formula/badgetizr.rb"
WORKFLOW_PATH=".github/workflows/badgetizr.yml"
UTILS_PATH="utils.sh"
README_PATH="README.md"
VERSION="$1"

Expand Down Expand Up @@ -41,6 +42,11 @@ if [ -z "$GITHUB_TOKEN" ]; then
exit 1
fi

# Changing the version for -v option
sed -i '' "s|^BADGETIZR_VERSION=.*|BADGETIZR_VERSION=\"$VERSION\"|" "$UTILS_PATH"
git add "$UTILS_PATH"
git commit -m "Bump version to $VERSION for -v option"
git push
# Step 1: Create the release
echo "🟡 [Step 1/5] Switching to master..."
git switch master
Expand Down
30 changes: 30 additions & 0 deletions utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

show_help() {
cat <<EOF
Usage: $0 [options]
Options :
-c <file>,
--configuration=<file>,
--configuration <file> (Optional) Specify the path to the configuration. Default is .badgetizr.yml
--pr-id=<id>,
--pr-id <id> (Mandatory) Specify the pull request id.
--pr-destination-branch=<branch>,
--pr-destination-branch <branch> (Mandatory when branch badge is enabled) Specify the pull request destination branch.
--pr-build-number=<number>,
--pr-build-number <number> (Mandatory when CI badge is enabled) Specify the pull request build number.
--pr-build-url=<url>,
--pr-build-url <url> (Mandatory when CI badge is enabled) Specify the pull request build url.
--version, -v Display the version of Badgetizr.
-h, --help Display this help.
EOF
}

BADGETIZR_VERSION=1.4.0

0 comments on commit ded24d0

Please sign in to comment.