Skip to content

Commit

Permalink
Fix versioning problem
Browse files Browse the repository at this point in the history
  • Loading branch information
RashadAnsari committed Jul 11, 2021
1 parent 6b05493 commit fe24176
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export APP=gola
export APP_VERSION=v0.0.0
export BUILD_INFO_PKG="github.com/RashadAnsari/gola/pkg/version"
export LDFLAGS="-w -s -X '$(BUILD_INFO_PKG).AppVersion=$(APP_VERSION)' -X '$(BUILD_INFO_PKG).Date=$$(date)' -X '$(BUILD_INFO_PKG).BuildVersion=$$(git rev-parse HEAD | cut -c 1-8)' -X '$(BUILD_INFO_PKG).VCSRef=$$(git rev-parse --abbrev-ref HEAD)'"
export LDFLAGS="-w -s -X '$(BUILD_INFO_PKG).AppVersion=dev' -X '$(BUILD_INFO_PKG).Date=$$(date)' -X '$(BUILD_INFO_PKG).BuildVersion=$$(git rev-parse HEAD | cut -c 1-8)' -X '$(BUILD_INFO_PKG).VCSRef=$$(git rev-parse --abbrev-ref HEAD)'"

binary:
@go build -ldflags $(LDFLAGS) ./cmd/gola
Expand All @@ -10,7 +8,7 @@ install:
@go install -ldflags $(LDFLAGS) ./cmd/gola

release:
@./scripts/release.sh $(APP) $(APP_VERSION) "$(LDFLAGS)"
@./scripts/release.sh $(APP_VERSION)

format:
@find . -type f -name '*.go' -not -path './vendor/*' -exec gofmt -s -w {} +
Expand Down
11 changes: 7 additions & 4 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/usr/bin/env bash

APP=$1
APP_VERSION=$2
LDFLAGS=$3
APP=gola

APP_VERSION=$1

BUILD_INFO_PKG="github.com/RashadAnsari/gola/pkg/version"
LDFLAGS="-w -s -X '${BUILD_INFO_PKG}.AppVersion=${APP_VERSION}' -X '${BUILD_INFO_PKG}.Date=$(date)' -X '${BUILD_INFO_PKG}.BuildVersion=$(git rev-parse HEAD | cut -c 1-8)' -X '${BUILD_INFO_PKG}.VCSRef=$(git rev-parse --abbrev-ref HEAD)'"

RELEASE_FOLDER=releases

function release {
GO_OS=$1
GO_ARCH=$2

GOOS=${GO_OS} GOARCH=${GO_ARCH} go build -ldflags "${LDFLAGS}" ./cmd/${APP}
GOOS=${GO_OS} GOARCH=${GO_ARCH} go build -ldflags "${LDFLAGS}" ./cmd/${APP}

BINARY_NAME=${APP}-${APP_VERSION}-${GO_OS}-${GO_ARCH}
mv ${APP} ${BINARY_NAME}
Expand Down

0 comments on commit fe24176

Please sign in to comment.