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