Skip to content

Commit 439d658

Browse files
committed
add workflows
1 parent 3204b5b commit 439d658

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release Go Binary
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v4
20+
with:
21+
go-version: "1.21"
22+
23+
- name: Build binaries
24+
run: |
25+
BINARY_NAME="myapp"
26+
VERSION=${GITHUB_REF#refs/tags/}
27+
28+
# Build for Linux
29+
GOOS=linux GOARCH=amd64 go build -o "${BINARY_NAME}-linux-amd64"
30+
tar czf "${BINARY_NAME}-linux-amd64.tar.gz" "${BINARY_NAME}-linux-amd64"
31+
32+
# Build for macOS
33+
GOOS=darwin GOARCH=amd64 go build -o "${BINARY_NAME}-darwin-amd64"
34+
tar czf "${BINARY_NAME}-darwin-amd64.tar.gz" "${BINARY_NAME}-darwin-amd64"
35+
36+
# Build for Windows
37+
GOOS=windows GOARCH=amd64 go build -o "${BINARY_NAME}-windows-amd64.exe"
38+
zip "${BINARY_NAME}-windows-amd64.zip" "${BINARY_NAME}-windows-amd64.exe"
39+
40+
- name: Create Release
41+
uses: softprops/action-gh-release@v1
42+
with:
43+
files: |
44+
myapp-linux-amd64.tar.gz
45+
myapp-darwin-amd64.tar.gz
46+
myapp-windows-amd64.zip
47+
draft: false
48+
prerelease: false
49+
generate_release_notes: true

0 commit comments

Comments
 (0)