mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-11 15:39:33 -05:00
Update pseudo-version script to determine future release version based on branch name
This commit is contained in:
parent
fdcdd5fb78
commit
2d87db3914
65
.github/actions/pseudo_version/action.yml
vendored
65
.github/actions/pseudo_version/action.yml
vendored
@ -8,6 +8,9 @@ outputs:
|
||||
semanticVersion:
|
||||
description: "Semantic version based on the current HEAD"
|
||||
value: ${{ steps.pseudo-version.outputs.semanticVersion }}
|
||||
releaseVersion:
|
||||
description: "Release version based on branch name"
|
||||
value: ${{ steps.pseudo-version.outputs.releaseVersion }}
|
||||
timestamp:
|
||||
description: "Commit timestamp based on the current HEAD"
|
||||
value: ${{ steps.pseudo-version.outputs.timestamp }}
|
||||
@ -16,35 +19,37 @@ outputs:
|
||||
value: ${{ steps.pseudo-version.outputs.branchName }}
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a
|
||||
with:
|
||||
go-version: "1.18"
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a
|
||||
with:
|
||||
go-version: "1.18"
|
||||
|
||||
- name: get pseudo version
|
||||
id: pseudo-version
|
||||
run: |
|
||||
set -e
|
||||
set -o pipefail
|
||||
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)"
|
||||
export GOCACHE=${homedir}/.cache/go-build
|
||||
export GOPATH=${homedir}/go
|
||||
export GOPRIVATE=github.com/edgelesssys
|
||||
export GOMODCACHE=${homedir}/.cache/go-mod
|
||||
pseudoVersion=$(go run .)
|
||||
semanticVersion=$(go run . -semantic-version)
|
||||
timestamp=$(go run . -print-timestamp)
|
||||
branchName=$(go run . -print-branch)
|
||||
echo "::set-output name=pseudoVersion::${pseudoVersion}"
|
||||
echo "::set-output name=semanticVersion::${semanticVersion}"
|
||||
echo "::set-output name=timestamp::${timestamp}"
|
||||
echo "::set-output name=branchName::${branchName}"
|
||||
working-directory: hack/pseudo-version
|
||||
shell: bash {0}
|
||||
- name: get pseudo version
|
||||
id: pseudo-version
|
||||
run: |
|
||||
set -e
|
||||
set -o pipefail
|
||||
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)"
|
||||
export GOCACHE=${homedir}/.cache/go-build
|
||||
export GOPATH=${homedir}/go
|
||||
export GOPRIVATE=github.com/edgelesssys
|
||||
export GOMODCACHE=${homedir}/.cache/go-mod
|
||||
pseudoVersion=$(go run .)
|
||||
semanticVersion=$(go run . -semantic-version)
|
||||
timestamp=$(go run . -print-timestamp)
|
||||
branchName=$(go run . -print-branch)
|
||||
releaseVersion=$(go run . -print-release-branch)
|
||||
echo "::set-output name=pseudoVersion::${pseudoVersion}"
|
||||
echo "::set-output name=semanticVersion::${semanticVersion}"
|
||||
echo "::set-output name=timestamp::${timestamp}"
|
||||
echo "::set-output name=branchName::${branchName}"
|
||||
echo "::set-output name=releaseVersion::${releaseVersion}"
|
||||
working-directory: hack/pseudo-version
|
||||
shell: bash {0}
|
||||
|
5
.github/workflows/build-coreos.yml
vendored
5
.github/workflows/build-coreos.yml
vendored
@ -88,15 +88,16 @@ jobs:
|
||||
run: |
|
||||
timestamp=${{ steps.version.outputs.timestamp }}
|
||||
semver=${{ steps.version.outputs.semanticVersion }}
|
||||
releaseVersion=${{ steps.version.outputs.releaseVersion }}
|
||||
pseudover=${{ steps.version.outputs.pseudoVersion }}
|
||||
echo "azureImageName=constellation-${pseudover//./-}" >> $GITHUB_ENV
|
||||
if [ "${{ startsWith(github.ref, 'refs/heads/release/') && (inputs.debug == false) }}" = true ]
|
||||
then
|
||||
echo "gcpImageName=constellation-${semver//./-}" >> $GITHUB_ENV
|
||||
echo "gcpImageName=constellation-${releaseVersion//./-}" >> $GITHUB_ENV
|
||||
echo "gcpImageFamily=constellation" >> $GITHUB_ENV
|
||||
echo "azureGalleryName=Constellation" >> $GITHUB_ENV
|
||||
echo "azureImageDefinition=constellation" >> $GITHUB_ENV
|
||||
echo "azureImageVersion=${semver:1}" >> $GITHUB_ENV
|
||||
echo "azureImageVersion=${releaseVersion:1}" >> $GITHUB_ENV
|
||||
elif [ "${{ ((github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/heads/release/')) && (inputs.debug == true) }}" = true ]
|
||||
then
|
||||
echo "gcpImageName=constellation-${{ steps.version.outputs.timestamp }}" >> $GITHUB_ENV
|
||||
|
@ -100,6 +100,14 @@ func (g *Git) ParsedBranchName() (string, error) {
|
||||
return strings.TrimSuffix(branch, "-"), nil
|
||||
}
|
||||
|
||||
func (g *Git) BranchName() (string, error) {
|
||||
commitRef, err := g.repo.Head()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return commitRef.Name().Short(), nil
|
||||
}
|
||||
|
||||
// tagsByRevisionHash returns a map from revision hash to a list of associated tags.
|
||||
func (g *Git) tagsByRevisionHash() (map[string][]string, error) {
|
||||
tags := make(map[string][]string)
|
||||
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/edgelesssys/constellation/hack/pseudo-version/internal/git"
|
||||
@ -16,6 +17,7 @@ func main() {
|
||||
printSemVer := flag.Bool("semantic-version", false, "Only print semantic version")
|
||||
printTimestamp := flag.Bool("print-timestamp", false, "Only print timestamp")
|
||||
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")
|
||||
base := flag.String("base", "", "Optional base version")
|
||||
revisionTimestamp := flag.String("time", "", "Optional revision time")
|
||||
@ -29,7 +31,12 @@ func main() {
|
||||
log.With(zap.Error(err)).Fatalf("Failed to initialize git client")
|
||||
}
|
||||
|
||||
branch, err := gitc.ParsedBranchName()
|
||||
parsedBranch, err := gitc.ParsedBranchName()
|
||||
if err != nil {
|
||||
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")
|
||||
}
|
||||
@ -72,7 +79,9 @@ func main() {
|
||||
case *printTimestamp:
|
||||
fmt.Println(headTime.Format("20060102150405"))
|
||||
case *printBranch:
|
||||
fmt.Println(branch)
|
||||
fmt.Println(parsedBranch)
|
||||
case *printReleaseVersion:
|
||||
fmt.Println(strings.TrimPrefix(rawBranch, "release/"))
|
||||
default:
|
||||
fmt.Println(version)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user