diff --git a/Formula/badgetizr.rb b/Formula/badgetizr.rb new file mode 100644 index 0000000..9c45430 --- /dev/null +++ b/Formula/badgetizr.rb @@ -0,0 +1,16 @@ +class Badgetizr < Formula + desc "Badgetizr is a tool to allow custom badges automatically added and updated according the content of your pull request." + homepage "https://github.com/aiKrice/homebrew-badgetizr" + url "https://github.com/aiKrice/homebrew-badgetizr/archive/refs/tags/1.2.0.tar.gz" + sha256 "024892da67071348af9b4bef84be76c121ab8b0779dd099ae0c8478f9aec59a3" + license "MIT" + + depends_on "yq" + depends_on "gh" + + def install + bin.install "badgetizr.sh" => "badgetizr" + end + + end + diff --git a/README.md b/README.md index da34dad..46f03c9 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ _📣 I would like to put this tool available with Homebrew and Apt-Get. To succ - [ ] Make the badge_ci badge dynamic (success, failure, pending) - [ ] Add a beautiful icon for this repository - [ ] Improve the Readme.md file +- [x] Add the tools to Homebrew tap - [ ] Add the tool to Homebrew - [ ] Add the tool to Apt-Get - [ ] Add the tools to Github Actions @@ -34,7 +35,7 @@ I am fully engaged to make this tool the best tool ever to add badges to your pu Buy Me a Coffee at ko-fi.com -## Installation +## Installation via Homebrew (MacOS) For now, only Github Pull Requests are supported. You have to export the environment variables `GITHUB_TOKEN` such as: ```bash export GITHUB_TOKEN="your_github_token" @@ -42,23 +43,34 @@ export GITHUB_TOKEN="your_github_token" Then you can run the configure script and the badgetizer script: ```bash -$ git clone https://github.com/aiKrice/badgetizr.git +$ brew tap aiKrice/badgetizr +$ brew install aiKrice/badgetizr/badgetizr # edit the .badgetizr.yml file to your needs $ export GITHUB_TOKEN="your_github_token" $ export BADGETIZR_BUILD_NUMBER="123" # the build number of your CI $ export BADGETIZR_BUILD_URL="https://your-shiny-ci.io/app/build/123" # the build url of your CI $ export BADGETIZR_PR_DESTINATION_BRANCH="develop" # the destination branch of your PR from the CI. -$ cd badgetizr && ./configure ``` +## Installation via Apt-Get (Linux) +Coming soon... + +## Installation manually +```bash +$ git clone https://github.com/aiKrice/badgetizr.git --branch master +$ cd badgetizr +$ ./configure +``` +In the rest of the documentation, I will consider that you have installed the tool in your `$PATH` and remove the `.sh` extension from the binary name. + ## Usage ```bash -$ ./badgetizer.sh +$ badgetizr ``` By default, the configuration file used is `.badgetizr.yml`. You can also specify a configuration file to use by using the `-c` option. ```bash -$ ./badgetizer.sh -c my_config.yml +$ badgetizer -c my_config.yml ``` ## Configuration @@ -143,3 +155,9 @@ export BADGETIZR_BUILD_URL="https://random.url%s" export BADGETIZR_PR_DESTINATION_BRANCH="develop" $ ./configure && ./badgetizer.sh ``` + +## Release (for maintainers) +To release the tool, you can run the `deploy-homebrew.sh` script by providing the version you want to release. Please respect the semantic versioning notation. +```bash +./deploy-homebrew.sh 1.1.3 +``` diff --git a/deploy-homebrew.sh b/deploy-homebrew.sh new file mode 100755 index 0000000..7828295 --- /dev/null +++ b/deploy-homebrew.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# The script deploy-homebrew.sh is used to release the tool to the homebrew repository. +# It will create a tag, update the formula and create a PR. + +# Configuration +REPOSITORY="aiKrice/homebrew-badgetizr" +FORMULA_PATH="Formula/badgetizr.rb" +VERSION="$1" + +if [ -z "$VERSION" ]; then + echo "❌ Please provide a version (example: ./release.sh 1.1.3). Please respect the semantic versioning notation." + exit 1 +fi + +# Step 1: Create the release +git switch master +git pull +git merge develop --no-ff --no-edit --no-verify +echo "🟢 Develop merged into master" +git push --no-verify + +echo "🟡 Creating the release tag" +git tag -a "$VERSION" -m "Release $VERSION" +git push origin "$VERSION" --no-verify +gh release create $VERSION --generate-notes --verify-tag +echo "🟢 Github release created" + +# Step 2: Download the archive and calculate SHA256 for Homebrew +ARCHIVE_URL="https://github.com/$REPOSITORY/archive/refs/tags/$VERSION.tar.gz" +curl -L -o "badgetizr-$VERSION.tar.gz" "$ARCHIVE_URL" +SHA256=$(shasum -a 256 "badgetizr-$VERSION.tar.gz" | awk '{print $1}') +echo "🟢 SHA256 generated: $SHA256" + +# Step 3: Update the formula +sed -i "" -E \ + -e "s#(url \").*(\".*)#\1$ARCHIVE_URL\2#" \ + -e "s#(sha256 \").*(\".*)#\1$SHA256\2#" \ + "$FORMULA_PATH" + +# Step 4: Commit and push +git add "$FORMULA_PATH" +git commit -m "Update formula for version $VERSION" +git push --no-verify + +# Step 5: Backmerge to develop +git switch develop +git pull +git merge master --no-ff --no-edit --no-verify +git push --no-verify +echo "🟢 Backmerged to develop" + +echo "🚀 Done"