Skip to content

Commit

Permalink
ci: build for multiple os/arch
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
  • Loading branch information
rchincha committed Mar 19, 2023
1 parent 3aca35c commit c0a7b39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -36,14 +38,16 @@ 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'
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.20"]
os: ["linux", "darwin"]
arch: ["amd64", "arm64"]
steps:
- uses: actions/checkout@v3
- name: Set up golang ${{ matrix.go-version }}
Expand All @@ -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:
Expand All @@ -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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit c0a7b39

Please # to comment.