Skip to content

Commit 22ef44f

Browse files
sovanesyanclaude
andcommitted
Add Homebrew packaging support
Add --version flag, GitHub Actions release workflow for building macOS binaries (arm64 + x86_64), and manual formula update script. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e1231e4 commit 22ef44f

3 files changed

Lines changed: 143 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
include:
16+
- os: macos-14
17+
target: aarch64-apple-darwin
18+
- os: macos-13
19+
target: x86_64-apple-darwin
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install Rust
25+
uses: dtolnay/rust-toolchain@stable
26+
with:
27+
targets: ${{ matrix.target }}
28+
29+
- name: Build
30+
run: cargo build --release --target ${{ matrix.target }}
31+
32+
- name: Package
33+
run: |
34+
cd target/${{ matrix.target }}/release
35+
tar czf ../../../calendarchy-${{ matrix.target }}.tar.gz calendarchy
36+
cd ../../..
37+
38+
- name: Upload artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: calendarchy-${{ matrix.target }}
42+
path: calendarchy-${{ matrix.target }}.tar.gz
43+
44+
release:
45+
needs: build
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Download artifacts
51+
uses: actions/download-artifact@v4
52+
with:
53+
merge-multiple: true
54+
55+
- name: Compute SHA256 hashes
56+
id: hashes
57+
run: |
58+
echo "arm64_sha256=$(sha256sum calendarchy-aarch64-apple-darwin.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
59+
echo "x86_64_sha256=$(sha256sum calendarchy-x86_64-apple-darwin.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
60+
61+
- name: Create GitHub Release
62+
uses: softprops/action-gh-release@v2
63+
with:
64+
generate_release_notes: true
65+
files: |
66+
calendarchy-aarch64-apple-darwin.tar.gz
67+
calendarchy-x86_64-apple-darwin.tar.gz
68+
69+
- name: Update Homebrew formula
70+
env:
71+
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
72+
run: |
73+
VERSION="${GITHUB_REF_NAME#v}"
74+
ARM64_SHA="${{ steps.hashes.outputs.arm64_sha256 }}"
75+
X86_64_SHA="${{ steps.hashes.outputs.x86_64_sha256 }}"
76+
77+
cat > /tmp/calendarchy.rb << FORMULA
78+
class Calendarchy < Formula
79+
desc "Terminal calendar app for Google Calendar and iCloud"
80+
homepage "https://github.com/sovanesyan/calendarchy"
81+
version "${VERSION}"
82+
license "MIT"
83+
84+
on_macos do
85+
on_arm do
86+
url "https://github.com/sovanesyan/calendarchy/releases/download/v#{version}/calendarchy-aarch64-apple-darwin.tar.gz"
87+
sha256 "${ARM64_SHA}"
88+
end
89+
on_intel do
90+
url "https://github.com/sovanesyan/calendarchy/releases/download/v#{version}/calendarchy-x86_64-apple-darwin.tar.gz"
91+
sha256 "${X86_64_SHA}"
92+
end
93+
end
94+
95+
def install
96+
bin.install "calendarchy"
97+
end
98+
99+
test do
100+
assert_match version.to_s, shell_output("#{bin}/calendarchy --version")
101+
end
102+
end
103+
FORMULA
104+
105+
# Clone tap repo, update formula, push
106+
git clone "https://x-access-token:${TAP_TOKEN}@github.com/sovanesyan/homebrew-calendarchy.git" /tmp/tap
107+
mkdir -p /tmp/tap/Formula
108+
cp /tmp/calendarchy.rb /tmp/tap/Formula/calendarchy.rb
109+
cd /tmp/tap
110+
git config user.name "github-actions[bot]"
111+
git config user.email "github-actions[bot]@users.noreply.github.com"
112+
git add Formula/calendarchy.rb
113+
git commit -m "Update calendarchy to ${VERSION}" || exit 0
114+
git push

scripts/update-formula.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
# Manual fallback: compute SHA256 hashes for a release and print formula values.
3+
# Usage: ./scripts/update-formula.sh v0.1.0
4+
5+
set -euo pipefail
6+
7+
VERSION="${1:?Usage: $0 <tag, e.g. v0.1.0>}"
8+
REPO="sovanesyan/calendarchy"
9+
BASE_URL="https://github.com/${REPO}/releases/download/${VERSION}"
10+
11+
ARM64_URL="${BASE_URL}/calendarchy-aarch64-apple-darwin.tar.gz"
12+
X86_64_URL="${BASE_URL}/calendarchy-x86_64-apple-darwin.tar.gz"
13+
14+
echo "Downloading arm64 tarball..."
15+
ARM64_SHA=$(curl -sL "$ARM64_URL" | shasum -a 256 | cut -d' ' -f1)
16+
17+
echo "Downloading x86_64 tarball..."
18+
X86_64_SHA=$(curl -sL "$X86_64_URL" | shasum -a 256 | cut -d' ' -f1)
19+
20+
echo ""
21+
echo "=== Update Formula/calendarchy.rb with these values ==="
22+
echo "version \"${VERSION#v}\""
23+
echo "arm64 sha256: \"${ARM64_SHA}\""
24+
echo "x86_64 sha256: \"${X86_64_SHA}\""

src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ enum AsyncMessage {
5959

6060
#[tokio::main]
6161
async fn main() -> Result<(), Box<dyn std::error::Error>> {
62+
if std::env::args().any(|a| a == "--version" || a == "-V") {
63+
println!("calendarchy {}", env!("CARGO_PKG_VERSION"));
64+
return Ok(());
65+
}
66+
6267
let mut app = App::new();
6368

6469
// Load config

0 commit comments

Comments
 (0)