Skip to content

[DEV] Improve how versioning is handle between main driver and plugins #19

@davidallendj

Description

@davidallendj

Short Description
The configurator currently has a way of checking if both the main driver and generator plugins are built using the same git commit. This tends to work fine when the binaries are being built within a clone repository, but fails when built externally, since the method for getting the version commit is just running a git command:

func GitCommit() string {
	c := exec.Command("git", "rev-parse", "--short=8", "HEAD")
	stdout, err := c.Output()
	if err != nil {
		return ""
	}

	return strings.TrimRight(string(stdout), "\n")
}

Instead, it may be a better idea to use a version tag (with commit as well if necessary) that gets injected when building the binaries. Having the version tag injected external to the program itself should allow the version tag to be included when the binaries are built external to the repository.

Definition of Done
This task will be considered complete once the versioning is done external to configurator through a script or the Makefile.

Additional context
There are examples from SMD and magellan how this task should be completed. The main program must contain variables that are set via LDFLAGS when building:

LDFLAGS="-s -X=$(GIT)main.commit=$(BUILD) -X=$(GIT)main.version=$(VERSION) -X=$(GIT)main.date=$(shell date +%Y-%m-%d:%H:%M:%S)"

The main program should contain variables like so:

var (
	version string
	commit  string
	date    string
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions