%global _hardened_build 1
%define debug_package %{nil}

Name:		mattermost-ctl
Version:	5.23.0
Release:	1%{?dist}
Summary:	A remote CLI tool for Mattermost
Group:		System/Library
License:	MIT
URL:		https://github.com/mattermost/mmctl
BuildRequires:	golang
BuildRequires:  git


%description
A remote CLI tool for Mattermost


%prep
%setup -q -T -c %{name}-%{version}
export GOPATH=`pwd`
mkdir -p src/github.com/mattermost/
cd src/github.com/mattermost/
git clone https://github.com/mattermost/mmctl/


%build
export GOPATH=`pwd`
export GO111MODULE=on
export CGO_ENABLED=0
cd src/github.com/mattermost/mmctl/
git checkout tags/v%{version}
export COMMIT=$(git rev-parse HEAD)
export SHORTCOMMIT=$(git rev-parse --short HEAD)
export BUILDDATE=$(date +%Y%m%d)
go build -v -trimpath --ldflags "
-X github.com/mattermost/mmctl/commands.BuildHash=$COMMIT
-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid %{version}" -o mattermost-ctl


%install
install -p -D -m 0555 src/github.com/mattermost/mmctl/mattermost-ctl %{buildroot}%{_bindir}/mattermost-ctl


%files
%doc
%{_bindir}/mattermost-ctl


%changelog
