feat(build): add RELEASE_VERSION argument to be able to pass release version via env
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
kolaente 2025-01-29 08:36:24 +01:00
parent 56961a9a40
commit 5e62c219d3
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 41 additions and 23 deletions

View File

@ -9,23 +9,24 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Login to GHCR
- name: Git describe
id: ghd
uses: proudust/gh-describe@v2
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
push: true
tags: ghcr.io/go-vikunja/vikunja:unstable
tags: ghcr.io/go-vikunja/vikunja:unstable
build-args: |
RELEASE_VERSION:${{ steps.ghd.outputs.describe }}

View File

@ -22,7 +22,8 @@ WORKDIR /go/src/code.vikunja.io/api
COPY . ./
COPY --from=frontendbuilder /build/dist ./frontend/dist
ARG TARGETOS TARGETARCH TARGETVARIANT
ARG TARGETOS TARGETARCH TARGETVARIANT RELEASE_VERSION
ENV RELEASE_VERSION=$RELEASE_VERSION
ENV GOPROXY=https://goproxy.kolaente.de
RUN export PATH=$PATH:$GOPATH/bin && \

View File

@ -37,7 +37,6 @@ import (
"time"
"github.com/iancoleman/strcase"
"github.com/magefile/mage/mg"
"golang.org/x/sync/errgroup"
)
@ -92,24 +91,41 @@ func runCmdWithOutput(name string, arg ...string) (output []byte, err error) {
return output, nil
}
func getRawVersionString() (version string, err error) {
versionEnv := os.Getenv("RELEASE_VERSION")
if versionEnv != "" {
return versionEnv, nil
}
if os.Getenv("DRONE_TAG") != "" {
return os.Getenv("DRONE_TAG"), nil
}
if os.Getenv("DRONE_BRANCH") != "" {
version = strings.Replace(os.Getenv("DRONE_BRANCH"), "release/v", "", 1)
}
if version == "main" {
version = "unstable"
}
if version != "" {
return
}
versionBytes, err := runCmdWithOutput("git", "describe", "--tags", "--always", "--abbrev=10")
return string(versionBytes), err
}
func setVersion() {
version, err := runCmdWithOutput("git", "describe", "--tags", "--always", "--abbrev=10")
version, err := getRawVersionString()
if err != nil {
fmt.Printf("Error getting version: %s\n", err)
os.Exit(1)
}
VersionNumber = strings.Trim(string(version), "\n")
VersionNumber = strings.Trim(version, "\n")
VersionNumber = strings.Replace(VersionNumber, "-g", "-", 1)
if os.Getenv("DRONE_TAG") != "" {
Version = os.Getenv("DRONE_TAG")
} else if os.Getenv("DRONE_BRANCH") != "" {
Version = strings.Replace(os.Getenv("DRONE_BRANCH"), "release/v", "", 1)
}
if Version == "main" {
Version = "unstable"
}
Version = version
}
func setBinLocation() {