Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,23 @@ jobs:
type=sha,format=short
flavor: latest=auto

- name: Build date
id: date
run: echo "value=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
# Stamps internal/version so `ignis -version` reports the release.
# meta.version is the tag without the leading v (0.5.0), matching
# the published image tag.
build-args: |
VERSION=${{ steps.meta.outputs.version }}
COMMIT=${{ github.sha }}
DATE=${{ steps.date.outputs.value }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.name }}
Expand Down
2 changes: 2 additions & 0 deletions cmd/build_db/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/thd-spatial-ai/ignis/internal/config"
importer "github.com/thd-spatial-ai/ignis/internal/db"
"github.com/thd-spatial-ai/ignis/internal/utils"
"github.com/thd-spatial-ai/ignis/internal/version"
"log"
"time"

Expand All @@ -16,6 +17,7 @@ func main() {
startTime := time.Now()
fmt.Println("============================================================")
fmt.Println("=== ignis Database Rebuild Tool ===")
fmt.Printf("=== %s\n", version.String())
fmt.Println("============================================================")
fmt.Println("")

Expand Down
6 changes: 1 addition & 5 deletions cmd/ignis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import (
"github.com/thd-spatial-ai/ignis/internal/version"
)

func versionString() string {
return fmt.Sprintf("%s (commit %s, built %s)", version.Version, version.Commit, version.Date)
}

// parseVersionFlag reports whether args request the version string, so the
// flag-handling decision can be tested without starting a server or exiting.
func parseVersionFlag(args []string) bool {
Expand All @@ -28,7 +24,7 @@ func parseVersionFlag(args []string) bool {
// Setup app server and routes
func main() {
if parseVersionFlag(os.Args[1:]) {
fmt.Println(versionString())
fmt.Println(version.String())
os.Exit(0)
}

Expand Down
12 changes: 0 additions & 12 deletions cmd/ignis/main_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
package main

import (
"strings"
"testing"

"github.com/thd-spatial-ai/ignis/internal/version"
)

func TestVersionString(t *testing.T) {
got := versionString()
for _, want := range []string{version.Version, version.Commit, version.Date} {
if !strings.Contains(got, want) {
t.Errorf("versionString() = %q, want it to contain %q", got, want)
}
}
}

func TestParseVersionFlag(t *testing.T) {
cases := map[string][]string{
"no flags": {},
Expand Down
13 changes: 12 additions & 1 deletion environment/ignis-app.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ COPY go.mod go.sum ./
RUN go mod download

COPY . .
# Passed by the publish workflow on a tag build; default to the same values
# internal/version hard-codes, so a plain `docker build` is unchanged.
ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown
# -buildvcs=false: the build context may contain .git, and the toolchain's
# VCS stamping shells out to git, which fails on an ownership mismatch in CI.
# The image is identified by its release tag, so the stamp buys nothing.
RUN CGO_ENABLED=0 go build -buildvcs=false -o /out/ignis ./cmd/ignis
# -X: same three variables release.yml stamps into the standalone binaries.
RUN CGO_ENABLED=0 go build -buildvcs=false \
-ldflags="-s -w \
-X github.com/thd-spatial-ai/ignis/internal/version.Version=${VERSION} \
-X github.com/thd-spatial-ai/ignis/internal/version.Commit=${COMMIT} \
-X github.com/thd-spatial-ai/ignis/internal/version.Date=${DATE}" \
-o /out/ignis ./cmd/ignis

# ---------------------------------------------------------------------------
# Stage 2: final — only the compiled server binary, no compiler/source/git
Expand Down
12 changes: 11 additions & 1 deletion environment/ignis-db.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 go build -buildvcs=false -o /out/build_db ./cmd/build_db
# Passed by the publish workflow on a tag build; default to the same values
# internal/version hard-codes, so a plain `docker build` is unchanged.
ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown
RUN CGO_ENABLED=0 go build -buildvcs=false \
-ldflags="-s -w \
-X github.com/thd-spatial-ai/ignis/internal/version.Version=${VERSION} \
-X github.com/thd-spatial-ai/ignis/internal/version.Commit=${COMMIT} \
-X github.com/thd-spatial-ai/ignis/internal/version.Date=${DATE}" \
-o /out/build_db ./cmd/build_db

# ---------------------------------------------------------------------------
# Stage 2: final — compiled binary + the trimmed TABULA workbook baked in.
Expand Down
10 changes: 10 additions & 0 deletions internal/version/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package version

import "fmt"

var (
Version = "dev"
Commit = "none"
Date = "unknown"
)

// String renders the build's version, commit and date on one line.
// The three vars are set at link time by -ldflags -X (see release.yml and
// the environment/*.dockerfile builds); an unstamped build reports the
// hard-coded defaults.
func String() string {
return fmt.Sprintf("%s (commit %s, built %s)", Version, Commit, Date)
}
15 changes: 15 additions & 0 deletions internal/version/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package version

import (
"strings"
"testing"
)

func TestString(t *testing.T) {
got := String()
for _, want := range []string{Version, Commit, Date} {
if !strings.Contains(got, want) {
t.Errorf("String() = %q, want it to contain %q", got, want)
}
}
}
Loading