Skip to content

Commit

Permalink
Makefile: add targets for macOS-arm64 and linux-amd64
Browse files Browse the repository at this point in the history
  • Loading branch information
toru committed Aug 24, 2024
1 parent d2eb508 commit 7647f2c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
VERSION ?= dev
BINARY_NAME = puff
RELEASE_DIR = dist
RELEASE_BUILD_FLAGS=-v -ldflags "-w -s -X main.version=$(VERSION)" -trimpath

build:
go vet ./...
go build -ldflags "-X main.version=$(VERSION)" -o $(BINARY_NAME)
go build -o $(BINARY_NAME)

release-darwin-arm64: require-version
@echo "Building for darwin-arm64"
rm -rf $(RELEASE_DIR)
go vet ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ${RELEASE_BUILD_FLAGS} -o $(RELEASE_DIR)/$(BINARY_NAME)
tar -czvf $(BINARY_NAME)-$(VERSION)-darwin-arm64.tar.gz -C $(RELEASE_DIR) $(BINARY_NAME)

release-linux-amd64: require-version
@echo "Building for linux-amd64"
rm -rf $(RELEASE_DIR)
go vet ./...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${RELEASE_BUILD_FLAGS} -o $(RELEASE_DIR)/$(BINARY_NAME)
tar -czvf $(BINARY_NAME)-$(VERSION)-linux-amd64.tar.gz -C $(RELEASE_DIR) $(BINARY_NAME)

require-version:
@if [ "$(VERSION)" = "dev" ]; then \
echo "You must set the VERSION"; \
exit 1; \
fi

clean:
git clean -fd

0 comments on commit 7647f2c

Please sign in to comment.