Merge pull request #711 from ppc64le-cloud/dependabot/go_modules/gith… #1612
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 ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- run: go version | |
- 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 |