Skip to content

Commit

Permalink
Added arm64 arch (#670)
Browse files Browse the repository at this point in the history
* Added arm64 arch

Signed-off-by: Fernando Ike <fike@maburix.com>

* Added missed files generated in release action into goreleaser
* Commented var env GOARCH in the e2e test

Signed-off-by: Fernando Ike <fike@maburix.com>
  • Loading branch information
fike authored Oct 20, 2021
1 parent 245f013 commit 693bf32
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 16 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
go-version: 1.17
- name: build
run: |
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o "tmp/horusec-linux" ./cmd/app/main.go
CGO_ENABLED=0 GOOS=darwin go build -a -installsuffix cgo -o "tmp/horusec-darwin" ./cmd/app/main.go
env GOOS=windows GOARCH=amd64 go build -o "tmp/horusec-win.exe" ./cmd/app/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -o "tmp/horusec-linux-x64" ./cmd/app/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o "tmp/horusec-linux-arm64" ./cmd/app/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -a -installsuffix cgo -o "tmp/horusec-darwin-x64" ./cmd/app/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -installsuffix cgo -o "tmp/horusec-darwin-arm64" ./cmd/app/main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -a -installsuffix cgo -o "tmp/horusec-win.exe" ./cmd/app/main.go
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ jobs:
cosign sign-blob -key=$COSIGN_KEY_LOCATION \
-output=./tmp/horusec_linux_x64_stand_alone.sig ./tmp/horusec_linux_x64_stand_alone
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags \
"-X 'github.com/ZupIT/horusec/config/dist.standAlone=true' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Version=${{ steps.updated-version.outputs.version }}' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Commit=${{ github.sha }}' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Date=${{ steps.date.outputs.date }}'" \
-o ./tmp/horusec_linux_arm64_stand_alone ./cmd/app/main.go
cosign sign-blob -key=$COSIGN_KEY_LOCATION \
-output=./tmp/horusec_linux_arm64_stand_alone.sig ./tmp/horusec_linux_arm64_stand_alone
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags \
"-X 'github.com/ZupIT/horusec/config/dist.standAlone=true' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Version=${{ steps.updated-version.outputs.version }}' \
Expand All @@ -111,6 +121,16 @@ jobs:
cosign sign-blob -key=$COSIGN_KEY_LOCATION \
-output=./tmp/horusec_windows_x64_stand_alone.exe.sig ./tmp/horusec_windows_x64_stand_alone.exe
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags \
"-X 'github.com/ZupIT/horusec/config/dist.standAlone=true' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Version=${{ steps.updated-version.outputs.version }}' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Commit=${{ github.sha }}' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Date=${{ steps.date.outputs.date }}'" \
-o ./tmp/horusec_windows_arm64_stand_alone.exe ./cmd/app/main.go
cosign sign-blob -key=$COSIGN_KEY_LOCATION \
-output=./tmp/horusec_windows_arm64_stand_alone.exe.sig ./tmp/horusec_windows_x64_stand_alone.exe
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags \
"-X 'github.com/ZupIT/horusec/config/dist.standAlone=true' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Version=${{ steps.updated-version.outputs.version }}' \
Expand All @@ -120,6 +140,16 @@ jobs:
cosign sign-blob -key=$COSIGN_KEY_LOCATION \
-output=./tmp/horusec_mac_x64_stand_alone.sig ./tmp/horusec_mac_x64_stand_alone
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags \
"-X 'github.com/ZupIT/horusec/config/dist.standAlone=true' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Version=${{ steps.updated-version.outputs.version }}' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Commit=${{ github.sha }}' \
-X 'github.com/ZupIT/horusec/cmd/app/version.Date=${{ steps.date.outputs.date }}'" \
-o ./tmp/horusec_mac_arm64_stand_alone ./cmd/app/main.go
cosign sign-blob -key=$COSIGN_KEY_LOCATION \
-output=./tmp/horusec_mac_arm64_stand_alone.sig ./tmp/horusec_mac_arm64_stand_alone
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}

Expand Down
61 changes: 50 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ADDLICENSE ?= addlicense
HORUSEC ?= horusec
DOCKER_COMPOSE ?= docker-compose
PATH_BINARY_BUILD_CLI ?= $(GOPATH)/bin
ARCH_ARM64 ?= arm64
ARCH_AMD64 ?= amd64
MAIN = ./cmd/app

fmt:
Expand Down Expand Up @@ -62,6 +64,31 @@ security:
build-dev:
$(GO) build -o horusec $(MAIN)

build-install-cli-linux-amd64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)" &> /dev/null
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH_AMD64) $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)"
horusec-linux-$(ARCH_AMD64) version

build-install-cli-linux-arm64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)" &> /dev/null
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH_ARM64) $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)"
horusec-linux-$(ARCH_ARM64) version

build-install-cli-darwin-amd64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)" &> /dev/null
CGO_ENABLED=0 GOOS=darwin GOARCH=$(ARCH_AMD64) $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)"
horusec-mac-$(ARCH_AMD64) version

build-install-cli-darwin-arm64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_ARM64)" &> /dev/null
CGO_ENABLED=0 GOOS=darwin GOARCH=$(ARCH_ARM64) $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_ARM64)" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_ARM64)"
horusec-mac-$(ARCH_ARM64) version


build-install-cli-linux:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux" &> /dev/null
CGO_ENABLED=0 GOOS=linux $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux" $(MAIN)
Expand All @@ -78,17 +105,29 @@ build-install-cli-windows:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" &> /dev/null
env GOOS=windows GOARCH=amd64 $(GO) build -o "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" $(MAIN)

build-install-stand-alone-cli-linux:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux" &> /dev/null
CGO_ENABLED=0 GOOS=linux $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux"
horusec-linux version

build-install-stand-alone-cli-darwin:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac" &> /dev/null
CGO_ENABLED=0 GOOS=darwin $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac"
horusec-mac version
build-install-stand-alone-cli-linux-amd64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)" &> /dev/null
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH_AMD64) $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux-amd64" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)"
horusec-linux-$(ARCH_AMD64) version

build-install-stand-alone-cli-linux-arm64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)" &> /dev/null
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH_ARM64) $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux-arm64" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)"
horusec-linux-$(ARCH_ARM64) version

build-install-stand-alone-cli-darwin-amd64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)" &> /dev/null
CGO_ENABLED=0 GOOS=darwin GOARCH=$(ARCH_ARM64) $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)"
horusec-mac-$(ARCH_AMD64) version

build-install-stand-alone-cli-darwin-arm64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_ARM64)" &> /dev/null
CGO_ENABLED=0 GOOS=darwin GOARCH=$(ARCH_ARM64) $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac-arm64"
horusec-mac-$(ARCH_ARM64) version

build-install-stand-alone-cli-windows:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" &> /dev/null
Expand Down
12 changes: 12 additions & 0 deletions deployments/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ horusecIdentifyOSLatest () {
if [ "$(uname -m)" = "x86_64" ]; then
echo "Installing Horusec for Linux x64"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/${VERSION_DOWNLOAD}/download/horusec_linux_x64"
elif [ "$(uname -m)" = "aarch64" ]; then
echo "Installing Horusec for Linux arm64"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/${VERSION_DOWNLOAD}/download/horusec_linux_arm64"
else
echo "Installing Horusec for Linux x86"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/${VERSION_DOWNLOAD}/download/horusec_linux_x86"
Expand All @@ -37,6 +40,9 @@ horusecIdentifyOSLatest () {
if [ "$(uname -m)" = "x86_64" ]; then
echo "Installing Horusec for Mac x64"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/${VERSION_DOWNLOAD}/download/horusec_mac_x64"
elif [ "$(uname -m)" = "arm64" ]; then
echo "Installing Horusec for Mac arm64"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/${VERSION_DOWNLOAD}/download/horusec_mac_arm64"
else
echo "Not enable Horusec to Mac x86"
exit 1
Expand All @@ -52,6 +58,9 @@ horusecIdentifyOSWithVersion () {
if [ "$(uname -m)" = "x86_64" ]; then
echo "Installing Horusec for Linux x64"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_linux_x64"
elif [ "$(uname -m)" = "aarch64" ]; then
echo "Installing Horusec for Linux x64"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_linux_arm64"
else
echo "Installing Horusec for Linux x86"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_linux_x64"
Expand All @@ -60,6 +69,9 @@ horusecIdentifyOSWithVersion () {
if [ "$(uname -m)" = "x86_64" ]; then
echo "Installing Horusec for Mac x64"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_mac_x64"
elif [ "$(uname -m)" = "x86_64" ]; then
echo "Installing Horusec for Mac M1"
URL_DOWNLOAD="https://github.com/ZupIT/horusec/releases/download/${VERSION_DOWNLOAD}/horusec_mac_arm64"
else
echo "Not enable Horusec to Mac x86"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion e2e/scan_languages/scan_languages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestMain(m *testing.M) {
cmd := exec.Command("go", "build", fmt.Sprintf("-o=%s", bin), path.Join(wd, "..", "..", "cmd", "app"))
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "GOOS=linux")
cmd.Env = append(cmd.Env, "GOARCH=amd64")
// cmd.Env = append(cmd.Env, "GOARCH=amd64")

defer func() {
if err := os.Remove(bin); err != nil {
Expand Down
13 changes: 12 additions & 1 deletion goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ builds:
- darwin
goarch:
- amd64
- arm64
- 386
changelog:
skip: true
Expand All @@ -39,6 +40,7 @@ archives:
replacements:
amd64: x64
386: x86
aarch64: arm64
darwin: mac
windows: win
checksum:
Expand All @@ -51,19 +53,26 @@ release:
- glob: ./tmp/horusec_linux_x86_stand_alone.sig
- glob: ./tmp/horusec_linux_x64_stand_alone
- glob: ./tmp/horusec_linux_x64_stand_alone.sig
- glob: ./tmp/horusec_linux_arm64_stand_alone
- glob: ./tmp/horusec_linux_arm64_stand_alone.sig
- glob: ./tmp/horusec_windows_x86_stand_alone.exe
- glob: ./tmp/horusec_windows_x86_stand_alone.exe.sig
- glob: ./tmp/horusec_windows_x64_stand_alone.exe
- glob: ./tmp/horusec_windows_x64_stand_alone.exe.sig
- glob: ./tmp/horusec_windows_arm64_stand_alone.exe
- glob: ./tmp/horusec_windows_arm64_stand_alone.exe.sig
- glob: ./tmp/horusec_mac_x64_stand_alone
- glob: ./tmp/horusec_mac_x64_stand_alone.sig
- glob: ./tmp/horusec_mac_arm64_stand_alone
- glob: ./tmp/horusec_mac_arm64_stand_alone.sig
nfpms:
- id: horusec
package_name: horusec
file_name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
replacements:
amd64: 64-bit
386: 32-bit
arm64: arm64
darwin: mac
windows: win
homepage: https://horusec.io/
Expand Down Expand Up @@ -91,7 +100,9 @@ docker_signs:
dockers:
- id: horusec
goos: linux
goarch: amd64
goarch:
- amd64
- arm64
ids:
- horusec
image_templates:
Expand Down

0 comments on commit 693bf32

Please sign in to comment.