Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aiKrice committed Nov 30, 2024
2 parents b0fbb2e + 4ddd280 commit de7cb11
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 5 deletions.
16 changes: 16 additions & 0 deletions Formula/badgetizr.rb
Original file line number Diff line number Diff line change
@@ -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

28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,31 +35,42 @@ I am fully engaged to make this tool the best tool ever to add badges to your pu

<a href='https://ko-fi.com/Q5Q7PPTYK' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi6.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

## 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"
```

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
Expand Down Expand Up @@ -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
```
53 changes: 53 additions & 0 deletions deploy-homebrew.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit de7cb11

Please sign in to comment.