github.com/ungtb10d/cli/v2@v2.0.0-20221110210412-98537dd9d6a1/Makefile (about)

     1  CGO_CPPFLAGS ?= ${CPPFLAGS}
     2  export CGO_CPPFLAGS
     3  CGO_CFLAGS ?= ${CFLAGS}
     4  export CGO_CFLAGS
     5  CGO_LDFLAGS ?= $(filter -g -L% -l% -O%,${LDFLAGS})
     6  export CGO_LDFLAGS
     7  
     8  EXE =
     9  ifeq ($(GOOS),windows)
    10  EXE = .exe
    11  endif
    12  
    13  ## The following tasks delegate to `script/build.go` so they can be run cross-platform.
    14  
    15  .PHONY: bin/gh$(EXE)
    16  bin/gh$(EXE): script/build
    17  	@script/build $@
    18  
    19  script/build: script/build.go
    20  	GOOS= GOARCH= GOARM= GOFLAGS= CGO_ENABLED= go build -o $@ $<
    21  
    22  .PHONY: clean
    23  clean: script/build
    24  	@script/build $@
    25  
    26  .PHONY: manpages
    27  manpages: script/build
    28  	@script/build $@
    29  
    30  # just a convenience task around `go test`
    31  .PHONY: test
    32  test:
    33  	go test ./...
    34  
    35  ## Site-related tasks are exclusively intended for use by the GitHub CLI team and for our release automation.
    36  
    37  site:
    38  	git clone https://github.com/ungtb10d/cli.git "$@"
    39  
    40  .PHONY: site-docs
    41  site-docs: site
    42  	git -C site pull
    43  	git -C site rm 'manual/gh*.md' 2>/dev/null || true
    44  	go run ./cmd/gen-docs --website --doc-path site/manual
    45  	rm -f site/manual/*.bak
    46  	git -C site add 'manual/gh*.md'
    47  	git -C site commit -m 'update help docs' || true
    48  
    49  .PHONY: site-bump
    50  site-bump: site-docs
    51  ifndef GITHUB_REF
    52  	$(error GITHUB_REF is not set)
    53  endif
    54  	sed -i.bak -E 's/(assign version = )".+"/\1"$(GITHUB_REF:refs/tags/v%=%)"/' site/index.html
    55  	rm -f site/index.html.bak
    56  	git -C site commit -m '$(GITHUB_REF:refs/tags/v%=%)' index.html
    57  
    58  ## Install/uninstall tasks are here for use on *nix platform. On Windows, there is no equivalent.
    59  
    60  DESTDIR :=
    61  prefix  := /usr/local
    62  bindir  := ${prefix}/bin
    63  mandir  := ${prefix}/share/man
    64  
    65  .PHONY: install
    66  install: bin/gh manpages
    67  	install -d ${DESTDIR}${bindir}
    68  	install -m755 bin/gh ${DESTDIR}${bindir}/
    69  	install -d ${DESTDIR}${mandir}/man1
    70  	install -m644 ./share/man/man1/* ${DESTDIR}${mandir}/man1/
    71  
    72  .PHONY: uninstall
    73  uninstall:
    74  	rm -f ${DESTDIR}${bindir}/gh ${DESTDIR}${mandir}/man1/gh.1 ${DESTDIR}${mandir}/man1/gh-*.1