nightly.yml

  1name: Nightly Release
  2
  3on:
  4  push:
  5    branches:
  6      - master
  7  workflow_dispatch:
  8
  9permissions:
 10  contents: write
 11
 12jobs:
 13  nightly:
 14    runs-on: macos-latest
 15    steps:
 16      - name: Checkout
 17        uses: actions/checkout@v6
 18        with:
 19          fetch-depth: 0
 20
 21      - name: Set up Go
 22        uses: actions/setup-go@v6
 23        with:
 24          go-version: "1.26.1"
 25
 26      - name: Set up Zig
 27        uses: goto-bus-stop/setup-zig@v2
 28
 29      - name: Get macOS SDK path
 30        id: macos_sdk
 31        run: echo "path=$(xcrun --show-sdk-path)" >> $GITHUB_OUTPUT
 32
 33      - name: Build with GoReleaser (snapshot)
 34        uses: goreleaser/goreleaser-action@v7
 35        with:
 36          version: latest
 37          args: release --snapshot --clean --config .goreleaser.nightly.yml
 38        env:
 39          SDK_PATH: ${{ steps.macos_sdk.outputs.path }}
 40
 41      - name: Delete existing nightly release
 42        env:
 43          GH_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
 44        run: |
 45          gh release delete nightlyv0 --yes --cleanup-tag || true
 46
 47      - name: Create nightly release
 48        env:
 49          GH_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
 50        run: |
 51          gh release create nightlyv0 dist/*.tar.gz dist/*.zip dist/checksums.txt \
 52            --title "Nightly Build ($(git rev-parse --short HEAD))" \
 53            --notes "This is an automated nightly build from the latest \`master\` commit ($(git rev-parse --short HEAD)).It may be unstable — use stable releases for production. You can install this version via Homebrew (`brew install floatpane/matcha/matcha-nightly`, or Snapcraft (`snap install matcha --beta`)" \
 54            --prerelease \
 55            --target master
 56
 57      - name: Update Homebrew tap
 58        env:
 59          GH_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
 60        run: |
 61          VERSION="nightly-$(git rev-parse --short HEAD)"
 62          DARWIN_AMD64_SHA=$(shasum -a 256 dist/matcha_nightly_darwin_amd64.tar.gz | cut -d ' ' -f 1)
 63          DARWIN_ARM64_SHA=$(shasum -a 256 dist/matcha_nightly_darwin_arm64.tar.gz | cut -d ' ' -f 1)
 64          LINUX_AMD64_SHA=$(shasum -a 256 dist/matcha_nightly_linux_amd64.tar.gz | cut -d ' ' -f 1)
 65          LINUX_ARM64_SHA=$(shasum -a 256 dist/matcha_nightly_linux_arm64.tar.gz | cut -d ' ' -f 1)
 66          BASE_URL="https://github.com/floatpane/matcha/releases/download/nightlyv0"
 67
 68          cat > /tmp/matcha-nightly.rb << EOF
 69          class MatchaNightly < Formula
 70            desc "A beautiful and functional email client for your terminal (nightly)"
 71            homepage "https://matcha.floatpane.com"
 72            version "$VERSION"
 73
 74            on_macos do
 75              if Hardware::CPU.intel?
 76                url "$BASE_URL/matcha_nightly_darwin_amd64.tar.gz"
 77                sha256 "$DARWIN_AMD64_SHA"
 78              else
 79                url "$BASE_URL/matcha_nightly_darwin_arm64.tar.gz"
 80                sha256 "$DARWIN_ARM64_SHA"
 81              end
 82            end
 83
 84            on_linux do
 85              if Hardware::CPU.intel?
 86                url "$BASE_URL/matcha_nightly_linux_amd64.tar.gz"
 87                sha256 "$LINUX_AMD64_SHA"
 88              else
 89                url "$BASE_URL/matcha_nightly_linux_arm64.tar.gz"
 90                sha256 "$LINUX_ARM64_SHA"
 91              end
 92            end
 93
 94            def install
 95              bin.install "matcha"
 96            end
 97
 98            test do
 99              system "#{bin}/matcha", "--version"
100            end
101          end
102          EOF
103
104          # Clone the tap repo and push the nightly formula
105          git clone "https://x-access-token:${GH_TOKEN}@github.com/floatpane/homebrew-matcha.git" /tmp/homebrew-matcha
106          cp /tmp/matcha-nightly.rb /tmp/homebrew-matcha/matcha-nightly.rb
107          cd /tmp/homebrew-matcha
108          git config user.name "goreleaserbot"
109          git config user.email "bot@goreleaser.com"
110          git add matcha-nightly.rb
111          git diff --cached --quiet || (git commit -m "Update matcha-nightly to $VERSION" && git push)
112
113  snapcraft:
114    runs-on: ${{ matrix.runner }}
115    needs: nightly
116    strategy:
117      matrix:
118        include:
119          - arch: amd64
120            runner: ubuntu-latest
121          - arch: arm64
122            runner: ubuntu-24.04-arm
123    steps:
124      - name: Checkout
125        uses: actions/checkout@v6
126        with:
127          fetch-depth: 0
128
129      - name: Install Snapcraft and LXD
130        run: |
131          sudo snap install snapcraft --classic
132          sudo snap install lxd
133          sudo lxd init --auto
134          sudo iptables -P FORWARD ACCEPT
135          sudo usermod -aG lxd $USER
136
137      - name: Build snap
138        run: sg lxd -c 'snapcraft pack --use-lxd --build-for=${{ matrix.arch }}'
139
140      - name: Upload snap
141        env:
142          SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
143        run: snapcraft upload --release=beta *.snap