Skip to content

Commit

Permalink
adds build
Browse files Browse the repository at this point in the history
  • Loading branch information
bentohset committed Mar 30, 2024
1 parent f19ef86 commit bedc1cf
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# App data files
*.log
hosts.yaml
hosts.yaml

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.DS_STORE

# Ignore dist folder
dist/
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
BUILD_VERSION = v1.0.0
BINARY_NAME = gnm

DIST_PATH=./dist
LD_FLAGS = -ldflags "-X main.Version=$(BUILD_VERSION)"

## build: create binary in ./dist folder for your current platform. Use this option if you build it for personal use.
.PHONY: build
build:
@rm -rf ./$(DIST_PATH)/*
@echo 'Building'
go build ${LD_FLAGS} -o $(DIST_PATH)/$(BINARY_NAME) ./cmd/gnm/*.go

## clean
.PHONY: clean
clean:
@go clean
@rm -rf ./$(DIST_PATH)/*

.PHONY: release
release:
@rm -rf ./$(DIST_PATH)/*

# Build for mac
go build ${LD_FLAGS} -o $(DIST_PATH)/mac64-$(BINARY_NAME) ./cmd/gnm/*.go
@tar czvf ./dist/${BINARY_NAME}-mac64-${BUILD_VERSION}.tar.gz ./dist/mac64-${BINARY_NAME}

# Build for arm
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${LD_FLAGS} -o $(DIST_PATH)/arm64-$(BINARY_NAME) ./cmd/gnm/*.go
@tar czvf ./dist/${BINARY_NAME}-arm64-${BUILD_VERSION}.tar.gz ./dist/arm64-${BINARY_NAME}

# Build for linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${LD_FLAGS} -o $(DIST_PATH)/linux64-$(BINARY_NAME) ./cmd/gnm/*.go
@tar czvf ./dist/${BINARY_NAME}-linux64-${BUILD_VERSION}.tar.gz ./dist/linux64-${BINARY_NAME}

# Build for windows
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ${LD_FLAGS} -o $(DIST_PATH)/win64-$(BINARY_NAME) ./cmd/gnm/*.go
@tar czvf ./dist/${BINARY_NAME}-win64-${BUILD_VERSION}.tar.gz ./dist/win64-${BINARY_NAME}

@rm -rf ./$(DIST_PATH)/*-$(BINARY_NAME)

0 comments on commit bedc1cf

Please sign in to comment.