mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-03 06:44:50 -04:00
introduce version.txt (#1412)
This commit is contained in:
parent
bdff0d1d08
commit
fe767ba78e
15 changed files with 53 additions and 161 deletions
2
.bazelrc
2
.bazelrc
|
@ -12,7 +12,7 @@ build --incompatible_enable_cc_toolchain_resolution
|
||||||
build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
|
build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
|
||||||
|
|
||||||
# inject version information into binaries
|
# inject version information into binaries
|
||||||
build --stamp --workspace_status_command=tools/workspace_status
|
build --stamp --workspace_status_command=tools/workspace_status.sh
|
||||||
|
|
||||||
# strip binaries for better reproducibility
|
# strip binaries for better reproducibility
|
||||||
build --strip=always
|
build --strip=always
|
||||||
|
|
6
.github/actions/build_ko/action.yml
vendored
6
.github/actions/build_ko/action.yml
vendored
|
@ -83,11 +83,11 @@ runs:
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${{ steps.pseudo-version.outputs.pseudoVersion }}" ]]; then
|
if [[ -n "${{ steps.pseudo-version.outputs.version }}" ]]; then
|
||||||
if [[ -n "${tags}" ]]; then
|
if [[ -n "${tags}" ]]; then
|
||||||
tags="${tags},${{ steps.pseudo-version.outputs.pseudoVersion }}"
|
tags="${tags},${{ steps.pseudo-version.outputs.version }}"
|
||||||
else
|
else
|
||||||
tags="${{ steps.pseudo-version.outputs.pseudoVersion }}"
|
tags="${{ steps.pseudo-version.outputs.version }}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ runs:
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
type=raw,value=${{ inputs.pushTag }},enable=${{ '' != inputs.pushTag }}
|
type=raw,value=${{ inputs.pushTag }},enable=${{ '' != inputs.pushTag }}
|
||||||
type=raw,value=${{ steps.pseudo-version.outputs.pseudoVersion }},enable=${{ '' != steps.pseudo-version.outputs.pseudoVersion }}
|
type=raw,value=${{ steps.pseudo-version.outputs.version }},enable=${{ '' != steps.pseudo-version.outputs.version }}
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
|
|
12
.github/actions/build_operator/action.yml
vendored
12
.github/actions/build_operator/action.yml
vendored
|
@ -53,7 +53,7 @@ runs:
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
type=raw,value=${{ inputs.pushTag }},enable=${{ '' != inputs.pushTag }}
|
type=raw,value=${{ inputs.pushTag }},enable=${{ '' != inputs.pushTag }}
|
||||||
type=raw,value=${{ steps.pseudo-version.outputs.pseudoVersion }},enable=${{ '' != steps.pseudo-version.outputs.pseudoVersion }}
|
type=raw,value=${{ steps.pseudo-version.outputs.version }},enable=${{ '' != steps.pseudo-version.outputs.version }}
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
|
|
||||||
- name: Build and push container image
|
- name: Build and push container image
|
||||||
|
@ -75,11 +75,11 @@ runs:
|
||||||
cosignPassword: ${{ inputs.cosignPassword }}
|
cosignPassword: ${{ inputs.cosignPassword }}
|
||||||
|
|
||||||
- name: Bundle for pseudo version
|
- name: Bundle for pseudo version
|
||||||
if: steps.pseudo-version.outputs.pseudoVersion != '' && inputs.pushTag == ''
|
if: steps.pseudo-version.outputs.version != '' && inputs.pushTag == ''
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: ${{ inputs.sourceDir }}
|
working-directory: ${{ inputs.sourceDir }}
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ steps.pseudo-version.outputs.pseudoVersion }}
|
VERSION: ${{ steps.pseudo-version.outputs.version }}
|
||||||
run: make bundle VERSION=${VERSION#v}
|
run: make bundle VERSION=${VERSION#v}
|
||||||
|
|
||||||
- name: Bundle for semantic version
|
- name: Bundle for semantic version
|
||||||
|
@ -99,7 +99,7 @@ runs:
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
type=raw,value=${{ inputs.pushTag }},enable=${{ '' != inputs.pushTag }}
|
type=raw,value=${{ inputs.pushTag }},enable=${{ '' != inputs.pushTag }}
|
||||||
type=raw,value=${{ steps.pseudo-version.outputs.pseudoVersion }},enable=${{ '' != steps.pseudo-version.outputs.pseudoVersion }}
|
type=raw,value=${{ steps.pseudo-version.outputs.version }},enable=${{ '' != steps.pseudo-version.outputs.version }}
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
|
|
||||||
- name: Build and push bundle image
|
- name: Build and push bundle image
|
||||||
|
@ -121,11 +121,11 @@ runs:
|
||||||
cosignPassword: ${{ inputs.cosignPassword }}
|
cosignPassword: ${{ inputs.cosignPassword }}
|
||||||
|
|
||||||
- name: Build and push catalog for pseudo versions
|
- name: Build and push catalog for pseudo versions
|
||||||
if: steps.pseudo-version.outputs.pseudoVersion != '' && inputs.pushTag == ''
|
if: steps.pseudo-version.outputs.version != '' && inputs.pushTag == ''
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: ${{ inputs.sourceDir }}
|
working-directory: ${{ inputs.sourceDir }}
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ steps.pseudo-version.outputs.pseudoVersion }}
|
VERSION: ${{ steps.pseudo-version.outputs.version }}
|
||||||
run: make VERSION=${VERSION#v} catalog-build catalog-push
|
run: make VERSION=${VERSION#v} catalog-build catalog-push
|
||||||
|
|
||||||
- name: Build and push catalog for releases
|
- name: Build and push catalog for releases
|
||||||
|
|
|
@ -205,8 +205,6 @@ runs:
|
||||||
imageType: ${{ inputs.imageType }}
|
imageType: ${{ inputs.imageType }}
|
||||||
timestamp: ${{ steps.version.outputs.timestamp }}
|
timestamp: ${{ steps.version.outputs.timestamp }}
|
||||||
semver: ${{ steps.version.outputs.semanticVersion }}
|
semver: ${{ steps.version.outputs.semanticVersion }}
|
||||||
pseudover: ${{ steps.version.outputs.pseudoVersion }}
|
|
||||||
branchName: ${{ steps.version.outputs.branchName }}
|
|
||||||
uploadVariant: ${{ inputs.uploadVariant }}
|
uploadVariant: ${{ inputs.uploadVariant }}
|
||||||
run: |
|
run: |
|
||||||
echo "resourceGroupName=constellation-images" >> $GITHUB_OUTPUT
|
echo "resourceGroupName=constellation-images" >> $GITHUB_OUTPUT
|
||||||
|
@ -265,7 +263,6 @@ runs:
|
||||||
imageVersion: ${{ inputs.imageVersion }}
|
imageVersion: ${{ inputs.imageVersion }}
|
||||||
imageType: ${{ inputs.imageType }}
|
imageType: ${{ inputs.imageType }}
|
||||||
timestamp: ${{ steps.version.outputs.timestamp }}
|
timestamp: ${{ steps.version.outputs.timestamp }}
|
||||||
semver: ${{ steps.version.outputs.semanticVersion }}
|
|
||||||
run: |
|
run: |
|
||||||
echo "project=constellation-images" >> $GITHUB_OUTPUT
|
echo "project=constellation-images" >> $GITHUB_OUTPUT
|
||||||
echo "bucket=constellation-images" >> $GITHUB_OUTPUT
|
echo "bucket=constellation-images" >> $GITHUB_OUTPUT
|
||||||
|
|
24
.github/actions/pseudo_version/action.yml
vendored
24
.github/actions/pseudo_version/action.yml
vendored
|
@ -2,15 +2,12 @@ name: Determine pseudo version
|
||||||
description: "Determine go-like pseudo version to use as container image tag."
|
description: "Determine go-like pseudo version to use as container image tag."
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
pseudoVersion:
|
|
||||||
description: "Pseudo version based on the current HEAD"
|
|
||||||
value: ${{ steps.pseudo-version.outputs.pseudoVersion }}
|
|
||||||
semanticVersion:
|
semanticVersion:
|
||||||
description: "Semantic version based on the current HEAD"
|
description: "Semantic version based on the current HEAD"
|
||||||
value: ${{ steps.pseudo-version.outputs.semanticVersion }}
|
value: ${{ steps.pseudo-version.outputs.semanticVersion }}
|
||||||
releaseVersion:
|
version:
|
||||||
description: "Release version based on branch name"
|
description: "Version based on branch name"
|
||||||
value: ${{ steps.pseudo-version.outputs.releaseVersion }}
|
value: ${{ steps.pseudo-version.outputs.version }}
|
||||||
timestamp:
|
timestamp:
|
||||||
description: "Commit timestamp based on the current HEAD"
|
description: "Commit timestamp based on the current HEAD"
|
||||||
value: ${{ steps.pseudo-version.outputs.timestamp }}
|
value: ${{ steps.pseudo-version.outputs.timestamp }}
|
||||||
|
@ -22,27 +19,22 @@ outputs:
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: get pseudo version
|
- name: get version
|
||||||
id: pseudo-version
|
id: pseudo-version
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: hack/pseudo-version
|
working-directory: hack/pseudo-version
|
||||||
run: |
|
run: |
|
||||||
if $(git rev-parse --is-shallow-repository); then
|
|
||||||
git fetch --prune --unshallow --tags -v
|
|
||||||
else
|
|
||||||
git fetch --tags -v
|
|
||||||
fi
|
|
||||||
homedir="$(getent passwd $(id -u) | cut -d ":" -f 6)"
|
homedir="$(getent passwd $(id -u) | cut -d ":" -f 6)"
|
||||||
export GOCACHE=${homedir}/.cache/go-build
|
export GOCACHE=${homedir}/.cache/go-build
|
||||||
export GOPATH=${homedir}/go
|
export GOPATH=${homedir}/go
|
||||||
export GOMODCACHE=${homedir}/.cache/go-mod
|
export GOMODCACHE=${homedir}/.cache/go-mod
|
||||||
pseudoVersion=$(go run .)
|
|
||||||
|
version=$(go run .)
|
||||||
semanticVersion=$(go run . -semantic-version)
|
semanticVersion=$(go run . -semantic-version)
|
||||||
timestamp=$(go run . -print-timestamp)
|
timestamp=$(go run . -print-timestamp)
|
||||||
branchName=$(go run . -print-branch)
|
branchName=$(go run . -print-branch)
|
||||||
releaseVersion=$(go run . -print-release-branch)
|
|
||||||
echo "pseudoVersion=${pseudoVersion}" >> $GITHUB_OUTPUT
|
echo "version=${version}" >> $GITHUB_OUTPUT
|
||||||
echo "semanticVersion=${semanticVersion}" >> $GITHUB_OUTPUT
|
echo "semanticVersion=${semanticVersion}" >> $GITHUB_OUTPUT
|
||||||
echo "timestamp=${timestamp}" >> $GITHUB_OUTPUT
|
echo "timestamp=${timestamp}" >> $GITHUB_OUTPUT
|
||||||
echo "branchName=${branchName}" >> $GITHUB_OUTPUT
|
echo "branchName=${branchName}" >> $GITHUB_OUTPUT
|
||||||
echo "releaseVersion=${releaseVersion}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
2
.github/workflows/build-apko-image.yml
vendored
2
.github/workflows/build-apko-image.yml
vendored
|
@ -30,7 +30,7 @@ jobs:
|
||||||
uses: ./.github/actions/build_apko
|
uses: ./.github/actions/build_apko
|
||||||
with:
|
with:
|
||||||
containerTags: |
|
containerTags: |
|
||||||
${{ steps.pseudo-version.outputs.pseudoVersion }}
|
${{ steps.pseudo-version.outputs.version }}
|
||||||
${{ github.ref_name == 'main' && 'latest' || github.ref_name }}
|
${{ github.ref_name == 'main' && 'latest' || github.ref_name }}
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
2
.github/workflows/build-os-image.yml
vendored
2
.github/workflows/build-os-image.yml
vendored
|
@ -196,7 +196,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
REF: ${{ steps.ref.outputs.ref }}
|
REF: ${{ steps.ref.outputs.ref }}
|
||||||
STREAM: ${{ steps.stream.outputs.stream }}
|
STREAM: ${{ steps.stream.outputs.stream }}
|
||||||
IMAGE_VERSION: ${{ inputs.imageVersion || steps.version.outputs.pseudoVersion }}
|
IMAGE_VERSION: ${{ inputs.imageVersion || steps.version.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
{
|
{
|
||||||
echo "imageVersion=${IMAGE_VERSION}"
|
echo "imageVersion=${IMAGE_VERSION}"
|
||||||
|
|
|
@ -5,10 +5,5 @@ go_library(
|
||||||
srcs = ["git.go"],
|
srcs = ["git.go"],
|
||||||
importpath = "github.com/edgelesssys/constellation/v2/hack/pseudo-version/internal/git",
|
importpath = "github.com/edgelesssys/constellation/v2/hack/pseudo-version/internal/git",
|
||||||
visibility = ["//hack/pseudo-version:__subpackages__"],
|
visibility = ["//hack/pseudo-version:__subpackages__"],
|
||||||
deps = [
|
deps = ["@com_github_go_git_go_git_v5//:go-git"],
|
||||||
"@com_github_go_git_go_git_v5//:go-git",
|
|
||||||
"@com_github_go_git_go_git_v5//plumbing",
|
|
||||||
"@com_github_go_git_go_git_v5//plumbing/object",
|
|
||||||
"@com_github_go_git_go_git_v5//plumbing/storer",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,20 +7,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
git "github.com/go-git/go-git/v5"
|
git "github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
|
||||||
"github.com/go-git/go-git/v5/plumbing/object"
|
|
||||||
"github.com/go-git/go-git/v5/plumbing/storer"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
versionRegex = regexp.MustCompile(`^v\d+\.\d+\.\d+(?:-pre)?$`)
|
|
||||||
tagReference = regexp.MustCompile(`^refs/tags/([^/]+)$`)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Git represents a git repository.
|
// Git represents a git repository.
|
||||||
|
@ -47,45 +39,6 @@ func (g *Git) Revision() (string, time.Time, error) {
|
||||||
return commitRef.Hash().String()[:12], commit.Committer.When, nil
|
return commitRef.Hash().String()[:12], commit.Committer.When, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FirstParentWithVersionTag returns the first parent of the HEAD commit (or HEAD itself) that has a version tag.
|
|
||||||
func (g *Git) FirstParentWithVersionTag() (revision string, versionTag string, err error) {
|
|
||||||
commitRef, err := g.repo.Head()
|
|
||||||
if err != nil {
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
commit, err := g.repo.CommitObject(commitRef.Hash())
|
|
||||||
if err != nil {
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
commitToHash, err := g.tagsByRevisionHash()
|
|
||||||
if err != nil {
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
iter := object.NewCommitIterCTime(commit, nil, nil)
|
|
||||||
if err := iter.ForEach(
|
|
||||||
func(c *object.Commit) error {
|
|
||||||
tags, ok := commitToHash[c.Hash.String()]
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
version := g.findVersionTag(tags)
|
|
||||||
if version == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
versionTag = *version
|
|
||||||
revision = c.Hash.String()
|
|
||||||
return storer.ErrStop
|
|
||||||
},
|
|
||||||
); err != nil {
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
if revision == "" || versionTag == "" {
|
|
||||||
return "", "", errors.New("no version tag found")
|
|
||||||
}
|
|
||||||
return revision, versionTag, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParsedBranchName returns the name of the current branch.
|
// ParsedBranchName returns the name of the current branch.
|
||||||
// Special characters are replaced with "-", and the name is lowercased and trimmed to 49 characters.
|
// Special characters are replaced with "-", and the name is lowercased and trimmed to 49 characters.
|
||||||
// This makes sure that the branch name is usable as a GCP image name.
|
// This makes sure that the branch name is usable as a GCP image name.
|
||||||
|
@ -117,60 +70,11 @@ func (g *Git) BranchName() (string, error) {
|
||||||
return commitRef.Name().Short(), nil
|
return commitRef.Name().Short(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// tagsByRevisionHash returns a map from revision hash to a list of associated tags.
|
// Path returns the path of the git repository.
|
||||||
func (g *Git) tagsByRevisionHash() (map[string][]string, error) {
|
func (g *Git) Path() (string, error) {
|
||||||
tags := make(map[string][]string)
|
worktree, err := g.repo.Worktree()
|
||||||
refs, err := g.repo.Tags()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", fmt.Errorf("failed to get worktree: %w", err)
|
||||||
}
|
}
|
||||||
if err := refs.ForEach(
|
return worktree.Filesystem.Root(), nil
|
||||||
func(ref *plumbing.Reference) error {
|
|
||||||
hash, err := g.tagRefToHash(ref)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
message, err := tagRefToName(ref)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
tags[hash] = append(tags[hash], message)
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return tags, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// findVersionTag tries to find a tag for a semantic version (e.g.: v1.0.0).
|
|
||||||
func (g *Git) findVersionTag(tags []string) *string {
|
|
||||||
for _, tag := range tags {
|
|
||||||
if versionRegex.MatchString(tag) {
|
|
||||||
return &tag
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *Git) tagRefToHash(tagRef *plumbing.Reference) (string, error) {
|
|
||||||
tagObject, err := g.repo.TagObject(tagRef.Hash())
|
|
||||||
switch err {
|
|
||||||
case nil:
|
|
||||||
return tagObject.Target.String(), nil
|
|
||||||
case plumbing.ErrObjectNotFound:
|
|
||||||
return tagRef.Hash().String(), nil
|
|
||||||
default:
|
|
||||||
// Some other error
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// tagRefToName extracts the name of a tag reference.
|
|
||||||
func tagRefToName(tagRef *plumbing.Reference) (string, error) {
|
|
||||||
matches := tagReference.FindStringSubmatch(tagRef.Name().String())
|
|
||||||
if len(matches) != 2 {
|
|
||||||
return "", errors.New("invalid tag reference")
|
|
||||||
}
|
|
||||||
return matches[1], nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -24,7 +26,6 @@ func main() {
|
||||||
printTimestamp := flag.Bool("print-timestamp", false, "Only print timestamp")
|
printTimestamp := flag.Bool("print-timestamp", false, "Only print timestamp")
|
||||||
timestampFormat := flag.String("timestamp-format", "20060102150405", "Timestamp format")
|
timestampFormat := flag.String("timestamp-format", "20060102150405", "Timestamp format")
|
||||||
printBranch := flag.Bool("print-branch", false, "Only print branch name")
|
printBranch := flag.Bool("print-branch", false, "Only print branch name")
|
||||||
printReleaseVersion := flag.Bool("print-release-branch", false, "Only print release branch version")
|
|
||||||
major := flag.String("major", "v0", "Optional major version")
|
major := flag.String("major", "v0", "Optional major version")
|
||||||
base := flag.String("base", "", "Optional base version")
|
base := flag.String("base", "", "Optional base version")
|
||||||
revisionTimestamp := flag.String("time", "", "Optional revision time")
|
revisionTimestamp := flag.String("time", "", "Optional revision time")
|
||||||
|
@ -44,18 +45,18 @@ func main() {
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to get parsed branch name")
|
log.With(zap.Error(err)).Fatalf("Failed to get parsed branch name")
|
||||||
}
|
}
|
||||||
|
|
||||||
rawBranch, err := gitc.BranchName()
|
|
||||||
if err != nil {
|
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to get branch name")
|
|
||||||
}
|
|
||||||
|
|
||||||
if *base == "" {
|
if *base == "" {
|
||||||
_, versionTag, err := gitc.FirstParentWithVersionTag()
|
rootPath, err := gitc.Path()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(zap.Error(err)).Warnf("Failed to find base version. Using default.")
|
log.With(zap.Error(err)).Fatalf("Failed to get git root path. Using default base version.")
|
||||||
versionTag = ""
|
} else {
|
||||||
|
versionTag, err := os.ReadFile(filepath.Join(rootPath, "version.txt"))
|
||||||
|
if err != nil {
|
||||||
|
log.With(zap.Error(err)).Warnf("Failed to read version.txt. Using default base version.")
|
||||||
|
} else {
|
||||||
|
*base = strings.TrimSpace(string(versionTag))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*base = versionTag
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var headRevision string
|
var headRevision string
|
||||||
|
@ -91,9 +92,13 @@ func main() {
|
||||||
fmt.Println(headTime.Format(*timestampFormat))
|
fmt.Println(headTime.Format(*timestampFormat))
|
||||||
case *printBranch:
|
case *printBranch:
|
||||||
fmt.Println(parsedBranch)
|
fmt.Println(parsedBranch)
|
||||||
case *printReleaseVersion:
|
|
||||||
fmt.Println(strings.TrimPrefix(rawBranch, "release/"))
|
|
||||||
default:
|
default:
|
||||||
fmt.Println(version)
|
if !strings.Contains(*base, "pre") {
|
||||||
|
// "v2.7.0" inside the version.txt will lead to "v2.7.0" as version
|
||||||
|
fmt.Println(*base)
|
||||||
|
} else {
|
||||||
|
// "2.7.0-pre" inside the version.txt will lead to "v2.7.0-pre.0.20230313121936-bab76e8a9acf" as version
|
||||||
|
fmt.Println(version)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
rm -f rpm/repo.yaml
|
rm -f rpm/repo.yaml
|
||||||
bazel run //:bazeldnf -- init \
|
bazel run //:bazeldnf -- init \
|
||||||
--fc 37 \
|
--fc 37 \
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
bazel run //:bazeldnf -- fetch \
|
bazel run //:bazeldnf -- fetch \
|
||||||
--repofile rpm/repo.yaml
|
--repofile rpm/repo.yaml
|
||||||
bazel run //:bazeldnf -- rpmtree \
|
bazel run //:bazeldnf -- rpmtree \
|
|
@ -13,12 +13,8 @@ ensure_pseudo_version_tool() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pseudo_version() {
|
pseudo_version() {
|
||||||
if [[ -f "${REPOSITORY_ROOT}/.version.txt" ]]; then
|
ensure_pseudo_version_tool
|
||||||
cat "${REPOSITORY_ROOT}/.version.txt"
|
"${REPOSITORY_ROOT}/tools/pseudo-version" -skip-v
|
||||||
else
|
|
||||||
ensure_pseudo_version_tool
|
|
||||||
"${REPOSITORY_ROOT}/tools/pseudo-version" -skip-v
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp() {
|
timestamp() {
|
1
version.txt
Normal file
1
version.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
v2.7.0-pre
|
Loading…
Add table
Add a link
Reference in a new issue