Skip to content

Commit

Permalink
feat(plugin): Add cross-platform support (#175)
Browse files Browse the repository at this point in the history
* feat(plugin): Add cross-platform support

* address comments

* update selectors
  • Loading branch information
simar7 authored Jun 15, 2024
1 parent 42ecf65 commit b85343c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Release

on:
workflow_dispatch:
push:
tags:
- "v*"
Expand All @@ -11,14 +12,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Build
run: make build
- name: Bundle
run: make bundle

- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
trivy-aws.tar.gz
trivy-aws-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
test:
go test -race ./...

.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags "-s -w" -o trivy-aws ./cmd/trivy-aws/main.go
PLATFORMS = linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64
OUTPUTS = $(patsubst %,%/trivy-aws,$(PLATFORMS))
build: $(OUTPUTS)
# os/arch/trivy-aws
%/trivy-aws:
@mkdir -p $(dir $@); \
GOOS=$(word 1,$(subst /, ,$*)); \
GOARCH=$(word 2,$(subst /, ,$*)); \
CGO_ENABLED=0 GOOS=$$GOOS GOARCH=$$GOARCH go build -ldflags "-s -w" -o trivy-aws-$$GOOS-$$GOARCH ./cmd/trivy-aws/main.go; \
tar -cvzf trivy-aws-$$GOOS-$$GOARCH.tar.gz plugin.yaml trivy-aws-$$GOOS-$$GOARCH LICENSE

.PHONY: test-no-localstack
test-no-localstack:
Expand All @@ -18,8 +25,4 @@ quality:
.PHONY: update-aws-deps
update-aws-deps:
@grep aws-sdk-go-v2 go.mod | grep -v '// indirect' | sed 's/^[ [[:blank:]]]*//g' | sed 's/[[:space:]]v.*//g' | xargs go get
@go mod tidy

.PHONY: bundle
bundle:
tar -cvzf trivy-aws.tar.gz plugin.yaml trivy-aws LICENSE
@go mod tidy
29 changes: 26 additions & 3 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,34 @@ name: aws-scan
repository: github.com/aquasecurity/trivy-aws
maintainer: aquasecurity
summary: Trivy AWS Cloud scanning plugin
version: "0.10.0"
version: "0.11.0"
usage: AWS Trivy plugin
description: |-
Trivy AWS plugin for the Trivy security scanner
https://github.com/aquasecurity/trivy-aws
platforms:
- uri: https://github.com/aquasecurity/trivy-aws/releases/download/v0.10.0/trivy-aws.tar.gz
bin: ./trivy-aws
- selector:
os: darwin
arch: amd64
uri: https://github.com/aquasecurity/trivy-aws/releases/download/v0.11.0/trivy-aws-darwin-amd64.tar.gz
bin: ./trivy-aws-darwin-amd64
- selector:
os: darwin
arch: arm64
uri: https://github.com/aquasecurity/trivy-aws/releases/download/v0.11.0/trivy-aws-darwin-arm64.tar.gz
bin: ./trivy-aws-darwin-arm64
- selector:
os: linux
arch: amd64
uri: https://github.com/aquasecurity/trivy-aws/releases/download/v0.11.0/trivy-aws-linux-amd64.tar.gz
bin: ./trivy-aws-linux-amd64
- selector:
os: linux
arch: arm64
uri: https://github.com/aquasecurity/trivy-aws/releases/download/v0.11.0/trivy-aws-linux-arm64.tar.gz
bin: ./trivy-aws-linux-arm64
- selector:
os: windows
arch: amd64
uri: https://github.com/aquasecurity/trivy-aws/releases/download/v0.11.0/trivy-aws-windows-amd64.tar.gz
bin: ./trivy-aws-windows-amd64

0 comments on commit b85343c

Please sign in to comment.