mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-26 06:46:40 +00:00
Instead of the CI/CD using sed to replace the 'replaceme' text we can instead use ldflags which can inject variables at build time to the versions. The makefile had a bunch of workarounds for dev so these have been removed to cleanup etc etc and fetchs versions from the gh api directly if the variables are not injected like the CI/CD does
25 lines
1.1 KiB
Makefile
25 lines
1.1 KiB
Makefile
all: go-build-release
|
|
|
|
# Build with version injection via ldflags
|
|
# Versions can be passed via: make go-build-release PANGOLIN_VERSION=x.x.x GERBIL_VERSION=x.x.x BADGER_VERSION=x.x.x
|
|
# Or fetched automatically if not provided (requires curl and jq)
|
|
|
|
PANGOLIN_VERSION ?= $(shell curl -s https://api.github.com/repos/fosrl/pangolin/tags | jq -r '.[0].name')
|
|
GERBIL_VERSION ?= $(shell curl -s https://api.github.com/repos/fosrl/gerbil/tags | jq -r '.[0].name')
|
|
BADGER_VERSION ?= $(shell curl -s https://api.github.com/repos/fosrl/badger/tags | jq -r '.[0].name')
|
|
|
|
LDFLAGS = -X main.pangolinVersion=$(PANGOLIN_VERSION) \
|
|
-X main.gerbilVersion=$(GERBIL_VERSION) \
|
|
-X main.badgerVersion=$(BADGER_VERSION)
|
|
|
|
go-build-release:
|
|
@echo "Building with versions - Pangolin: $(PANGOLIN_VERSION), Gerbil: $(GERBIL_VERSION), Badger: $(BADGER_VERSION)"
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/installer_linux_amd64
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o bin/installer_linux_arm64
|
|
|
|
clean:
|
|
rm -f bin/installer_linux_amd64
|
|
rm -f bin/installer_linux_arm64
|
|
|
|
.PHONY: all go-build-release clean
|