diff --git a/.gitignore b/.gitignore index 6d6e230..9d725f2 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,7 @@ go.work.sum esctl -*.sh + *.json *.log diff --git a/Makefile b/Makefile index 832a266..8276d44 100644 --- a/Makefile +++ b/Makefile @@ -89,7 +89,7 @@ goupdate: go get -t -u=patch ./... release: - ./mkrel.sh $(tool) $(BRANCH) $(COMMIT) $(GOVERSION) $(APIVERSION) $(VERSION) + ./mkrel.sh $(tool) $(COMMIT) $(GOVERSION) $(APIVERSION) $(VERSION) $(BRANCH) show-versions: buildlocal @echo "### esctl version:" diff --git a/mkrel.sh b/mkrel.sh new file mode 100755 index 0000000..7ea8b9d --- /dev/null +++ b/mkrel.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +set -e + +# +# Copyright © 2023-2024 Thomas von Dein +# Copyright 2024 Finanz Informatik Technologie Service GmbH & Co KG +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# get list with: go tool dist list +DIST="linux/amd64 +windows/amd64 +darwin/amd64" + +tool="$1" +COMMIT="$2" +GOVERSION="$3" +APIVERSION="$4" +version="$5" +BRANCH="$6" + +if test -z "$BRANCH"; then + BRANCH=main +fi + +rm -rf releases +mkdir -p releases + +for D in $DIST; do + os=${D/\/*/} + arch=${D/*\//} + binfile="releases/${tool}-${os}-${arch}-${version}" + + case "$os" in + windows) + binfile="${binfile}.exe" + ;; + esac + + set -x + GOOS=${os} GOARCH=${arch} go build -tags osusergo,netgo \ + -ldflags "-extldflags=-static -X github.com/fi-ts/esctl/pkg/cfg.BRANCH=${BRANCH} -X github.com/fi-ts/esctl/pkg/cfg.COMMIT=${COMMIT} -X github.com/fi-ts/esctl/pkg/cfg.GOVERSION=${GOVERSION} -X github.com/fi-ts/esctl/pkg/cfg.APIVERSION=${APIVERSION} -X github.com/fi-ts/esctl/pkg/cfg.BUILD=${BUILD}" -o "${binfile}" + + sha256sum ${binfile} | cut -d' ' -f1 > ${binfile}.sha256 + set +x +done +