Skip to content

Commit 786e176

Browse files
committed
Update release workflow for multi-platform binaries and install script
1 parent 3548ae8 commit 786e176

2 files changed

Lines changed: 49 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Release Go Binary
1+
name: Build and Release Go Binaries
22

33
on:
44
push:
@@ -16,13 +16,24 @@ jobs:
1616
with:
1717
go-version: '1.21'
1818

19-
- name: Build binary
19+
- name: Build binaries for all platforms
2020
run: |
21-
go build -o commit-msg-go commit-msg.go
21+
GOOS=linux GOARCH=amd64 go build -o commit-msg-go-linux-amd64 commit-msg.go
22+
GOOS=linux GOARCH=arm64 go build -o commit-msg-go-linux-arm64 commit-msg.go
23+
GOOS=darwin GOARCH=amd64 go build -o commit-msg-go-darwin-amd64 commit-msg.go
24+
GOOS=darwin GOARCH=arm64 go build -o commit-msg-go-darwin-arm64 commit-msg.go
25+
GOOS=windows GOARCH=amd64 go build -o commit-msg-go-windows-amd64.exe commit-msg.go
26+
GOOS=windows GOARCH=arm64 go build -o commit-msg-go-windows-arm64.exe commit-msg.go
2227
23-
- name: Upload Release Asset
28+
- name: Upload Release Assets
2429
uses: softprops/action-gh-release@v2
2530
with:
26-
files: commit-msg-go
31+
files: |
32+
commit-msg-go-linux-amd64
33+
commit-msg-go-linux-arm64
34+
commit-msg-go-darwin-amd64
35+
commit-msg-go-darwin-arm64
36+
commit-msg-go-windows-amd64.exe
37+
commit-msg-go-windows-arm64.exe
2738
env:
2839
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

install.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@ set -e
44
HOOK_PATH=".git/hooks/commit-msg"
55
BIN_PATH=".git/hooks/commit-msg-go"
66
HOOK_URL="https://raw.githubusercontent.com/inem/dotdotdot/main/_git/hooks/commit-msg"
7-
BIN_URL="https://github.com/inem/dotdotdot/releases/latest/download/commit-msg-go"
7+
8+
# Detect OS and ARCH
9+
OS=$(uname | tr '[:upper:]' '[:lower:]')
10+
ARCH=$(uname -m)
11+
12+
case "$ARCH" in
13+
x86_64|amd64)
14+
ARCH=amd64
15+
;;
16+
arm64|aarch64)
17+
ARCH=arm64
18+
;;
19+
*)
20+
echo "Unsupported architecture: $ARCH"
21+
exit 1
22+
;;
23+
esac
24+
25+
case "$OS" in
26+
linux|darwin)
27+
;;
28+
msys*|cygwin*|mingw*|windowsnt|windows)
29+
OS=windows
30+
BIN_PATH=".git/hooks/commit-msg-go.exe"
31+
;;
32+
*)
33+
echo "Unsupported OS: $OS"
34+
exit 1
35+
;;
36+
esac
37+
38+
BIN_URL="https://github.com/inem/dotdotdot/releases/latest/download/commit-msg-go-${OS}-${ARCH}"
839

940
if [ ! -d .git/hooks ]; then
1041
echo "Error: .git/hooks directory not found. Please run this script from the root of your git repository."
@@ -16,7 +47,7 @@ curl -fsSL "$HOOK_URL" -o "$HOOK_PATH"
1647
chmod +x "$HOOK_PATH"
1748
echo "Hook installed to $HOOK_PATH"
1849

19-
echo "Downloading Go binary from GitHub Releases..."
50+
echo "Downloading Go binary for $OS-$ARCH..."
2051
curl -fsSL "$BIN_URL" -o "$BIN_PATH"
2152
chmod +x "$BIN_PATH"
2253
echo "Binary installed to $BIN_PATH"

0 commit comments

Comments
 (0)