mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-06-19 11:44:20 -04:00
Update pseudo-version script to determine future release version based on branch name
This commit is contained in:
parent
fdcdd5fb78
commit
2d87db3914
4 changed files with 57 additions and 34 deletions
65
.github/actions/pseudo_version/action.yml
vendored
65
.github/actions/pseudo_version/action.yml
vendored
|
@ -8,6 +8,9 @@ outputs:
|
||||||
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:
|
||||||
|
description: "Release version based on branch name"
|
||||||
|
value: ${{ steps.pseudo-version.outputs.releaseVersion }}
|
||||||
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 }}
|
||||||
|
@ -16,35 +19,37 @@ outputs:
|
||||||
value: ${{ steps.pseudo-version.outputs.branchName }}
|
value: ${{ steps.pseudo-version.outputs.branchName }}
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a
|
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a
|
||||||
with:
|
with:
|
||||||
go-version: "1.18"
|
go-version: "1.18"
|
||||||
|
|
||||||
- name: get pseudo version
|
- name: get pseudo version
|
||||||
id: pseudo-version
|
id: pseudo-version
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
if $(git rev-parse --is-shallow-repository); then
|
if $(git rev-parse --is-shallow-repository); then
|
||||||
git fetch --prune --unshallow --tags -v
|
git fetch --prune --unshallow --tags -v
|
||||||
else
|
else
|
||||||
git fetch --tags -v
|
git fetch --tags -v
|
||||||
fi
|
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 GOPRIVATE=github.com/edgelesssys
|
export GOPRIVATE=github.com/edgelesssys
|
||||||
export GOMODCACHE=${homedir}/.cache/go-mod
|
export GOMODCACHE=${homedir}/.cache/go-mod
|
||||||
pseudoVersion=$(go run .)
|
pseudoVersion=$(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)
|
||||||
echo "::set-output name=pseudoVersion::${pseudoVersion}"
|
releaseVersion=$(go run . -print-release-branch)
|
||||||
echo "::set-output name=semanticVersion::${semanticVersion}"
|
echo "::set-output name=pseudoVersion::${pseudoVersion}"
|
||||||
echo "::set-output name=timestamp::${timestamp}"
|
echo "::set-output name=semanticVersion::${semanticVersion}"
|
||||||
echo "::set-output name=branchName::${branchName}"
|
echo "::set-output name=timestamp::${timestamp}"
|
||||||
working-directory: hack/pseudo-version
|
echo "::set-output name=branchName::${branchName}"
|
||||||
shell: bash {0}
|
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: |
|
run: |
|
||||||
timestamp=${{ steps.version.outputs.timestamp }}
|
timestamp=${{ steps.version.outputs.timestamp }}
|
||||||
semver=${{ steps.version.outputs.semanticVersion }}
|
semver=${{ steps.version.outputs.semanticVersion }}
|
||||||
|
releaseVersion=${{ steps.version.outputs.releaseVersion }}
|
||||||
pseudover=${{ steps.version.outputs.pseudoVersion }}
|
pseudover=${{ steps.version.outputs.pseudoVersion }}
|
||||||
echo "azureImageName=constellation-${pseudover//./-}" >> $GITHUB_ENV
|
echo "azureImageName=constellation-${pseudover//./-}" >> $GITHUB_ENV
|
||||||
if [ "${{ startsWith(github.ref, 'refs/heads/release/') && (inputs.debug == false) }}" = true ]
|
if [ "${{ startsWith(github.ref, 'refs/heads/release/') && (inputs.debug == false) }}" = true ]
|
||||||
then
|
then
|
||||||
echo "gcpImageName=constellation-${semver//./-}" >> $GITHUB_ENV
|
echo "gcpImageName=constellation-${releaseVersion//./-}" >> $GITHUB_ENV
|
||||||
echo "gcpImageFamily=constellation" >> $GITHUB_ENV
|
echo "gcpImageFamily=constellation" >> $GITHUB_ENV
|
||||||
echo "azureGalleryName=Constellation" >> $GITHUB_ENV
|
echo "azureGalleryName=Constellation" >> $GITHUB_ENV
|
||||||
echo "azureImageDefinition=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 ]
|
elif [ "${{ ((github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/heads/release/')) && (inputs.debug == true) }}" = true ]
|
||||||
then
|
then
|
||||||
echo "gcpImageName=constellation-${{ steps.version.outputs.timestamp }}" >> $GITHUB_ENV
|
echo "gcpImageName=constellation-${{ steps.version.outputs.timestamp }}" >> $GITHUB_ENV
|
||||||
|
|
|
@ -100,6 +100,14 @@ func (g *Git) ParsedBranchName() (string, error) {
|
||||||
return strings.TrimSuffix(branch, "-"), nil
|
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.
|
// tagsByRevisionHash returns a map from revision hash to a list of associated tags.
|
||||||
func (g *Git) tagsByRevisionHash() (map[string][]string, error) {
|
func (g *Git) tagsByRevisionHash() (map[string][]string, error) {
|
||||||
tags := make(map[string][]string)
|
tags := make(map[string][]string)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/hack/pseudo-version/internal/git"
|
"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")
|
printSemVer := flag.Bool("semantic-version", false, "Only print semantic version")
|
||||||
printTimestamp := flag.Bool("print-timestamp", false, "Only print timestamp")
|
printTimestamp := flag.Bool("print-timestamp", false, "Only print timestamp")
|
||||||
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")
|
||||||
|
@ -29,7 +31,12 @@ func main() {
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to initialize git client")
|
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 {
|
if err != nil {
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to get branch name")
|
log.With(zap.Error(err)).Fatalf("Failed to get branch name")
|
||||||
}
|
}
|
||||||
|
@ -72,7 +79,9 @@ func main() {
|
||||||
case *printTimestamp:
|
case *printTimestamp:
|
||||||
fmt.Println(headTime.Format("20060102150405"))
|
fmt.Println(headTime.Format("20060102150405"))
|
||||||
case *printBranch:
|
case *printBranch:
|
||||||
fmt.Println(branch)
|
fmt.Println(parsedBranch)
|
||||||
|
case *printReleaseVersion:
|
||||||
|
fmt.Println(strings.TrimPrefix(rawBranch, "release/"))
|
||||||
default:
|
default:
|
||||||
fmt.Println(version)
|
fmt.Println(version)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue