diff --git a/.github/workflows/distribute.yml b/.github/workflows/distribute.yml index 17f82d9..1ac0c0e 100644 --- a/.github/workflows/distribute.yml +++ b/.github/workflows/distribute.yml @@ -233,3 +233,99 @@ jobs: else echo "::notice::AUR distribution completed." fi + + homebrew: + name: Homebrew tap (SamiAhmed7777/homebrew-triangles) + needs: version + runs-on: ubuntu-22.04 + env: + HOMEBREW_GITHUB_TOKEN: *** secrets.HOMEBREW_GITHUB_TOKEN }} + VERSION: ${{ needs.version.outputs.version }} + steps: + - name: Check HOMEBREW_GITHUB_TOKEN + run: | + if [ -z "$HOMEBREW_GITHUB_TOKEN" ]; then + echo "::warning::HOMEBREW_GITHUB_TOKEN secret not set — skipping Homebrew push. Add it at Settings → Secrets → Actions." + echo "::warning::Use a GitHub PAT with 'repo' scope for SamiAhmed7777/homebrew-triangles." + fi + + - name: Wait for release artifacts + if: env.HOMEBREW_GITHUB_TOKEN != '' + run: | + for i in {1..30}; do + URL="https://github.com/SamiAhmed7777/triangles_v5/releases/download/v${VERSION}/Cryptographic-Triangles-v${VERSION}-macos-arm64.dmg" + if curl -fsSL --head "$URL" >/dev/null 2>&1; then + echo "✓ Release .dmg available: $URL" + exit 0 + fi + echo " waiting for release v${VERSION}... ($i/30)" + sleep 20 + done + echo "::error::Release v${VERSION} macOS .dmg never became available" + exit 1 + + - name: Compute macOS .dmg SHA256 + if: env.HOMEBREW_GITHUB_TOKEN != '' + id: sha + run: | + curl -fsSL -o /tmp/triangles.dmg \ + "https://github.com/SamiAhmed7777/triangles_v5/releases/download/v${VERSION}/Cryptographic-Triangles-v${VERSION}-macos-arm64.dmg" + SHA=$(sha256sum /tmp/triangles.dmg | awk '{print $1}') + echo "sha=$SHA" >> $GITHUB_OUTPUT + echo "macOS .dmg SHA256: $SHA" + + - name: Clone homebrew-triangles + if: env.HOMEBREW_GITHUB_TOKEN != '' + run: | + git clone https://x-access-token:$HOMEBREW_GITHUB_TOKEN@github.com/SamiAhmed7777/homebrew-triangles.git /tmp/homebrew-triangles + cd /tmp/homebrew-triangles + git --no-pager log --oneline | head -3 + + - name: Update Formula and Cask + if: env.HOMEBREW_GITHUB_TOKEN != '' + env: + VERSION: ${{ needs.version.outputs.version }} + SHA: ${{ steps.sha.outputs.sha }} + run: | + cd /tmp/homebrew-triangles + # Update Casks/cryptographic-triangles.rb + python3 - <