Merge pull request #478 from ppc64le-cloud/dependabot/go_modules/gith… #1049
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go | |
on: | |
push: | |
tags: | |
- '*' | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
GO_VERSION: "1.20" | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v4 | |
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@v3 | |
with: | |
name: pvsadm-binaries | |
path: pvsadm-binaries.tar.gz | |
if-no-files-found: error |