Skip to content

Commit

Permalink
Adding semver.go support
Browse files Browse the repository at this point in the history
  • Loading branch information
riya-kaushal7997 committed Feb 3, 2025
1 parent 10c316b commit 0bf43a6
Show file tree
Hide file tree
Showing 6 changed files with 409 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
# limitations under the License.
# Includes the following generated file to get semantic version information

MAJOR=1
MINOR=12
PATCH=0
VERSION?="v$(MAJOR).$(MINOR).$(PATCH)"
REGISTRY?="${REGISTRY_HOST}:${REGISTRY_PORT}/podmon"

all: clean podman push

unit-test:
Expand All @@ -30,12 +24,12 @@ clean:
build:
GOOS=linux CGO_ENABLED=0 go build -o podmon ./cmd/podmon/

podman: download-csm-common
$(eval include csm-common.mk)
podman build --pull --no-cache -t "$(REGISTRY):$(VERSION)" --build-arg GOIMAGE=$(DEFAULT_GOIMAGE) --build-arg BASEIMAGE=$(CSM_BASEIMAGE) -f ./Dockerfile --label commit=$(shell git log --max-count 1 --format="%H") .
podman:
go run core/semver/semver.go -f mk >semver.mk
make -f docker.mk podman

push:
podman push "$(REGISTRY):$(VERSION)"
make -f docker.mk push

download-csm-common:
curl -O -L https://raw.githubusercontent.com/dell/csm/main/config/csm-common.mk
Expand Down
1 change: 1 addition & 0 deletions core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
core_generated.go
34 changes: 34 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright © 2021 - 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate go run semver/semver.go -f semver.tpl -o core_generated.go

package core

import "time"

var (
// SemVer is the semantic version.
SemVer = "unknown"

// CommitSha7 is the short version of the commit hash from which
// this program was built.
CommitSha7 string

// CommitSha32 is the long version of the commit hash from which
// this program was built.
CommitSha32 string

// CommitTime is the commit timestamp of the commit from which
// this program was built.
CommitTime time.Time
)
11 changes: 11 additions & 0 deletions core/semver.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package core

import "time"

func init() {
SemVer = "{{.SemVer}}"
CommitSha7 = "{{.Sha7}}"
CommitSha32 = "{{.Sha32}}"
CommitTime = time.Unix({{.Epoch}}, 0)
}

Loading

0 comments on commit 0bf43a6

Please sign in to comment.