Skip to content

Commit 0ca427c

Browse files
committed
Add GitHub Actions workflow for automated releases
This workflow builds binaries for macOS (AMD64 and ARM64) and Linux AMD64 when commits are pushed to the main branch, and publishes them as GitHub releases.
1 parent ef0d1f4 commit 0ca427c

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
name: Build and Release
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v4
19+
with:
20+
go-version: '1.21'
21+
check-latest: true
22+
23+
- name: Get version
24+
id: get_version
25+
run: |
26+
VERSION=$(git describe --tags --always --dirty | sed 's/^v//')
27+
if [ -z "$VERSION" ]; then
28+
VERSION=$(date +'%Y%m%d%H%M%S')
29+
fi
30+
echo "VERSION=$VERSION" >> $GITHUB_ENV
31+
echo "version=$VERSION" >> $GITHUB_OUTPUT
32+
33+
- name: Build for macOS (AMD64)
34+
run: |
35+
GOOS=darwin GOARCH=amd64 go build -o mcp-darwin-amd64 -ldflags="-X 'main.Version=${{ env.VERSION }}'" ./...
36+
chmod +x mcp-darwin-amd64
37+
zip -j mcp-darwin-amd64.zip mcp-darwin-amd64
38+
39+
- name: Build for macOS (ARM64)
40+
run: |
41+
GOOS=darwin GOARCH=arm64 go build -o mcp-darwin-arm64 -ldflags="-X 'main.Version=${{ env.VERSION }}'" ./...
42+
chmod +x mcp-darwin-arm64
43+
zip -j mcp-darwin-arm64.zip mcp-darwin-arm64
44+
45+
- name: Build for Linux (AMD64)
46+
run: |
47+
GOOS=linux GOARCH=amd64 go build -o mcp-linux-amd64 -ldflags="-X 'main.Version=${{ env.VERSION }}'" ./...
48+
chmod +x mcp-linux-amd64
49+
zip -j mcp-linux-amd64.zip mcp-linux-amd64
50+
51+
- name: Create Release
52+
id: create_release
53+
uses: softprops/action-gh-release@v1
54+
with:
55+
name: Release ${{ env.VERSION }}
56+
tag_name: v${{ env.VERSION }}
57+
draft: false
58+
prerelease: false
59+
files: |
60+
mcp-darwin-amd64.zip
61+
mcp-darwin-arm64.zip
62+
mcp-linux-amd64.zip
63+
generate_release_notes: true
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)