| skipped 5 lines |
6 | 6 | | SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(MAKEFILE) |
7 | 7 | | |
8 | 8 | | VERSION := $(shell git describe --abbrev=0) |
| 9 | + | VERSION_TRIM := $(shell sed "s/-.*//" <<< $(VERSION)) |
| 10 | + | VERSION_REGEX := $(subst .,\.,$(VERSION_TRIM)) |
9 | 11 | | REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES)) |
10 | 12 | | BUILD_FLAGS := -a -ldflags "-X main.version=$(VERSION) -X main.revision=$(REVISION) -w '-extldflags=$(LDFLAGS)'" -tags "$(TAGS)" |
11 | 13 | | |
| skipped 3 lines |
15 | 17 | | BINARYARM7 := fzf-$(GOOS)_arm7 |
16 | 18 | | BINARYARM8 := fzf-$(GOOS)_arm8 |
17 | 19 | | BINARYPPC64LE := fzf-$(GOOS)_ppc64le |
18 | | - | VERSION := $(shell awk -F= '/version =/ {print $$2}' src/constants.go | tr -d "\" ") |
19 | 20 | | |
20 | 21 | | # https://en.wikipedia.org/wiki/Uname |
21 | 22 | | UNAME_M := $(shell uname -m) |
| skipped 14 lines |
36 | 37 | | else ifeq ($(UNAME_M),ppc64le) |
37 | 38 | | BINARY := $(BINARYPPC64LE) |
38 | 39 | | else |
39 | | - | $(error "Build on $(UNAME_M) is not supported, yet.") |
| 40 | + | $(error Build on $(UNAME_M) is not supported, yet.) |
40 | 41 | | endif |
41 | 42 | | |
42 | 43 | | all: target/$(BINARY) |
| skipped 7 lines |
50 | 51 | | |
51 | 52 | | install: bin/fzf |
52 | 53 | | |
53 | | - | release: |
| 54 | + | build: |
54 | 55 | | goreleaser --rm-dist --snapshot |
55 | 56 | | |
| 57 | + | release: |
| 58 | + | ifndef GITHUB_TOKEN |
| 59 | + | $(error GITHUB_TOKEN is not defined) |
| 60 | + | endif |
| 61 | + | |
| 62 | + | # Check if we are on master branch |
| 63 | + | ifneq ($(shell git symbolic-ref --short HEAD),master) |
| 64 | + | $(error Not on master branch) |
| 65 | + | endif |
| 66 | + | |
| 67 | + | # Check if version numbers are properly updated |
| 68 | + | grep -q ^$(VERSION_REGEX)$$ CHANGELOG.md |
| 69 | + | grep -qF '"fzf $(VERSION_TRIM)"' man/man1/fzf.1 |
| 70 | + | grep -qF '"fzf $(VERSION_TRIM)"' man/man1/fzf-tmux.1 |
| 71 | + | grep -qF $(VERSION) install |
| 72 | + | grep -qF $(VERSION) install.ps1 |
| 73 | + | |
| 74 | + | # Make release note out of CHANGELOG.md |
| 75 | + | sed -n '/^$(VERSION_REGEX)$$/,/^[0-9]/p' CHANGELOG.md | tail -r | \ |
| 76 | + | sed '1,/^ *$$/d' | tail -r | sed 1,2d | tee tmp/release-note |
| 77 | + | |
| 78 | + | # Push to temp branch first so that install scripts always works on master branch |
| 79 | + | git checkout -B temp master |
| 80 | + | git push origin temp --follow-tags --force |
| 81 | + | |
| 82 | + | # Make a GitHub release |
| 83 | + | goreleaser --rm-dist --release-notes tmp/release-note |
| 84 | + | |
| 85 | + | # Push to master |
| 86 | + | git checkout master |
| 87 | + | git push origin master |
| 88 | + | |
| 89 | + | # Delete temp branch |
| 90 | + | git push origin --delete temp |
| 91 | + | |
56 | 92 | | clean: |
57 | 93 | | $(RM) -r dist target |
58 | 94 | | |
| skipped 31 lines |
90 | 126 | | $(GO) get -u |
91 | 127 | | $(GO) mod tidy |
92 | 128 | | |
93 | | - | .PHONY: all release test install clean docker docker-test update |
| 129 | + | .PHONY: all build release test install clean docker docker-test update |
94 | 130 | | |