diff --git a/.github/workflows/badgetizr.yml b/.github/workflows/badgetizr.yml index 5c62bf9..b3d66a1 100644 --- a/.github/workflows/badgetizr.yml +++ b/.github/workflows/badgetizr.yml @@ -18,10 +18,12 @@ jobs: uses: actions/checkout@v3 - name: Run Badgetizr - uses: aiKrice/homebrew-badgetizr@feat/support_github_action + uses: aiKrice/homebrew-badgetizr@feat/_support_github_action with: pr_id: ${{ github.event.pull_request.number }} configuration: .badgetizr.yml pr_destination_branch: ${{ github.event.pull_request.base.ref }} pr_build_number: ${{ github.run_id }} - pr_build_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ No newline at end of file + pr_build_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index 294fcd6..c5fe0a6 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ $ ./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 +## Usage (CLI) ```bash $ badgetizr #[options] ``` @@ -75,6 +75,30 @@ To see the different options available, you can use the `--help` option: $ badgetizr --help ``` +## Usage GithubAction +Instead of using the CLI, you can directly use the github action in your workflow. +```yaml +jobs: + badgetizr: + runs-on: ubuntu-latest #works also on macos-latest + + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + + - name: Run Badgetizr + uses: aiKrice/homebrew-badgetizr@1.3.0 + with: + pr_id: ${{ github.event.pull_request.number }} + configuration: .badgetizr.yml + pr_destination_branch: ${{ github.event.pull_request.base.ref }} + pr_build_number: ${{ github.run_id }} + pr_build_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +``` + ## Configuration By default, the configuration file used is `.badgetizr.yml`. You can also specify a configuration file to use by using the `-c` option. ```bash @@ -185,8 +209,9 @@ $ ./configure #optional, just for dependencies $ ./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. +## Publishing (for maintainers) +To publish the tool, you can run the `publish.sh` script by providing the version you want to release. Please respect the semantic versioning notation. ```bash -./deploy-homebrew.sh 1.1.3 +./publish.sh 1.1.3 ``` +This script will bump everything possible to keep everything up-to-date. \ No newline at end of file diff --git a/deploy-homebrew.sh b/publish.sh similarity index 71% rename from deploy-homebrew.sh rename to publish.sh index 77f638e..8c4073b 100755 --- a/deploy-homebrew.sh +++ b/publish.sh @@ -6,6 +6,8 @@ # Configuration REPOSITORY="aiKrice/homebrew-badgetizr" FORMULA_PATH="Formula/badgetizr.rb" +WORKFLOW_PATH=".github/workflows/badgetizr.yml" +README_PATH="README.md" VERSION="$1" red='\033[1;31m' @@ -27,7 +29,7 @@ function fail_if_error() { } if [ -z "$VERSION" ]; then - echo "❌ Please provide a version (example: ./release.sh 1.1.3). Please respect the semantic versioning notation." + echo "❌ Please provide a version (example: ./release.sh ${cyan}1.1.3${reset}). Please respect the semantic versioning notation." exit 1 fi @@ -40,20 +42,21 @@ fail_if_error "Failed to merge develop into master" echo "🟢 [Step 1/5] Master is updated." git push --no-verify -echo "🟡 [Step 2/5] Creating the release tag..." +echo "🟡 [Step 2/5] Creating the release tag ${cyan}$VERSION${reset}..." git tag -a "$VERSION" -m "Release $VERSION" git push origin "$VERSION" --no-verify gh release create $VERSION --generate-notes --verify-tag echo "🟢 [Step 2/5] Github release created" # Step 2: Download the archive and calculate SHA256 for Homebrew -echo "🟡 [Step 3/5] Downloading the archive..." ARCHIVE_URL="https://github.com/$REPOSITORY/archive/refs/tags/$VERSION.tar.gz" +echo "🟡 [Step 3/5] Downloading the archive $ARCHIVE_URL..." + curl -L -o "badgetizr-$VERSION.tar.gz" "$ARCHIVE_URL" > /dev/null fail_if_error "Failed to download the archive" echo "🟢 [Step 3/5] Archive downloaded." SHA256=$(shasum -a 256 "badgetizr-$VERSION.tar.gz" | awk '{print $1}') -echo "🟢 SHA256 generated: $SHA256" +echo "🟢 SHA256 generated: ${cyan}$SHA256${reset}" # Step 3: Update the formula sed -i "" -E \ @@ -61,14 +64,18 @@ sed -i "" -E \ -e "s#(sha256 \").*(\".*)#\1$SHA256\2#" \ "$FORMULA_PATH" +# Step 3bis: Update the workflow with new version number +sed -i '' "s|uses: aiKrice/homebrew-badgetizr@.*|uses: aiKrice/homebrew-badgetizr@${NEW_VERSION}|" "$WORKFLOW_FILE" + # Step 4: Commit and push -echo "🟡 [Step 4/5] Committing the formula..." -git add "$FORMULA_PATH" -git commit -m "Update formula for version $VERSION" -fail_if_error "Failed to commit the formula" +echo "🟡 [Step 4/5] Commiting the bump of the files..." +git add "$FORMULA_PATH" "$WORKFLOW_PATH" +git commit -m "Bump version $VERSION" +fail_if_error "Failed to commit the bump" git push --no-verify -fail_if_error "Failed to push the formula" -echo "🟢 [Step 4/5] Formula pushed." +fail_if_error "Failed to push the bump" +echo "🟢 [Step 4/5] Bump pushed." + # Step 5: Backmerge to develop echo "🟡 [Step 5/5] Switching to develop..." git switch develop