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: Set up libpcsclite for Linux cross-compilation
30 run: |
31 PCSC_DIR="$RUNNER_TEMP/pcsclite"
32 mkdir -p "$PCSC_DIR/include" "$PCSC_DIR/lib/pkgconfig"
33
34 # Download pcsc-lite headers from upstream
35 PCSC_URL="https://raw.githubusercontent.com/LudovicRousseau/PCSC/master/src/PCSC"
36 for header in winscard.h wintypes.h; do
37 curl -fsSL "$PCSC_URL/$header" -o "$PCSC_DIR/include/$header"
38 done
39 # pcsclite.h is generated from pcsclite.h.in — download and substitute the version placeholder
40 curl -fsSL "$PCSC_URL/pcsclite.h.in" -o "$PCSC_DIR/include/pcsclite.h"
41 sed -i '' 's/@VERSION@/1.9.0/' "$PCSC_DIR/include/pcsclite.h"
42
43 # Create pkg-config file (headers-only, no library needed for cross-compilation)
44 cat > "$PCSC_DIR/lib/pkgconfig/libpcsclite.pc" << EOF
45 Name: libpcsclite
46 Description: PC/SC Lite
47 Version: 1.9.0
48 Cflags: -I$PCSC_DIR/include
49 EOF
50
51 echo "PKG_CONFIG_PATH=$PCSC_DIR/lib/pkgconfig" >> $GITHUB_ENV
52
53 - name: Get macOS SDK path
54 id: macos_sdk
55 run: echo "path=$(xcrun --show-sdk-path)" >> $GITHUB_OUTPUT
56
57 - name: Build with GoReleaser (snapshot)
58 uses: goreleaser/goreleaser-action@v7
59 with:
60 version: latest
61 args: release --snapshot --clean --config .goreleaser.nightly.yml
62 env:
63 SDK_PATH: ${{ steps.macos_sdk.outputs.path }}
64
65 - name: Delete existing nightly release
66 env:
67 GH_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
68 run: |
69 gh release delete nightlyv0 --yes --cleanup-tag || true
70
71 - name: Generate release notes
72 id: notes
73 env:
74 GH_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
75 run: |
76 SHORT_SHA="$(git rev-parse --short HEAD)"
77 LATEST_TAG="$(git describe --tags --abbrev=0 --exclude='nightlyv*' 2>/dev/null || echo '')"
78
79 {
80 echo 'BODY<<EOF'
81 echo "> [!WARNING]"
82 echo "> This is an automated nightly build from the latest \`master\` commit (\`$SHORT_SHA\`). It may be unstable — use stable releases for production."
83 echo ""
84 echo "### Install"
85 echo ""
86 echo "- **Homebrew:** \`brew install floatpane/matcha/matcha-nightly\`"
87 echo "- **Snapcraft:** \`snap install matcha --beta\`"
88
89 if [ -n "$LATEST_TAG" ]; then
90 echo ""
91 echo "### Changes since $LATEST_TAG"
92 echo ""
93 git log --pretty=format:"- %s (%h)" "$LATEST_TAG..HEAD"
94 echo ""
95 fi
96
97 echo 'EOF'
98 } >> "$GITHUB_OUTPUT"
99
100 - name: Create nightly release
101 env:
102 GH_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
103 run: |
104 gh release create nightlyv0 dist/*.tar.gz dist/*.zip dist/checksums.txt \
105 --title "Nightly Build ($(git rev-parse --short HEAD))" \
106 --notes "${{ steps.notes.outputs.BODY }}" \
107 --prerelease \
108 --target master
109
110 - name: Update Homebrew tap
111 env:
112 GH_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
113 run: |
114 VERSION="nightly-$(git rev-parse --short HEAD)"
115 DARWIN_AMD64_SHA=$(shasum -a 256 dist/matcha_nightly_darwin_amd64.tar.gz | cut -d ' ' -f 1)
116 DARWIN_ARM64_SHA=$(shasum -a 256 dist/matcha_nightly_darwin_arm64.tar.gz | cut -d ' ' -f 1)
117 LINUX_AMD64_SHA=$(shasum -a 256 dist/matcha_nightly_linux_amd64.tar.gz | cut -d ' ' -f 1)
118 LINUX_ARM64_SHA=$(shasum -a 256 dist/matcha_nightly_linux_arm64.tar.gz | cut -d ' ' -f 1)
119 BASE_URL="https://github.com/floatpane/matcha/releases/download/nightlyv0"
120
121 cat > /tmp/matcha-nightly.rb << EOF
122 class MatchaNightly < Formula
123 desc "A beautiful and functional email client for your terminal (nightly)"
124 homepage "https://matcha.floatpane.com"
125 version "$VERSION"
126
127 on_macos do
128 if Hardware::CPU.intel?
129 url "$BASE_URL/matcha_nightly_darwin_amd64.tar.gz"
130 sha256 "$DARWIN_AMD64_SHA"
131 else
132 url "$BASE_URL/matcha_nightly_darwin_arm64.tar.gz"
133 sha256 "$DARWIN_ARM64_SHA"
134 end
135 end
136
137 on_linux do
138 if Hardware::CPU.intel?
139 url "$BASE_URL/matcha_nightly_linux_amd64.tar.gz"
140 sha256 "$LINUX_AMD64_SHA"
141 else
142 url "$BASE_URL/matcha_nightly_linux_arm64.tar.gz"
143 sha256 "$LINUX_ARM64_SHA"
144 end
145 end
146
147 def install
148 bin.install "matcha"
149 end
150
151 test do
152 system "#{bin}/matcha", "--version"
153 end
154 end
155 EOF
156
157 # Clone the tap repo and push the nightly formula
158 git clone "https://x-access-token:${GH_TOKEN}@github.com/floatpane/homebrew-matcha.git" /tmp/homebrew-matcha
159 cp /tmp/matcha-nightly.rb /tmp/homebrew-matcha/matcha-nightly.rb
160 cd /tmp/homebrew-matcha
161 git config user.name "goreleaserbot"
162 git config user.email "bot@goreleaser.com"
163 git add matcha-nightly.rb
164 git diff --cached --quiet || (git commit -m "Update matcha-nightly to $VERSION" && git push)
165
166 snapcraft:
167 runs-on: ${{ matrix.runner }}
168 needs: nightly
169 strategy:
170 matrix:
171 include:
172 - arch: amd64
173 runner: ubuntu-latest
174 - arch: arm64
175 runner: ubuntu-24.04-arm
176 steps:
177 - name: Checkout
178 uses: actions/checkout@v6
179 with:
180 fetch-depth: 0
181
182 - name: Install Snapcraft and LXD
183 run: |
184 sudo snap install snapcraft --classic
185 sudo snap install lxd
186 sudo lxd init --auto
187 sudo iptables -P FORWARD ACCEPT
188 sudo usermod -aG lxd $USER
189
190 - name: Build snap
191 run: sg lxd -c 'snapcraft pack --use-lxd --build-for=${{ matrix.arch }}'
192
193 - name: Upload snap
194 env:
195 SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
196 run: snapcraft upload --release=beta *.snap