-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
116 lines (92 loc) · 3.71 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/make -f
VERSION := $(shell git describe --tags --abbrev=0)
COMMIT := $(shell git rev-parse --short HEAD)
BUILD_DIR ?= $(CURDIR)/build
HIDNODE_CMD_DIR := $(CURDIR)/cmd/hid-noded
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
GOBIN = $(shell go env GOPATH)/bin
GOOS = $(shell go env GOOS)
GOARCH = $(shell go env GOARCH)
SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
BFT_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=hid-node \
-X github.com/cosmos/cosmos-sdk/version.AppName=hid-node \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(BFT_VERSION)
BUILD_FLAGS := -ldflags '$(ldflags)'
export GO111MODULE=on
###############################################################################
### Build ###
###############################################################################
.PHONY: build install
all: proto-gen-go proto-gen-swagger build
go-version-check:
ifneq ($(GO_MINOR_VERSION),21)
@echo "ERROR: Go version 1.21 is required to build hid-noded binary"
exit 1
endif
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify
install: go.sum go-version-check
go install -mod=readonly $(BUILD_FLAGS) $(HIDNODE_CMD_DIR)
build: go-version-check
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILD_DIR)/hid-noded $(HIDNODE_CMD_DIR)
###############################################################################
### Proto ###
###############################################################################
proto-gen-go:
@echo "Generating golang code from protobuf"
./scripts/protocgen-go.sh
proto-gen-swagger:
@echo "Generating swagger docs"
./scripts/protocgen-swagger.sh
proto-gen-ts:
@echo "Generating typescript code from protobuf"
./scripts/protocgen-ts.sh
###############################################################################
### Docker ###
###############################################################################
DOCKER_IMAGE_NAME := hid-node-image
docker-all: docker-build docker-run
docker-build:
docker build -t $(DOCKER_IMAGE_NAME) .
docker-run:
docker run --rm -d \
-p 26657:26657 -p 1317:1317 -p 26656:26656 -p 9090:9090 \
--name hid-node-container \
$(DOCKER_IMAGE_NAME) start
###############################################################################
### Release ###
###############################################################################
GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION)
COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm | sed 's/.* //')
ifdef GITHUB_TOKEN
release:
docker run \
--rm \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-e COSMWASM_VERSION=$(COSMWASM_VERSION) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/hid-noded \
-w /go/src/hid-noded \
$(GORELEASER_IMAGE) \
release \
--clean
else
release:
@echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'."
endif
release-dry-run:
docker run \
--rm \
-e COSMWASM_VERSION=$(COSMWASM_VERSION) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/hid-noded \
-w /go/src/hid-noded \
$(GORELEASER_IMAGE) \
release \
--clean \
--skip=publish