From b838e379a6edef3f154c23ce38ddffdd74ab3c76 Mon Sep 17 00:00:00 2001 From: Marc Troelitzsch Date: Tue, 4 Jun 2024 23:28:09 +0200 Subject: [PATCH] chore: add powershell and homebrew installers --- .github/workflows/release.yml | 43 ++++++++++++++++++++++++++++++++++- Cargo.lock | 2 +- Cargo.toml | 8 +++++-- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c816275..f244ef4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -235,15 +235,56 @@ jobs: name: artifacts-dist-manifest path: dist-manifest.json + publish-homebrew-formula: + needs: + - plan + - host + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PLAN: ${{ needs.plan.outputs.val }} + GITHUB_USER: "axo bot" + GITHUB_EMAIL: "admin+bot@axo.dev" + if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} + steps: + - uses: actions/checkout@v4 + with: + repository: "marcfrederick/homebrew-tap" + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} + # So we have access to the formula + - name: Fetch homebrew formulae + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: Formula/ + merge-multiple: true + # This is extra complex because you can make your Formula name not match your app name + # so we need to find releases with a *.rb file, and publish with that filename. + - name: Commit formula files + run: | + git config --global user.name "${GITHUB_USER}" + git config --global user.email "${GITHUB_EMAIL}" + + for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do + filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output) + name=$(echo "$filename" | sed "s/\.rb$//") + version=$(echo "$release" | jq .app_version --raw-output) + + git add "Formula/${filename}" + git commit -m "${name} ${version}" + done + git push + # Create a GitHub Release while uploading all files to it announce: needs: - plan - host + - publish-homebrew-formula # use "always() && ..." to allow us to wait for all publish jobs while # still allowing individual publish jobs to skip themselves (for prereleases). # "host" however must run to completion, no skipping allowed! - if: ${{ always() && needs.host.result == 'success' }} + if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }} runs-on: "ubuntu-20.04" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index 909a13d..b5333d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -143,7 +143,7 @@ checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "git-foreach" -version = "0.1.0" +version = "0.1.1" dependencies = [ "clap", "ignore", diff --git a/Cargo.toml b/Cargo.toml index 2796009..1af0d31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "git-foreach" description = "Run a command in each git repository in a directory" -version = "0.1.0" +version = "0.1.1" edition = "2021" +license = "MIT" +homepage = "https://github.com/marcfrederick/git-foreach" repository = "https://github.com/marcfrederick/git-foreach" [profile.dist] @@ -19,4 +21,6 @@ ci = "github" targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] pr-run-mode = "plan" install-updater = false -installers = ["shell"] +installers = ["shell", "powershell", "homebrew"] +tap = "marcfrederick/homebrew-tap" +publish-jobs = ["homebrew"]