-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·89 lines (72 loc) · 2.4 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·89 lines (72 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
set -e
export PATH="/opt/homebrew/bin:$PATH"
if [ -z "$1" ]; then
echo "Usage: ./release.sh <version> (e.g. ./release.sh 1.1.0)"
exit 1
fi
VERSION=$1
ZIP_FILE="NetSpeed.zip"
TAP_DIR="/opt/homebrew/Library/Taps/rahul230892/homebrew-tap"
CASK_FILE="${TAP_DIR}/Casks/netspeed.rb"
# 1. Check gh is installed and logged in
if ! command -v gh &> /dev/null; then
echo "GitHub CLI (gh) is not installed. Please run: brew install gh"
exit 1
fi
if ! gh auth status &> /dev/null; then
echo "You are not logged into GitHub CLI!"
echo "Please run: gh auth login"
exit 1
fi
# 2. Check if repo has a remote
if ! git remote get-url origin &> /dev/null; then
echo "No remote repository found. Creating one..."
# Create a public repo by default since Homebrew casks usually need public zip access
gh repo create macSpeed --public --source=. --remote=origin --push
fi
# 3. Build & Zip
echo "Building NetSpeed..."
./build.sh
# 4. Commit and push current changes
echo "Committing code..."
git add .
git diff-index --quiet HEAD || git commit -m "Bump version to $VERSION"
git push origin dev || git push origin main || git push origin master
# 5. Create GitHub Release
echo "Creating GitHub Release v${VERSION}..."
gh release create "v${VERSION}" "${ZIP_FILE}" --title "NetSpeed v${VERSION}" --notes "Automated release of v${VERSION}"
# 6. Update Homebrew Tap
echo "Updating Homebrew Tap..."
SHA256=$(shasum -a 256 "${ZIP_FILE}" | awk '{ print $1 }')
GITHUB_USERNAME=$(gh api user -q ".login")
cat <<EOF > "${CASK_FILE}"
cask "netspeed" do
version "${VERSION}"
sha256 "${SHA256}"
url "https://github.com/${GITHUB_USERNAME}/macSpeed/releases/download/v#{version}/NetSpeed.zip"
name "NetSpeed"
desc "macOS Network Speed Monitor"
homepage "https://github.com/${GITHUB_USERNAME}/macSpeed"
app "NetSpeed.app"
uninstall quit: "com.netspeed.app"
postflight do
system_command "xattr",
args: ["-cr", "#{appdir}/NetSpeed.app"],
sudo: false
end
caveats <<~EOS
If you get a "damaged" or "cannot be opened" error, run:
xattr -cr /Applications/NetSpeed.app
EOS
end
EOF
# 7. Push updated Tap
echo "Pushing Tap updates..."
cd "${TAP_DIR}"
git add Casks/netspeed.rb
git commit -m "Update netspeed to v${VERSION}"
git push
echo ""
echo "✅ Release v${VERSION} successfully published to GitHub and Homebrew!"
echo "Users can now update by running: brew reinstall netspeed"