# Template file for 'github-cli'
pkgname=github-cli
version=2.9.0
revision=1
wrksrc="cli-${version}"
build_style=go
build_helper=qemu
go_import_path="github.com/cli/cli/v2/cmd/gh"
go_ldflags="-X github.com/cli/cli/v2/internal/build.Version=v${version}"
short_desc="GitHub CLI tool"
maintainer="shizonic <realtiaz@gmail.com>"
license="MIT"
homepage="https://cli.github.com"
changelog="https://github.com/cli/cli/releases"
distfiles="https://github.com/cli/cli/archive/v${version}.tar.gz"
checksum=730b600d33afb67d84af4dca1af80cb1fbff79d302ac4f840fc8e9e4c25fceb7

pre_build() {
	local _date
	if [ "$SOURCE_DATE_EPOCH" ]; then
		_date="$(date --utc --date "@$SOURCE_DATE_EPOCH" "+%Y-%m-%d")"
		go_ldflags="$go_ldflags -X github.com/cli/cli/v2/internal/build.Date=${_date}"
	fi
}

post_build() {
	CGO_ENABLED=0 GOARCH="" go run script/build.go manpages
	gh=$(find $GOPATH/bin -name gh)
	for shell in bash fish zsh; do
		vtargetrun $gh completion -s $shell > github-cli.$shell
	done
}

post_install() {
	vlicense LICENSE

	vcopy share/man usr/share
	for shell in bash fish zsh; do
		vcompletion github-cli.$shell $shell gh
	done
}
