From c0a7b3925364cb59de828e82fd88d5459f5469f0 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Sun, 19 Mar 2023 01:20:41 +0000 Subject: [PATCH] ci: build for multiple os/arch Signed-off-by: Ramkumar Chinchani --- .github/workflows/ci.yaml | 12 ++++++++---- Makefile | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 30d92db..8291a63 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,6 +17,8 @@ jobs: strategy: matrix: go-version: ["1.20"] + os: ["linux", "darwin"] + arch: ["amd64", "arm64"] steps: - uses: actions/checkout@v3 - uses: benjlevesque/short-sha@v2.1 @@ -27,7 +29,7 @@ jobs: go-version: ${{ matrix.go-version }} - name: build run: | - make binary + make binary OS=${{ matrix.os }} ARCH=${{ matrix.arch }} - name: lint run: | make lint @@ -36,7 +38,7 @@ jobs: - uses: actions/cache/save@v3 if: always() with: - path: bin/sbom + file: bin/stacker-sbom-* key: ${{ github.sha }} release: if: github.event_name == 'release' && github.event.action== 'published' @@ -44,6 +46,8 @@ jobs: strategy: matrix: go-version: ["1.20"] + os: ["linux", "darwin"] + arch: ["amd64", "arm64"] steps: - uses: actions/checkout@v3 - name: Set up golang ${{ matrix.go-version }} @@ -52,7 +56,7 @@ jobs: go-version: ${{ matrix.go-version }} - name: build run: | - make binary RELEASE_TAG=${{ github.event.release.tag_name }} + make binary RELEASE_TAG=${{ github.event.release.tag_name }} OS=${{ matrix.os }} ARCH=${{ matrix.arch }} - uses: actions/cache/save@v3 if: always() with: @@ -62,7 +66,7 @@ jobs: uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: bin/sbom + file: bin/stacker-sbom-* tag: ${{ github.ref }} overwrite: true file_glob: true diff --git a/Makefile b/Makefile index 43b0608..b512f7d 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,10 @@ TOOLSDIR := $(shell pwd)/hack/tools GOLINTER := $(TOOLSDIR)/bin/golangci-lint GOLINTER_VERSION := v1.51.2 +BINARY := stacker-sbom +OS ?= linux +ARCH ?= amd64 + .PHONY: all all: binary lint @@ -18,7 +22,7 @@ $(GOLINTER): .PHONY: binary binary: mkdir -p ${BINDIR} - go build -v -trimpath -ldflags "-X stackerbuild.io/sbom/pkg/build.ReleaseTag=${RELEASE_TAG} -X stackerbuild.io/sbom/pkg/build.Commit=${COMMIT} -s -w" -o ${BINDIR}/sbom ./cmd/sbom/... + GOOS=${OS} GOARCH=${ARCH} go build -v -trimpath -ldflags "-X stackerbuild.io/sbom/pkg/build.ReleaseTag=${RELEASE_TAG} -X stackerbuild.io/sbom/pkg/build.Commit=${COMMIT} -s -w" -o ${BINDIR}/${BINARY}-${OS}-${ARCH} ./cmd/sbom/... .PHONY: lint lint: ./golangcilint.yaml $(GOLINTER)