Skip to content

Commit 014e533

Browse files
committed
[RELEASE] decouple the release name from the version number
The release name, as provided by FORGEJO_RELEASE, is used to build OCI images and binary files. Although it can be the same as the Forgejo version, it is not a requirement. When the FORGEJO_RELEASE environment variable is set, use it as a default for naming the binary file instead of FORGEJO_VERSION. For instance, when building from the forgejo branch here is what is desired: FORGEJO_VERSION=7.0.0-g2343 GITEA_VERSION=1.22.0 VERSION=vforgejo-test The name of the release is also displayed with forgejo --version for sanity check purposes. Before: FORGEJO_VERSION is the computed version GITEA_VERSION is set manually VERSION defaults to FORGEJO_VERSION forgejo --help does not display VERSION After: FORGEJO_VERSION is the computed version GITEA_VERSION is set manually RELEASE_VERSION defaults to FORGEJO_VERSION VERSION defaults to RELEASE_VERSION forgejo --help displays VERSION
1 parent fd01298 commit 014e533

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

.forgejo/workflows/build-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,4 @@ jobs:
190190
destination-token: ${{ secrets.CASCADE_DESTINATION_TOKEN }}
191191
update: .forgejo/cascading-release-end-to-end
192192
env:
193-
FORGEJO_BINARY: "${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/releases/download/v${{ steps.tag-version.outputs.value }}/forgejo-${{ steps.tag-version.outputs.value }}-linux-amd64"
193+
FORGEJO_BINARY: "${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/releases/download/v${{ steps.release-info.outputs.version }}/forgejo-${{ steps.release-info.outputs.version }}-linux-amd64"

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.21-alpine3.19 as build
55
ARG GOPROXY
66
ENV GOPROXY ${GOPROXY:-direct}
77

8-
ARG GITEA_VERSION
8+
ARG RELEASE_VERSION
99
ARG TAGS="sqlite sqlite_unlock_notify"
1010
ENV TAGS "bindata timetzdata $TAGS"
1111
ARG CGO_EXTRA_CFLAGS
@@ -36,7 +36,7 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
3636
RUN make clean-all
3737
RUN make frontend
3838
RUN go build contrib/environment-to-ini/environment-to-ini.go && xx-verify environment-to-ini
39-
RUN make go-check generate-backend static-executable && xx-verify gitea
39+
RUN make RELEASE_VERSION=$RELEASE_VERSION go-check generate-backend static-executable && xx-verify gitea
4040

4141
# Copy local files
4242
COPY docker/root /tmp/local

Dockerfile.rootless

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.21-alpine3.19 as build
55
ARG GOPROXY
66
ENV GOPROXY ${GOPROXY:-direct}
77

8-
ARG GITEA_VERSION
8+
ARG RELEASE_VERSION
99
ARG TAGS="sqlite sqlite_unlock_notify"
1010
ENV TAGS "bindata timetzdata $TAGS"
1111
ARG CGO_EXTRA_CFLAGS
@@ -36,7 +36,7 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
3636
RUN make clean-all
3737
RUN make frontend
3838
RUN go build contrib/environment-to-ini/environment-to-ini.go && xx-verify environment-to-ini
39-
RUN make go-check generate-backend static-executable && xx-verify gitea
39+
RUN make RELEASE_VERSION=$RELEASE_VERSION go-check generate-backend static-executable && xx-verify gitea
4040

4141
# Copy local files
4242
COPY docker/rootless /tmp/local

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ ifneq ($(STORED_VERSION),)
9292
else
9393
FORGEJO_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
9494
endif
95-
VERSION ?= ${FORGEJO_VERSION}
95+
RELEASE_VERSION ?= ${FORGEJO_VERSION}
96+
VERSION ?= ${RELEASE_VERSION}
9697

9798
GITEA_VERSION ?= 1.22.0
9899

99-
LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)" -X "main.ForgejoVersion=$(FORGEJO_VERSION)"
100+
LDFLAGS := $(LDFLAGS) -X "main.ReleaseVersion=$(RELEASE_VERSION)" -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)" -X "main.ForgejoVersion=$(FORGEJO_VERSION)"
100101

101102
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
102103

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ var (
2929
Version = "development" // program version for this build
3030
Tags = "" // the Golang build tags
3131
MakeVersion = "" // "make" program version if built with make
32+
33+
ReleaseVersion = ""
3234
)
3335

3436
var ForgejoVersion = "1.0.0"
@@ -54,11 +56,18 @@ func main() {
5456
log.GetManager().Close()
5557
os.Exit(code)
5658
}
57-
app := cmd.NewMainApp(Version, formatBuiltWith())
59+
app := cmd.NewMainApp(Version, formatReleaseVersion()+formatBuiltWith())
5860
_ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp
5961
log.GetManager().Close()
6062
}
6163

64+
func formatReleaseVersion() string {
65+
if len(ReleaseVersion) > 0 {
66+
return " (release name " + ReleaseVersion + ")"
67+
}
68+
return ""
69+
}
70+
6271
func formatBuiltWith() string {
6372
version := runtime.Version()
6473
if len(MakeVersion) > 0 {

0 commit comments

Comments
 (0)