ci-includes-yml/scripts/golang-build.sh

20 lines
427 B
Bash
Raw Normal View History

2024-03-31 10:02:00 -05:00
#!/usr/bin/env bash
#%%MULTILINE_YAML_START
#Build golang project
export GOPATH=/go
export PATH=$PATH:$GOPATH/bin
mkdir output
2024-04-05 09:00:14 -05:00
#go install
go mod download
2024-03-31 10:02:00 -05:00
# Check if go.mod contains "swag"
if grep -q "swag" go.mod; then
echo "Found 'swag' in go.mod. Running swag init..."
2024-04-05 09:04:17 -05:00
go install github.com/swaggo/swag/cmd/swag@latest
2024-03-31 10:02:00 -05:00
swag init
fi
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./output/main .