feat: add build time and commit hash to server info and improve nightly release workflow

- Expose BuildTime and CommitHash in core constants and health endpoints (/api/info)
- Refactor nightly release workflow to delete only assets instead of the entire release tag
- Rename github-action make target to run-github-action for clarity and consistency
This commit is contained in:
j3ssie
2026-01-26 02:11:26 +08:00
parent bbba13501f
commit dcb71d3b1d
6 changed files with 27 additions and 14 deletions
+6 -11
View File
@@ -24,20 +24,15 @@ jobs:
with:
go-version: '1.25'
- name: Delete existing nightly release
- name: Delete existing nightly release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Delete release if exists (tag will be force-updated)
gh release delete v0.0.0-nightly --yes || true
- name: Create or update nightly tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Use semver-compliant tag for GoReleaser v2
git tag -fa v0.0.0-nightly -m "Nightly build $(date -u +%Y-%m-%d)"
git push origin v0.0.0-nightly --force
TAG="v0.0.0-nightly"
gh release view "$TAG" --json assets -q '.assets[].name' | while read -r asset; do
echo "Deleting asset: $asset"
gh release delete-asset "$TAG" "$asset" --yes
done
- name: Create release notes
run: |
+3 -3
View File
@@ -1,4 +1,4 @@
.PHONY: build run test test-unit test-integration test-workflow-integration test-e2e test-e2e-verbose test-e2e-ssh test-e2e-api test-e2e-nix test-e2e-install test-docker test-ssh test-distributed test-all test-summary test-ci clean install install-gotestsum lint fmt db-seed db-clean db-migrate run-server-debug swagger update-ui snapshot-release github-release github-action docker-toolbox docker-toolbox-run docker-toolbox-shell docker-publish
.PHONY: build run test test-unit test-integration test-workflow-integration test-e2e test-e2e-verbose test-e2e-ssh test-e2e-api test-e2e-nix test-e2e-install test-docker test-ssh test-distributed test-all test-summary test-ci clean install install-gotestsum lint fmt db-seed db-clean db-migrate run-server-debug swagger update-ui snapshot-release github-release run-github-action docker-toolbox docker-toolbox-run docker-toolbox-shell docker-publish
# Go parameters
GOCMD=go
@@ -317,7 +317,7 @@ github-release:
@echo "$(PREFIX) Building and publishing GitHub release..."
export GORELEASER_CURRENT_TAG="$(VERSION)" && goreleaser release --clean
github-action:
run-github-action:
unset GH_TOKEN &&gh workflow run manual-release.yaml && gh workflow run nightly-release.yaml
# Database commands
@@ -393,7 +393,7 @@ help:
@echo " make snapshot-release Build local snapshot release (no publish)"
@echo " make local-release Build local snapshot for mac/linux arm (testing)"
@echo " make github-release Build and publish GitHub release"
@echo " make github-action Trigger manual and nightly GitHub workflows"
@echo " make run-github-action Trigger manual and nightly GitHub workflows"
@echo ""
@echo "\033[33m DATABASE\033[0m"
@echo " make db-seed Seed database with sample data"
+3
View File
@@ -1,6 +1,7 @@
package main
import (
"github.com/j3ssie/osmedeus/v5/internal/core"
"github.com/j3ssie/osmedeus/v5/pkg/cli"
)
@@ -32,6 +33,8 @@ var (
// @description JWT Bearer token authentication. Format: "Bearer {token}"
func main() {
core.BuildTime = BuildTime
core.CommitHash = CommitHash
cli.SetBuildInfo(BuildTime, CommitHash)
cli.Execute()
}
+3
View File
@@ -29,3 +29,6 @@ const (
// DefaultUA is the default User-Agent for HTTP clients
DefaultUA = "Mozilla/5.0 (compatible; Osmedeus/" + VERSION + "; +" + REPO_URL + ")"
)
var BuildTime = "unknown"
var CommitHash = "unknown"
+6
View File
@@ -15,6 +15,8 @@ type ServerInfoData struct {
Repo string
Author string
Docs string
Build string
Commit string
}
// cachedServerInfo holds server info set once at startup
@@ -68,6 +70,8 @@ func Root(cfg *config.Config) fiber.Handler {
"author": cachedServerInfo.Author,
"docs": cachedServerInfo.Docs,
"license": cachedServerInfo.License,
"build": cachedServerInfo.Build,
"commit": cachedServerInfo.Commit,
})
}
}
@@ -88,6 +92,8 @@ func ServerInfo(cfg *config.Config) fiber.Handler {
"author": cachedServerInfo.Author,
"docs": cachedServerInfo.Docs,
"license": cachedServerInfo.License,
"build": cachedServerInfo.Build,
"commit": cachedServerInfo.Commit,
})
}
}
+6
View File
@@ -51,6 +51,8 @@ var cachedServerInfo struct {
Repo string
Author string
Docs string
Build string
Commit string
}
// Server represents the web server
@@ -107,6 +109,8 @@ func New(cfg *config.Config, opts *Options) (*Server, error) {
cachedServerInfo.Repo = core.REPO_URL
cachedServerInfo.Author = core.AUTHOR
cachedServerInfo.Docs = core.DOCS
cachedServerInfo.Build = core.BuildTime
cachedServerInfo.Commit = core.CommitHash
// Set cached info for handlers to use
handlers.SetServerInfo(&handlers.ServerInfoData{
@@ -116,6 +120,8 @@ func New(cfg *config.Config, opts *Options) (*Server, error) {
Repo: cachedServerInfo.Repo,
Author: cachedServerInfo.Author,
Docs: cachedServerInfo.Docs,
Build: cachedServerInfo.Build,
Commit: cachedServerInfo.Commit,
})
// Select error handler based on debug mode