2021-01-06 18:44:29 +00:00
|
|
|
OUTPUT = slack-status
|
|
|
|
GOFILES = *.go go.mod go.sum
|
2021-02-16 21:08:32 +00:00
|
|
|
DIST_ARCH = darwin-amd64 darwin-arm64 linux-amd64
|
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:
|
2021-02-02 19:57:39 +00:00
|
|
|
pre-commit run --all-files
|
2021-01-06 18:44:29 +00:00
|
|
|
go test
|
|
|
|
|
2021-02-16 22:16:45 +00:00
|
|
|
slack-status: $(GOFILES) certs/key.pem
|
2021-01-06 18:44:29 +00:00
|
|
|
go build -o $(OUTPUT)
|
|
|
|
|
|
|
|
.PHONY: dist
|
|
|
|
dist: $(DIST_TARGETS)
|
|
|
|
|
2021-02-16 22:16:45 +00:00
|
|
|
$(DIST_TARGETS): $(GOFILES) certs/key.pem
|
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 $@
|
|
|
|
|
2021-02-16 22:16:45 +00:00
|
|
|
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
|
2021-02-16 22:16:45 +00:00
|
|
|
rm -fr ./certs
|
2021-02-02 19:57:39 +00:00
|
|
|
|
|
|
|
.PHONY: install-hooks
|
|
|
|
install-hooks:
|
|
|
|
pre-commit install --overwrite --install-hooks
|