trigger: force workflow re-run with updated secrets #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to Homebrew | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| release: | |
| types: [published] | |
| jobs: | |
| publish-homebrew: | |
| runs-on: ubuntu-latest | |
| if: | | |
| github.event_name != 'pull_request' | |
| steps: | |
| - name: Set version info | |
| run: | | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| VERSION="${{ github.event.release.tag_name }}" | |
| TARBALL_URL="https://github.com/zero8dotdev/warp-cli/archive/refs/tags/${VERSION}.tar.gz" | |
| else | |
| VERSION="main" | |
| TARBALL_URL="https://github.com/zero8dotdev/warp-cli/archive/refs/heads/main.tar.gz" | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "TARBALL_URL=$TARBALL_URL" >> $GITHUB_ENV | |
| - name: Checkout warp-cli | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: zero8dotdev/warp-cli | |
| ref: ${{ env.VERSION == 'main' && 'main' || github.event.release.tag_name }} | |
| - name: Download release tarball | |
| run: | | |
| curl -L "${{ env.TARBALL_URL }}" -o warp.tar.gz | |
| SHA256=$(shasum -a 256 warp.tar.gz | cut -d' ' -f1) | |
| echo "SHA256=$SHA256" >> $GITHUB_ENV | |
| - name: Checkout homebrew-warp | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: zero8dotdev/homebrew-warp | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| path: homebrew-warp | |
| - name: Update formula | |
| run: | | |
| cat > homebrew-warp/Formula/warp.rb << 'EOF' | |
| class Warp < Formula | |
| desc "Beautiful CLI for Cloudflare WARP - Control your VPN from the terminal" | |
| homepage "https://github.com/zero8dotdev/warp-cli" | |
| url "${{ env.TARBALL_URL }}" | |
| sha256 "${{ env.SHA256 }}" | |
| license "MIT" | |
| head "https://github.com/zero8dotdev/warp-cli.git", branch: "main" | |
| depends_on "rust" => :build | |
| def install | |
| system "cargo", "build", "--release" | |
| bin.install "target/release/warp" | |
| end | |
| def caveats | |
| <<~EOS | |
| Cloudflare WARP app must be installed first: | |
| brew install --cask cloudflare-warp | |
| Or download from: https://apps.apple.com/app/cloudflare-warp/id1423210915 | |
| EOS | |
| end | |
| test do | |
| assert_match "warp", shell_output("#{bin}/warp --version") | |
| assert_match "Commands:", shell_output("#{bin}/warp --help") | |
| end | |
| end | |
| EOF | |
| - name: Commit and push | |
| working-directory: homebrew-warp | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git add Formula/warp.rb | |
| git commit -m "chore: bump warp to ${{ env.VERSION }}" | |
| git push | |
| - name: Comment on release | |
| if: github.event_name == 'release' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: '✅ Published to Homebrew!\n\nInstall with:\n```\nbrew tap zero8dotdev/warp\nbrew install warp\n```' | |
| }) |