slack-status-cli/Makefile

57 lines
1.2 KiB
Makefile
Raw Normal View History

2021-01-06 18:44:29 +00:00
OUTPUT = slack-status
GOFILES = *.go go.mod go.sum
2022-01-28 05:17:32 +00:00
DIST_ARCH = darwin-amd64 darwin-arm64 linux-amd64 linux-arm64
2021-01-06 18:44:29 +00:00
DIST_TARGETS = $(addprefix dist/$(OUTPUT)-,$(DIST_ARCH))
2021-02-02 21:49:10 +00:00
VERSION ?= $(shell git describe --tags --dirty)
2021-01-06 18:44:29 +00:00
.PHONY: default
default: slack-status
2021-01-07 17:19:56 +00:00
.PHONY: run
run: slack-status
./slack-status
2021-01-06 18:44:29 +00:00
.PHONY: all
all: dist
.PHONY: test
test:
pre-commit run --all-files
2021-01-06 18:44:29 +00:00
go test
slack-status: $(GOFILES) certs
2021-01-06 18:44:29 +00:00
go build -o $(OUTPUT)
.PHONY: dist
dist: $(DIST_TARGETS)
$(DIST_TARGETS): $(GOFILES) certs
2021-01-06 18:44:29 +00:00
@mkdir -p ./dist
GOOS=$(word 3, $(subst -, ,$(@))) GOARCH=$(word 4, $(subst -, ,$(@))) \
go build \
2021-02-02 21:49:10 +00:00
-ldflags '-X "main.version=${VERSION}" -X "main.defaultClientID=$(CLIENT_ID)" -X "main.defaultClientSecret=$(CLIENT_SECRET)"' \
2021-01-06 18:44:29 +00:00
-o $@
.PHONY: certs
certs: certs/key.pem
certs/cert.pem: certs/key.pem
certs/key.pem:
mkdir -p certs/
openssl req -x509 -subj "/C=US/O=Slack Status CLI/CN=localhost:8888" \
-nodes -days 365 -newkey "rsa:2048" \
-addext "subjectAltName=DNS:localhost:8888" \
-keyout certs/key.pem -out certs/cert.pem
2021-01-06 18:44:29 +00:00
.PHONY: clean
clean:
2021-02-02 21:49:10 +00:00
rm -f ./slack-status
2021-01-06 18:44:29 +00:00
rm -fr ./dist
2023-09-19 20:18:27 +00:00
.PHONY: clean-certs
clean-certs:
rm -fr ./certs
.PHONY: install-hooks
install-hooks:
pre-commit install --overwrite --install-hooks