Merge pull request #1921 from kubescape/buildnumber

Update build number retrieval and permissions in workflow
This commit is contained in:
Matthias Bertschy
2026-01-16 12:21:04 +00:00
committed by GitHub
4 changed files with 12 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ jobs:
pr-scanner:
permissions:
actions: read
artifact-metadata: read
attestations: read
checks: read
contents: write
@@ -37,7 +38,6 @@ jobs:
repository-projects: read
security-events: read
statuses: read
artifact-metadata: read
uses: ./.github/workflows/a-pr-scanner.yaml
with:
RELEASE: ""

View File

@@ -70,8 +70,7 @@ jobs:
- name: golangci-lint
continue-on-error: false
uses: golangci/golangci-lint-action@v8
uses: golangci/golangci-lint-action@v9
with:
version: v2.1
args: --timeout 10m
only-new-issues: true

View File

@@ -36,7 +36,6 @@ builds:
- arm64
ldflags:
- -s -w
- -X "github.com/kubescape/kubescape/v3/core/cautils.BuildNumber={{.Env.RELEASE}}"
- -X "github.com/kubescape/kubescape/v3/core/cautils.Client={{.Env.CLIENT}}"
hooks:
post:

View File

@@ -2,19 +2,25 @@ package cautils
import (
"os"
"runtime/debug"
"github.com/kubescape/backend/pkg/versioncheck"
)
var BuildNumber string
var Client string
func init() {
if BuildNumber != "" {
versioncheck.BuildNumber = BuildNumber
} else {
// Try to get version from build info (Go 1.24+ automatically populates this from VCS tags)
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" && info.Main.Version != "(devel)" {
versioncheck.BuildNumber = info.Main.Version
}
// Fallback to RELEASE environment variable
if versioncheck.BuildNumber == "" {
versioncheck.BuildNumber = os.Getenv("RELEASE")
}
// Client is typically set via ldflags: -X "github.com/kubescape/kubescape/v3/core/cautils.Client=..."
if Client != "" {
versioncheck.Client = Client
}