-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (41 loc) · 1.37 KB
/
go.yml
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
name: Build and Release Multi-Arch Go Application
on:
workflow_dispatch:
push:
# Publish semver tags as releases.
tags: ['*.*']
jobs:
build:
name: Multi-Platform Build
runs-on: [ubuntu-latest, windows-latest, macos-latest]
strategy:
matrix:
arch: [amd64, arm64, 386] # Architectures: 64-bit, ARM 64-bit, 32-bit
steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Go environment
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.23" # Replace with the desired Go version
# Step 3: Build for the specific OS and architecture
- name: Build for ${{ matrix.os }} ${{ matrix.arch }}
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: |
mkdir -p build/
OUTPUT_NAME="myapp-${{ matrix.os }}-${{ matrix.arch }}"
if [ "${{ matrix.os }}" == "windows" ]; then OUTPUT_NAME="$OUTPUT_NAME.exe"; fi
go build -o build/$OUTPUT_NAME .
echo "Built $OUTPUT_NAME"
# Step 4: Upload all built binaries as release assets
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./build/
asset_name: build
asset_content_type: application/octet-stream