-
Notifications
You must be signed in to change notification settings - Fork 1
31 lines (29 loc) · 1.03 KB
/
ci.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
name: CI
on: [push, pull_request]
jobs:
build_multi_platform:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: "1.20"
- name: Build for multi-platform
run: |
set -xeu
DIST=dist
mkdir $DIST
# (from: https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-16-04)
platforms=("linux/amd64" "darwin/amd64" "linux/arm" "windows/amd64")
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
export GOOS=${platform_split[0]}
export GOARCH=${platform_split[1]}
[ $GOOS = "windows" ] && EXTENSION='.exe' || EXTENSION=''
BUILD_PATH=piping-sshd-$GOOS-$GOARCH
mkdir $BUILD_PATH
# Build
CGO_ENABLED=0 go build -o "${BUILD_PATH}/piping-sshd${EXTENSION}" main/main.go
done