1 Makefile
BINDIR ?= /usr/local/bin
PROGRAM ?= load-hive
BUILD_DIR ?= build
LOCAL_BINARY ?= $(BUILD_DIR)/$(PROGRAM)
# `make help`
.PHONY: help
help:
@cat Makefile | grep '# `' | grep -v '@cat Makefile'
# `make build`
.PHONY: build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(PROGRAM)_linux_amd64 -mod vendor -trimpath -ldflags '-s -w' .
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(BUILD_DIR)/$(PROGRAM)_linux_arm64 -mod vendor -trimpath -ldflags '-s -w' .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $(BUILD_DIR)/$(PROGRAM)_darwin_amd64 -mod vendor -trimpath -ldflags '-s -w' .
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/$(PROGRAM)_darwin_arm64 -mod vendor -trimpath -ldflags '-s -w' .
# `make clean`
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
# `make install`
.PHONY: install
install:
mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 go build -o $(LOCAL_BINARY) -mod vendor -trimpath -ldflags '-s -w' .
mkdir -p $(DESTDIR)$(BINDIR)
install -m 755 $(LOCAL_BINARY) $(DESTDIR)$(BINDIR)/$(PROGRAM)
2 .github/actions/release.yaml
name: Release
on:
push:
permissions:
contents: write
jobs:
release:
name: Build and Publish Release Assets
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build
run: make build
- name: Publish GitHub release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v3
with:
files: build/*
generate_release_notes: true