Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

chore: set commit hash during build time

goenningb1349f33affa
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 8ed3bec36..7a1706fe2 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -38,7 +38,7 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
- build-args: BUILDNUMBER=${{ github.event.workflow_run.head_sha }}
+ build-args: COMMITHASH=${{ github.event.workflow_run.head_sha }}
platforms: linux/amd64,linux/arm64/v8
tags: getfider/fider:PR_${{ github.event.workflow_run.pull_requests[0].number }}
@@ -47,6 +47,6 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
- build-args: BUILDNUMBER=${{ github.event.workflow_run.head_sha }}
+ build-args: COMMITHASH=${{ github.event.workflow_run.head_sha }}
platforms: linux/amd64,linux/arm64/v8
tags: getfider/fider:SHA_${{ github.event.workflow_run.head_sha }},getfider/fider:main
diff --git a/Dockerfile b/Dockerfile
index 6af851616..b1347e76a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,7 +3,7 @@
#####################
FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:1.17-buster AS server-builder
-ARG BUILDNUMBER=local
+ARG COMMITHASH
ARG TARGETOS
ARG TARGETARCH
@@ -11,7 +11,7 @@ RUN mkdir /server
WORKDIR /server
COPY . .
-RUN BUILDNUMBER=${BUILDNUMBER} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-server
+RUN COMMITHASH=${COMMITHASH} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-server
#################
### UI Build Step
diff --git a/Makefile b/Makefile
index 1bc19837e..f8a5a24db 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
##
## For more information, refer to https://suva.sh/posts/well-documented-makefiles/
-LDFLAGS += -X github.com/getfider/fider/app/pkg/env.buildnumber=${BUILDNUMBER}
+LDFLAGS += -X github.com/getfider/fider/app/pkg/env.commithash=${COMMITHASH}
diff --git a/app/pkg/env/env.go b/app/pkg/env/env.go
index be6360390..bf54c9b4e 100644
--- a/app/pkg/env/env.go
+++ b/app/pkg/env/env.go
@@ -14,14 +14,14 @@ import (
)
var (
- // these values are replaced during CI build
+ // this value is set by the CI build
buildnumber = ""
- version = "0.20.0-dev"
+ version = "0.20.0"
)
func Version() string {
if buildnumber == "" {
- return version
+ return fmt.Sprintf("%s-dev", version)
}
return fmt.Sprintf("%s-%s", version, buildnumber)
@@ -175,7 +175,7 @@ func Reload() {
func mustBeSet(name string) {
value := os.Getenv(name)
if value == "" {
- panic(fmt.Errorf("Could not find environment variable named '%s'", name))
+ panic(fmt.Errorf("could not find environment variable named '%s'", name))
}
}