diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index e7ff679e..a316dbda 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -46,7 +46,7 @@ jobs: git tag -d nightly || true git tag nightly kokai release --no-emoji --add-links github:commits,issues --ref nightly >"CHANGELOG.md" - - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }} + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) && github.repository == 'KomoCorp/komorebi-for-mac' }} shell: bash run: | gh release delete nightly --yes || true @@ -59,3 +59,34 @@ jobs: --notes-file CHANGELOG.md \ komorebi-nightly-aarch64-apple-darwin.zip \ checksums.txt + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) && github.repository == 'KomoCorp/komorebi-for-mac' }} + shell: bash + run: | + ASSET_ID=$(gh api repos/${{ github.repository }}/releases/tags/nightly \ + --jq '.assets[] | select(.name=="komorebi-nightly-aarch64-apple-darwin.zip") | .id') + + SHA256=$(cat checksums.txt | cut -d' ' -f1) + + echo "ASSET_ID=$ASSET_ID" >> $GITHUB_ENV + echo "SHA256=$SHA256" >> $GITHUB_ENV + + echo "Asset ID: $ASSET_ID" + echo "SHA256: $SHA256" + - if: ${{ github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) && github.repository == 'KomoCorp/komorebi-for-mac' }} + shell: bash + env: + GIT_AUTHOR_NAME: "JeezyBot" + GIT_AUTHOR_EMAIL: "lgug2z@fastmail.com" + GIT_COMMITTER_NAME: "JeezyBot" + GIT_COMMITTER_EMAIL: "lgug2z@fastmail.com" + run: | + sed "s/REPLACE_ASSET_ID/$ASSET_ID/g; s/REPLACE_SHA_256/$SHA256/g" formula.template.rb > komorebi-for-mac-nightly.rb + cat komorebi-for-mac-nightly.rb + gh release upload nightly komorebi-for-mac-nightly.rb + + git clone https://x-access-token:${{ secrets.GH_USER_API_TOKEN }}@github.com/LGUG2Z/homebrew-tap + cd homebrew-tap + cp ../komorebi-for-mac-nightly.rb ./Formula + git add . + git commit -m "Update komorebi-for-mac-nightly to $ASSET_ID ($SHA256)" + git push diff --git a/formula.template.rb b/formula.template.rb new file mode 100644 index 00000000..118951e6 --- /dev/null +++ b/formula.template.rb @@ -0,0 +1,30 @@ +class KomorebiForMacNightly < Formula + desc "Tiling window manager for macOS (nightly build)" + homepage "https://github.com/KomoCorp/komorebi-for-mac" + url "https://api.github.com/repos/KomoCorp/komorebi-for-mac/releases/assets/REPLACE_ASSET_ID", + headers: [ + "Accept: application/octet-stream", + "X-GitHub-Api-Version: 2022-11-28", + "Authorization: bearer #{ENV.fetch("HOMEBREW_GITHUB_API_TOKEN")}", + ] + version "nightly" + sha256 "REPLACE_SHA_256" + license "Komorebi License 2.0.0" + + def install + bin.install Dir["*"] + end + + def caveats + <<~EOS + This formula requires access to a private GitHub repository. + Make sure you have set your GitHub token: + + export HOMEBREW_GITHUB_API_TOKEN=your_token_here + EOS + end + + test do + system "#{bin}/komorebi", "--help" + end +end