From ded24d06cda0a8aa645cd9d0d10e6e96c6b63f48 Mon Sep 17 00:00:00 2001 From: Chris Saez Date: Wed, 4 Dec 2024 22:38:30 +0100 Subject: [PATCH] fix(badgetizr): Fix version + help + parameter --- Formula/badgetizr.rb | 3 ++- action.yml | 3 +-- badgetizr.sh => badgetizr | 38 ++++++++------------------------------ publish.sh | 6 ++++++ utils.sh | 30 ++++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 33 deletions(-) rename badgetizr.sh => badgetizr (89%) create mode 100755 utils.sh diff --git a/Formula/badgetizr.rb b/Formula/badgetizr.rb index bbf9c0d..cfcc2f2 100644 --- a/Formula/badgetizr.rb +++ b/Formula/badgetizr.rb @@ -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 diff --git a/action.yml b/action.yml index a3fcad0..cda857b 100644 --- a/action.yml +++ b/action.yml @@ -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 \ No newline at end of file diff --git a/badgetizr.sh b/badgetizr similarity index 89% rename from badgetizr.sh rename to badgetizr index 844aef4..b132a17 100755 --- a/badgetizr.sh +++ b/badgetizr @@ -1,38 +1,16 @@ #!/bin/bash -# Read config file - -show_help() { - cat <, - --configuration=, - --configuration (Optional) Specify the path to the configuration. Default is .badgetizr.yml - - --pr-id=, - --pr-id (Mandatory) Specify the pull request id. - - --pr-destination-branch=, - --pr-destination-branch (Mandatory when branch badge is enabled) Specify the pull request destination branch. - - --pr-build-number=, - --pr-build-number (Mandatory when CI badge is enabled) Specify the pull request build number. - - --pr-build-url=, - --pr-build-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" diff --git a/publish.sh b/publish.sh index 942276b..b898328 100755 --- a/publish.sh +++ b/publish.sh @@ -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" @@ -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 diff --git a/utils.sh b/utils.sh new file mode 100755 index 0000000..db65bbd --- /dev/null +++ b/utils.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +show_help() { + cat <, + --configuration=, + --configuration (Optional) Specify the path to the configuration. Default is .badgetizr.yml + + --pr-id=, + --pr-id (Mandatory) Specify the pull request id. + + --pr-destination-branch=, + --pr-destination-branch (Mandatory when branch badge is enabled) Specify the pull request destination branch. + + --pr-build-number=, + --pr-build-number (Mandatory when CI badge is enabled) Specify the pull request build number. + + --pr-build-url=, + --pr-build-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 \ No newline at end of file