Skip to content

Commit

Permalink
Drop build number from release assets; align binary naming with backe…
Browse files Browse the repository at this point in the history
…nd; no more darwin86; add checksum to zips (#67)
  • Loading branch information
tr1ck3r committed Dec 11, 2020
1 parent 9408118 commit f760d59
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
30 changes: 13 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,24 @@
MKFILE_PATH := $(lastword $(MAKEFILE_LIST))
CURRENT_DIR := $(patsubst %/,%,$(dir $(realpath $(MKFILE_PATH))))


# List of tests to run
TEST ?= $$(go list ./... | grep -v /vendor/ | grep -v /e2e)
TEST_TIMEOUT?=20m
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)

#Plugin information
PLUGIN_NAME := vault-pki-monitor-venafi
PLUGIN_NAME := venafi-pki-monitor
PLUGIN_DIR := pkg/bin
PLUGIN_PATH := $(PLUGIN_DIR)/$(PLUGIN_NAME)
DIST_DIR := pkg/dist
ifdef BUILD_NUMBER
VERSION=`git describe --abbrev=0 --tags`+$(BUILD_NUMBER)
else
VERSION=`git describe --abbrev=0 --tags`

ifdef BUILD_NUMBER
VERSION:=$(VERSION)+$(BUILD_NUMBER)
endif

#define version if release is set
ifdef RELEASE_VERSION
ifdef BUILD_NUMBER
VERSION=$(RELEASE_VERSION)+$(BUILD_NUMBER)
else
ifneq ($(RELEASE_VERSION),none)
VERSION=$(RELEASE_VERSION)
endif
endif
Expand Down Expand Up @@ -85,7 +81,7 @@ ca:
clean:
rm -rf $(PLUGIN_DIR)
rm -rf $(DIST_DIR)
rm -rf artifcats
rm -rf artifacts

build: build_strict build_optional

Expand Down Expand Up @@ -130,16 +126,16 @@ import_cert_write:


collect_artifacts:
rm -rf artifcats
mkdir -p artifcats
cp -rv $(DIST_DIR)/*.zip artifcats
cd artifcats; echo '```' > ../release.txt
cd artifcats; sha256sum * >> ../release.txt
cd artifcats; echo '```' >> ../release.txt
rm -rf artifacts
mkdir -p artifacts
cp -rv $(DIST_DIR)/*.zip artifacts

release:
echo '```' > release.txt
cd artifacts; sha256sum * >> ../release.txt
echo '```' >> release.txt
go get -u github.com/tcnksm/ghr
ghr -prerelease -n $$RELEASE_VERSION -body="$$(cat ./release.txt)" $$RELEASE_VERSION artifcats/
ghr -prerelease -n $$RELEASE_VERSION -body="$$(cat ./release.txt)" $$RELEASE_VERSION artifacts/

#Docker server with consul
docker_server_prepare:
Expand Down
33 changes: 19 additions & 14 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ BUILD_MODE=$4
VERSION=$5
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

if [ ${BUILD_MODE}=="strict" ]; then
if [ ${BUILD_MODE} == "strict" ]; then
echo "Changing venafiPolicyDenyAll to true"
sed -i 's/const venafiPolicyDenyAll =.*/const venafiPolicyDenyAll = true/' plugin/pki/vcert.go
elif [ ${BUILD_MODE}=="optional" ]; then
elif [ ${BUILD_MODE} == "optional" ]; then
echo "Changing venafiPolicyDenyAll to false"
sed -i 's/const venafiPolicyDenyAll =.*/const venafiPolicyDenyAll = false/' plugin/pki/vcert.go
else
Expand All @@ -23,25 +23,30 @@ mkdir -p ${CURRENT_DIR}/../${DIST_DIR}

for os in linux darwin windows; do
for arch in 386 amd64; do
if echo ${arch}|grep --quiet 386; then
binary_name="${PLUGIN_DIR}/${os}86/${PLUGIN_NAME}_${BUILD_MODE}"
archive_name="${CURRENT_DIR}/../${DIST_DIR}/${PLUGIN_NAME}_${VERSION}_${os}86_${BUILD_MODE}"
else
binary_name="${PLUGIN_DIR}/${os}/${PLUGIN_NAME}_${BUILD_MODE}"
archive_name="${CURRENT_DIR}/../${DIST_DIR}/${PLUGIN_NAME}_${VERSION}_${os}_${BUILD_MODE}"
# 32-bit macOS build is now retired since support was dropped in Go 1.15
if [ "${os}" == "darwin" ] && [ "${arch}" == "386" ]; then continue; fi

case "${arch}" in
386) EXT="86" ;;
*) EXT="" ;;
esac
binary_name="${PLUGIN_DIR}/${os}${EXT}/${PLUGIN_NAME}"
archive_name="${CURRENT_DIR}/../${DIST_DIR}/${PLUGIN_NAME}_${VERSION}_${os}${EXT}_${BUILD_MODE}"

if [ ${BUILD_MODE} != "strict" ]; then
binary_name="${binary_name}_${BUILD_MODE}"
fi
if echo ${os}|grep --quiet windows; then

if [ "${os}" == "windows" ]; then
binary_name="${binary_name}.exe"
fi

echo "Building plugin binary ${binary_name} for ${os}-${arch}"
env CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build -ldflags '-s -w -extldflags "-static"' -a -o ${binary_name} || exit 1
chmod +x ${binary_name}
echo "Archiving binary into ${archive_name}.zip"
SHA256=$(sha256sum ${binary_name}| head -c 64)
echo "${SHA256} ${PLUGIN_NAME}_${BUILD_MODE}" > ${archive_name}.SHA256SUM
zip -j "${archive_name}.zip" "${binary_name}"
echo "${SHA256}" > ${binary_name}.SHA256SUM
zip -j "${archive_name}.zip" "${binary_name}" "${binary_name}.SHA256SUM"
done
done

echo "Checksums for binaries:"
cat ${CURRENT_DIR}/../${DIST_DIR}/*.SHA256SUM

0 comments on commit f760d59

Please sign in to comment.