From 8ccdd9e013b58880eb85b5474d7436cee19d7876 Mon Sep 17 00:00:00 2001 From: Jon Lundy Date: Fri, 6 Jan 2023 13:30:33 -0700 Subject: [PATCH] fix: version generate --- .gitignore | 3 ++- Makefile | 6 +++++- go.mod | 1 + go.sum | 2 ++ main.go | 2 -- version.sh | 18 +++++++++--------- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 24e892d..54dbb91 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ sour.is-keyproofs .env -/pub \ No newline at end of file +/pub +local.mk diff --git a/Makefile b/Makefile index 141ff78..63ffbd8 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ BUMP?=current DATE:=$(shell date -u +%FT%TZ) HASH:=$(shell git rev-parse HEAD 2> /dev/null) VERSION:=$(shell BUMP=$(BUMP) ./version.sh) - +-include local.mk +DISABLE_VCARD=true build: $(NAME) @@ -12,11 +13,14 @@ clean: version: @echo $(VERSION) + tag: git tag -a v$(VERSION) -m "Version: $(VERSION)" git push --follow-tags + release: @make tag BUMP=patch + run: go run -v \ -ldflags "\ diff --git a/go.mod b/go.mod index 7a9aa37..5d5e508 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( go.uber.org/ratelimit v0.1.0 golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect + golang.org/x/sys v0.3.0 // indirect golang.org/x/text v0.3.4 // indirect gosrc.io/xmpp v0.5.1 ) diff --git a/go.sum b/go.sum index 0326c3b..d2c38a1 100644 --- a/go.sum +++ b/go.sum @@ -145,6 +145,8 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193 golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/main.go b/main.go index af99c50..bacd58c 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,6 @@ import ( "github.com/rs/cors" "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "gosrc.io/xmpp" "github.com/sour-is/keyproofs/pkg/cache" "github.com/sour-is/keyproofs/pkg/config" @@ -25,7 +24,6 @@ import ( app_avatar "github.com/sour-is/keyproofs/pkg/app/avatar" app_dns "github.com/sour-is/keyproofs/pkg/app/dns" app_keyproofs "github.com/sour-is/keyproofs/pkg/app/keyproofs" - app_vcard "github.com/sour-is/keyproofs/pkg/app/vcard" app_wkd "github.com/sour-is/keyproofs/pkg/app/wkd" ) diff --git a/version.sh b/version.sh index b7ccbc1..39bea48 100755 --- a/version.sh +++ b/version.sh @@ -1,8 +1,8 @@ #!/bin/bash # Increment a version string using Semantic Versioning (SemVer) terminology. - # Parse command line options. +BUMP="${BUMP:="$1"}" case $BUMP in current ) ;; @@ -11,43 +11,43 @@ case $BUMP in patch ) patch=true;; esac -version=$(git describe --tags `git rev-list --tags --max-count=1 2> /dev/null` 2> /dev/null|cut -b2-) +version=$(git describe --tags "$(git rev-list --tags --max-count=1 2> /dev/null)" 2> /dev/null|cut -b2-) # Build array from version string. -a=( ${version//./ } ) +IFS="." read -r -a a <<< "$version" # If version string is missing or has the wrong number of members, show usage message. if [ ${#a[@]} -ne 3 ] then version=0.0.0 - a=( ${version//./ } ) + IFS="." read -r -a a <<< "$version" fi # Increment version numbers as requested. -if [ ! -z $major ] +if [ -n "$major" ] then ((a[0]++)) a[1]=0 a[2]=0 fi -if [ ! -z $minor ] +if [ -n "$minor" ] then ((a[1]++)) a[2]=0 fi -if [ ! -z $patch ] +if [ -n "$patch" ] then ((a[2]++)) fi if git status --porcelain >/dev/null then - echo "${a[0]}.${a[1]}.${a[2]}" + echo "v${a[0]}.${a[1]}.${a[2]}" else - echo "${a[0]}.${a[1]}.${a[2]}-dirty" + echo "v${a[0]}.${a[1]}.${a[2]}-dirty" fi \ No newline at end of file