Skip to content

Commit fba51b6

Browse files
authored
Build version update (#1302)
* published is a better choice than created for releases. * Generate the version from the build process
1 parent 9b5c745 commit fba51b6

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ jobs:
6565
with:
6666
push: true
6767
context: .
68-
build-args: COMMITHASH=${{ github.event.workflow_run.head_sha }}
68+
build-args: |
69+
COMMITHASH=${{ github.event.workflow_run.head_sha }}
70+
VERSION=${{ github.event.workflow_run.display_title }}
6971
platforms: linux/amd64,linux/arm64/v8
7072
tags: getfider/fider:${{ github.event.workflow_run.display_title }}
7173
cache-from: type=gha

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ RUN go mod download
1717
COPY . ./
1818

1919
ARG COMMITHASH
20-
RUN COMMITHASH=${COMMITHASH} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-server
20+
ARG VERSION
21+
RUN COMMITHASH=${COMMITHASH} VERSION=${VERSION} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-server
2122
#################
2223
### UI Build Step
2324
#################

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## For more information, refer to https://www.thapaliya.com/en/writings/well-documented-makefiles/
44

55
LDFLAGS += -X github.com/getfider/fider/app/pkg/env.commithash=${COMMITHASH}
6+
LDFLAGS += -X github.com/getfider/fider/app/pkg/env.version=${VERSION}
67

78

89

app/pkg/env/env.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@ import (
1616
)
1717

1818
var (
19-
// this value is set by the CI build
19+
// these values are set by the CI build
2020
commithash = ""
21-
version = "0.22.0"
21+
version = ""
2222
)
2323

2424
func Version() string {
25+
v := version
26+
if v == "" {
27+
v = "dev"
28+
}
29+
2530
if commithash == "" {
26-
return fmt.Sprintf("%s-dev", version)
31+
return v
2732
}
2833

29-
return fmt.Sprintf("%s-%s", version, commithash)
34+
return fmt.Sprintf("%s-%s", v, commithash)
3035
}
3136

3237
type config struct {
@@ -49,7 +54,7 @@ type config struct {
4954
Locale string `env:"LOCALE,default=en"`
5055
JWTSecret string `env:"JWT_SECRET,required"`
5156
PostCreationWithTagsEnabled bool `env:"POST_CREATION_WITH_TAGS_ENABLED,default=false"`
52-
Paddle struct {
57+
Paddle struct {
5358
IsSandbox bool `env:"PADDLE_SANDBOX,default=false"`
5459
VendorID string `env:"PADDLE_VENDOR_ID"`
5560
VendorAuthCode string `env:"PADDLE_VENDOR_AUTHCODE"`

0 commit comments

Comments
 (0)