From da3aeb9bb23908306ce9a3ef87699e32e13da84e Mon Sep 17 00:00:00 2001 From: James Mills Date: Sat, 18 Sep 2021 09:43:22 +1000 Subject: [PATCH] Add release script --- .goreleaser.yml | 25 +++++++++++++++++++++++++ tools/release.sh | 25 +++++++++++++++++++++++++ version.go | 18 ++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .goreleaser.yml create mode 100755 tools/release.sh create mode 100644 version.go diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..88ef0c6 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,25 @@ +--- +builds: + - + id: zs + binary: zs + main: . + flags: -tags "static_build" + ldflags: -w -X main.Version={{.Version}} -X main.Commit={{.Commit}} + env: + - CGO_ENABLED=0 + goos: + - darwin + - linux + goarch: + - amd64 + - arm64 +signs: + - artifacts: checksum +release: + gitea: + owner: prologic + name: zs + draft: true +gitea_urls: + api: https://git.mills.io/api/v1/ diff --git a/tools/release.sh b/tools/release.sh new file mode 100755 index 0000000..e8ab44e --- /dev/null +++ b/tools/release.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Get the highest tag number +VERSION="$(git describe --abbrev=0 --tags)" +VERSION=${VERSION:-'0.0.0'} + +# Get number parts +MAJOR="${VERSION%%.*}"; VERSION="${VERSION#*.}" +MINOR="${VERSION%%.*}"; VERSION="${VERSION#*.}" +PATCH="${VERSION%%.*}"; VERSION="${VERSION#*.}" + +# Increase version +PATCH=$((PATCH+1)) + +TAG="${1}" + +if [ "${TAG}" = "" ]; then + TAG="${MAJOR}.${MINOR}.${PATCH}" +fi + +echo "Releasing ${TAG} ..." + +git tag -a -s -m "Release ${TAG}" "${TAG}" +git push --tags +goreleaser release --rm-dist diff --git a/version.go b/version.go new file mode 100644 index 0000000..3aefaf3 --- /dev/null +++ b/version.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" +) + +var ( + // Version release version + Version = "0.0.1" + + // Commit will be overwritten automatically by the build system + Commit = "HEAD" +) + +// FullVersion display the full version and build +func FullVersion() string { + return fmt.Sprintf("%s@%s", Version, Commit) +}