Skip to content

Commit

Permalink
fix version
Browse files Browse the repository at this point in the history
  • Loading branch information
hengfeiyang committed May 31, 2022
1 parent 1e73e00 commit c219063
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ builds:
id: zinc_binaries
ldflags:
- -s -w
- -X github.com/zinclabs/zinc/pkg/meta/v1.Version={{.Version}} # https://goreleaser.com/customization/templates/
- "-X github.com/zinclabs/zinc/pkg/meta/v1.BuildDate={{.Date}}"
- "-X github.com/zinclabs/zinc/pkg/meta/v1.CommitHash={{.Commit}}"
- -X github.com/zinclabs/zinc/pkg/meta.Version={{.Version}} # https://goreleaser.com/customization/templates/
- "-X github.com/zinclabs/zinc/pkg/meta.BuildDate={{.Date}}"
- "-X github.com/zinclabs/zinc/pkg/meta.CommitHash={{.Commit}}"
env:
- CGO_ENABLED=0
goos:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ go build -o zinc cmd/zinc/main.go # will build the zinc binary
Advanced

```shell
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X github.com/zinclabs/zinc/pkg/meta/v1.Version=${VERSION} -X github.com/zinclabs/zinc/pkg/meta/v1.CommitHash=${COMMIT_HASH} -X github.com/zinclabs/zinc/pkg/meta/v1.BuildDate=${BUILD_DATE}" -o zinc cmd/zinc/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X github.com/zinclabs/zinc/pkg/meta.Version=${VERSION} -X github.com/zinclabs/zinc/pkg/meta.CommitHash=${COMMIT_HASH} -X github.com/zinclabs/zinc/pkg/meta.BuildDate=${BUILD_DATE}" -o zinc cmd/zinc/main.go
```

Setting GOOS and GOARCH appropriately allows for cross platform compilation. Check [Official docs](https://go.dev/doc/install/source#environment) for all possible values and combinations. This [gist](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63) is also great.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ENV VERSION=$VERSION
ENV COMMIT_HASH=$COMMIT_HASH
ENV BUILD_DATE=$BUILD_DATE

RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w -X github.com/zinclabs/zinc/pkg/meta/v1.Version=${VERSION} -X github.com/zinclabs/zinc/pkg/meta/v1.CommitHash=${COMMIT_HASH} -X github.com/zinclabs/zinc/pkg/meta/v1.BuildDate=${BUILD_DATE}" -o zinc cmd/zinc/main.go
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w -X github.com/zinclabs/zinc/pkg/meta.Version=${VERSION} -X github.com/zinclabs/zinc/pkg/meta.CommitHash=${COMMIT_HASH} -X github.com/zinclabs/zinc/pkg/meta.BuildDate=${BUILD_DATE}" -o zinc cmd/zinc/main.go
############################
# STEP 2 build a small image
############################
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.hub
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ENV VERSION=$VERSION
ENV COMMIT_HASH=$COMMIT_HASH
ENV BUILD_DATE=$BUILD_DATE

RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w -X github.com/zinclabs/zinc/pkg/meta/v1.Version=${VERSION} -X github.com/zinclabs/zinc/pkg/meta/v1.CommitHash=${COMMIT_HASH} -X github.com/zinclabs/zinc/pkg/meta/v1.BuildDate=${BUILD_DATE}" -o zinc cmd/zinc/main.go
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w -X github.com/zinclabs/zinc/pkg/meta.Version=${VERSION} -X github.com/zinclabs/zinc/pkg/meta.CommitHash=${COMMIT_HASH} -X github.com/zinclabs/zinc/pkg/meta.BuildDate=${BUILD_DATE}" -o zinc cmd/zinc/main.go
############################
# STEP 2 build a small image
############################
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export VERSION=`git describe --tags --always`
export BUILD_DATE=`date -u '+%Y-%m-%d_%I:%M:%S%p-GMT'`
export COMMIT_HASH=`git rev-parse HEAD`

export ZINC_LDFLAGS="-w -s -X github.com/zinclabs/zinc/pkg/meta/v1.Version=${VERSION} -X github.com/zinclabs/zinc/pkg/meta/v1.BuildDate=${BUILD_DATE} -X github.com/zinclabs/zinc/pkg/meta/v1.CommitHash=${COMMIT_HASH}"
export ZINC_LDFLAGS="-w -s -X github.com/zinclabs/zinc/pkg/meta.Version=${VERSION} -X github.com/zinclabs/zinc/pkg/meta.BuildDate=${BUILD_DATE} -X github.com/zinclabs/zinc/pkg/meta.CommitHash=${COMMIT_HASH}"

# CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s -X main.Version=$VERSION -X main.Date=$DATE -X main.Commit=$COMMIT_HASH" -o zinc cmd/zinc/main.go
# CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-X main.Version=$VERSION -X main.Date=$DATE -X main.Commit=$COMMIT_HASH" -o zinc cmd/zinc/main.go
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// export DATE=`date -u '+%Y-%m-%d_%I:%M:%S%p-GMT'`
// export COMMIT_HASH=`git rev-parse HEAD`

// go build -a -ldflags "-X github.com/zinclabs/zinc/pkg/meta/v1.Version=$VERSION" -o zinc
// go build -a -ldflags "-X github.com/zinclabs/zinc/pkg/meta.Version=$VERSION" -o zinc
var (
// Version is the version of the program - Git tag - git describe --tags --always
Version = "v0.0.0"
Expand Down

0 comments on commit c219063

Please sign in to comment.