forked from ppc64le-cloud/pvsadm
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (64 loc) · 1.89 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Go
on:
push:
tags:
- '*'
branches: [ main ]
pull_request:
branches: [ main ]
env:
GO_VERSION: "1.21"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
- run: go version
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Go Formatting
run: |
unformatted=$(gofmt -l -e -d .)
if [[ ! -z "${unformatted}" ]]; then
echo "fix the formatting...."
echo "${unformatted}"
exit 1
fi
- name: Go Vet
run: |
go vet ./...
- name: Build
run: |
mkdir -p bin
# workaround for https://github.com/actions/checkout/issues/290
git fetch --tags --force --prune
VERSION=$(git describe --tags --dirty)
STATIC_FLAG='-w -extldflags "-static"'
for platform in darwin/amd64 darwin/arm64 linux/amd64 linux/ppc64le windows/amd64
do
os_name=$(echo "$platform" | cut -d "/" -f 1)
arch=$(echo "$platform" | cut -d "/" -f 2)
CGO_ENABLED=0 GOOS=${os_name} GOARCH=${arch} go build -a -tags netgo -ldflags "-X github.com/ppc64le-cloud/pvsadm/pkg/version.Version=${VERSION} ${STATIC_FLAG}" -o bin/pvsadm-${os_name}-${arch} .
done
tar -czvf pvsadm-binaries.tar.gz bin/
- name: Test
run: make unit
- uses: actions/upload-artifact@v4
with:
name: pvsadm-binaries
path: pvsadm-binaries.tar.gz
if-no-files-found: error