mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-24 23:19:39 -05:00
ci: upload cli version list (#1377)
* upload cli version list * fix flag * name * allow cli kind for listing * [remove] update vapi cli * allow cli kind * use latest versionsapi image version * fix kind parsing * use workflow calls in on_release action * [remove] update container tag * change back to latest tag
This commit is contained in:
parent
b356af5a39
commit
01705feb51
4
.github/actions/versionsapi/action.yml
vendored
4
.github/actions/versionsapi/action.yml
vendored
@ -22,6 +22,9 @@ inputs:
|
|||||||
version:
|
version:
|
||||||
description: --version flag
|
description: --version flag
|
||||||
required: false
|
required: false
|
||||||
|
kind:
|
||||||
|
description: --kind flag
|
||||||
|
required: false
|
||||||
version_path:
|
version_path:
|
||||||
description: --version-path flag
|
description: --version-path flag
|
||||||
required: false
|
required: false
|
||||||
@ -65,6 +68,7 @@ runs:
|
|||||||
${{ inputs.ref != '' && format('--ref="{0}"', inputs.ref) || '' }} \
|
${{ inputs.ref != '' && format('--ref="{0}"', inputs.ref) || '' }} \
|
||||||
${{ inputs.stream != '' && format('--stream="{0}"', inputs.stream) || '' }} \
|
${{ inputs.stream != '' && format('--stream="{0}"', inputs.stream) || '' }} \
|
||||||
${{ inputs.version != '' && format('--version="{0}"', inputs.version) || '' }} \
|
${{ inputs.version != '' && format('--version="{0}"', inputs.version) || '' }} \
|
||||||
|
${{ inputs.kind != '' && format('--kind="{0}"', inputs.kind) || '' }} \
|
||||||
${{ inputs.version_path != '' && format('--version-path="{0}"', inputs.version_path) || '' }} \
|
${{ inputs.version_path != '' && format('--version-path="{0}"', inputs.version_path) || '' }} \
|
||||||
${{ inputs.add_latest == 'true' && '--latest' || '' }} \
|
${{ inputs.add_latest == 'true' && '--latest' || '' }} \
|
||||||
${{ inputs.add_release == 'true' && '--release' || '' }} \
|
${{ inputs.add_release == 'true' && '--release' || '' }} \
|
||||||
|
21
.github/workflows/build-os-image.yml
vendored
21
.github/workflows/build-os-image.yml
vendored
@ -977,9 +977,9 @@ jobs:
|
|||||||
--stream=${{ needs.build-settings.outputs.stream }} \
|
--stream=${{ needs.build-settings.outputs.stream }} \
|
||||||
--version=${{ needs.build-settings.outputs.imageVersion }} \
|
--version=${{ needs.build-settings.outputs.imageVersion }} \
|
||||||
|
|
||||||
add-version-to-versionsapi:
|
add-image-version-to-versionsapi:
|
||||||
needs: [upload-artifacts, build-settings]
|
needs: [upload-artifacts, build-settings]
|
||||||
name: "Add version to versionsapi"
|
name: "Add image version to versionsapi"
|
||||||
if: needs.build-settings.outputs.ref != '-'
|
if: needs.build-settings.outputs.ref != '-'
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@ -990,4 +990,21 @@ jobs:
|
|||||||
ref: ${{ needs.build-settings.outputs.ref }}
|
ref: ${{ needs.build-settings.outputs.ref }}
|
||||||
stream: ${{ needs.build-settings.outputs.stream }}
|
stream: ${{ needs.build-settings.outputs.stream }}
|
||||||
version: ${{ needs.build-settings.outputs.imageVersion }}
|
version: ${{ needs.build-settings.outputs.imageVersion }}
|
||||||
|
kind: "image"
|
||||||
|
add_latest: true
|
||||||
|
|
||||||
|
add-cli-version-to-versionsapi:
|
||||||
|
needs: [upload-artifacts, build-settings]
|
||||||
|
name: "Add CLI version to versionsapi"
|
||||||
|
if: needs.build-settings.outputs.ref != '-'
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
uses: ./.github/workflows/versionsapi.yml
|
||||||
|
with:
|
||||||
|
command: add
|
||||||
|
ref: ${{ needs.build-settings.outputs.ref }}
|
||||||
|
stream: ${{ needs.build-settings.outputs.stream }}
|
||||||
|
version: ${{ needs.build-settings.outputs.imageVersion }}
|
||||||
|
kind: "cli"
|
||||||
add_latest: true
|
add_latest: true
|
||||||
|
40
.github/workflows/on-release.yml
vendored
40
.github/workflows/on-release.yml
vendored
@ -63,16 +63,32 @@ jobs:
|
|||||||
role-to-assume: arn:aws:iam::795746500882:role/GithubAddReleaseVersion
|
role-to-assume: arn:aws:iam::795746500882:role/GithubAddReleaseVersion
|
||||||
aws-region: eu-central-1
|
aws-region: eu-central-1
|
||||||
|
|
||||||
- name: Build versionsapi CLI
|
add-image-version-to-versionsapi:
|
||||||
working-directory: internal/versionsapi/cli
|
needs: [update]
|
||||||
run: go build -o versionsapi
|
name: "Add image version to versionsapi"
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
uses: ./.github/workflows/versionsapi.yml
|
||||||
|
with:
|
||||||
|
command: add
|
||||||
|
add_release: true
|
||||||
|
stream: stable
|
||||||
|
version: ${{ inputs.tag }}
|
||||||
|
kind: image
|
||||||
|
add_latest: true
|
||||||
|
|
||||||
- name: Add version to versionsapi
|
add-cli-version-to-versionsapi:
|
||||||
working-directory: internal/versionsapi/cli
|
needs: [update]
|
||||||
run: |
|
name: "Add CLI version to versionsapi"
|
||||||
latest_flag=$([[ "${LATEST}" = "true" ]] && echo "--latest" || echo "")
|
permissions:
|
||||||
./versionsapi add \
|
contents: read
|
||||||
--release \
|
id-token: write
|
||||||
--stream "stable" \
|
uses: ./.github/workflows/versionsapi.yml
|
||||||
--version "${TAG}" \
|
with:
|
||||||
"${latest_flag}"
|
command: add
|
||||||
|
add_release: true
|
||||||
|
stream: stable
|
||||||
|
version: ${{ inputs.tag }}
|
||||||
|
kind: cli
|
||||||
|
add_latest: true
|
||||||
|
9
.github/workflows/versionsapi.yml
vendored
9
.github/workflows/versionsapi.yml
vendored
@ -24,6 +24,10 @@ on:
|
|||||||
description: --version flag
|
description: --version flag
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
kind:
|
||||||
|
description: --kind flag
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
version_path:
|
version_path:
|
||||||
description: --version-path flag
|
description: --version-path flag
|
||||||
required: false
|
required: false
|
||||||
@ -66,6 +70,10 @@ on:
|
|||||||
description: --version flag
|
description: --version flag
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
kind:
|
||||||
|
description: --kind flag
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
version_path:
|
version_path:
|
||||||
description: --version-path flag
|
description: --version-path flag
|
||||||
required: false
|
required: false
|
||||||
@ -180,6 +188,7 @@ jobs:
|
|||||||
ref: ${{ inputs.ref }}
|
ref: ${{ inputs.ref }}
|
||||||
stream: ${{ inputs.stream }}
|
stream: ${{ inputs.stream }}
|
||||||
version: ${{ inputs.version }}
|
version: ${{ inputs.version }}
|
||||||
|
kind: ${{ inputs.kind }}
|
||||||
version_path: ${{ inputs.version_path }}
|
version_path: ${{ inputs.version_path }}
|
||||||
add_latest: ${{ inputs.add_latest }}
|
add_latest: ${{ inputs.add_latest }}
|
||||||
add_release: ${{ inputs.add_release }}
|
add_release: ${{ inputs.add_release }}
|
||||||
|
@ -26,7 +26,7 @@ func newAddCmd() *cobra.Command {
|
|||||||
Long: `Add a new version to the versions API.
|
Long: `Add a new version to the versions API.
|
||||||
|
|
||||||
Developers should not use this command directly. It is invoked by the CI/CD pipeline.
|
Developers should not use this command directly. It is invoked by the CI/CD pipeline.
|
||||||
If you've build a local image, use an local override instead of adding a new version.
|
If you've build a local image, use a local override instead of adding a new version.
|
||||||
|
|
||||||
❗ If you use the command nevertheless, you better know what you do.
|
❗ If you use the command nevertheless, you better know what you do.
|
||||||
`,
|
`,
|
||||||
@ -36,6 +36,7 @@ If you've build a local image, use an local override instead of adding a new ver
|
|||||||
cmd.Flags().String("ref", "", "Ref of the version to add")
|
cmd.Flags().String("ref", "", "Ref of the version to add")
|
||||||
cmd.Flags().String("stream", "", "Stream of the version to add")
|
cmd.Flags().String("stream", "", "Stream of the version to add")
|
||||||
cmd.Flags().String("version", "", "Version to add (format: \"v1.2.3\")")
|
cmd.Flags().String("version", "", "Version to add (format: \"v1.2.3\")")
|
||||||
|
cmd.Flags().String("kind", "", "Version kind to add (e.g. image, cli)")
|
||||||
cmd.Flags().Bool("latest", false, "Whether the version is the latest version of the ref/stream")
|
cmd.Flags().Bool("latest", false, "Whether the version is the latest version of the ref/stream")
|
||||||
cmd.Flags().Bool("release", false, "Whether the version is a release version")
|
cmd.Flags().Bool("release", false, "Whether the version is a release version")
|
||||||
cmd.Flags().Bool("dryrun", false, "Whether to run in dry-run mode (no changes are made)")
|
cmd.Flags().Bool("dryrun", false, "Whether to run in dry-run mode (no changes are made)")
|
||||||
@ -64,7 +65,7 @@ func runAdd(cmd *cobra.Command, args []string) (retErr error) {
|
|||||||
Ref: flags.ref,
|
Ref: flags.ref,
|
||||||
Stream: flags.stream,
|
Stream: flags.stream,
|
||||||
Version: flags.version,
|
Version: flags.version,
|
||||||
Kind: versionsapi.VersionKindImage,
|
Kind: flags.kind,
|
||||||
}
|
}
|
||||||
if err := ver.Validate(); err != nil {
|
if err := ver.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -83,16 +84,16 @@ func runAdd(cmd *cobra.Command, args []string) (retErr error) {
|
|||||||
}(&retErr)
|
}(&retErr)
|
||||||
|
|
||||||
log.Infof("Adding version")
|
log.Infof("Adding version")
|
||||||
if err := ensureVersion(cmd.Context(), client, ver, versionsapi.GranularityMajor, log); err != nil {
|
if err := ensureVersion(cmd.Context(), client, flags.kind, ver, versionsapi.GranularityMajor, log); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ensureVersion(cmd.Context(), client, ver, versionsapi.GranularityMinor, log); err != nil {
|
if err := ensureVersion(cmd.Context(), client, flags.kind, ver, versionsapi.GranularityMinor, log); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.latest {
|
if flags.latest {
|
||||||
if err := updateLatest(cmd.Context(), client, ver, log); err != nil {
|
if err := updateLatest(cmd.Context(), client, flags.kind, ver, log); err != nil {
|
||||||
return fmt.Errorf("setting latest version: %w", err)
|
return fmt.Errorf("setting latest version: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +104,7 @@ func runAdd(cmd *cobra.Command, args []string) (retErr error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureVersion(ctx context.Context, client *verclient.Client, ver versionsapi.Version, gran versionsapi.Granularity,
|
func ensureVersion(ctx context.Context, client *verclient.Client, kind versionsapi.VersionKind, ver versionsapi.Version, gran versionsapi.Granularity,
|
||||||
log *logger.Logger,
|
log *logger.Logger,
|
||||||
) error {
|
) error {
|
||||||
verListReq := versionsapi.List{
|
verListReq := versionsapi.List{
|
||||||
@ -111,7 +112,7 @@ func ensureVersion(ctx context.Context, client *verclient.Client, ver versionsap
|
|||||||
Stream: ver.Stream,
|
Stream: ver.Stream,
|
||||||
Granularity: gran,
|
Granularity: gran,
|
||||||
Base: ver.WithGranularity(gran),
|
Base: ver.WithGranularity(gran),
|
||||||
Kind: versionsapi.VersionKindImage,
|
Kind: kind,
|
||||||
}
|
}
|
||||||
verList, err := client.FetchVersionList(ctx, verListReq)
|
verList, err := client.FetchVersionList(ctx, verListReq)
|
||||||
var notFoundErr *verclient.NotFoundError
|
var notFoundErr *verclient.NotFoundError
|
||||||
@ -143,11 +144,11 @@ func ensureVersion(ctx context.Context, client *verclient.Client, ver versionsap
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateLatest(ctx context.Context, client *verclient.Client, ver versionsapi.Version, log *logger.Logger) error {
|
func updateLatest(ctx context.Context, client *verclient.Client, kind versionsapi.VersionKind, ver versionsapi.Version, log *logger.Logger) error {
|
||||||
latest := versionsapi.Latest{
|
latest := versionsapi.Latest{
|
||||||
Ref: ver.Ref,
|
Ref: ver.Ref,
|
||||||
Stream: ver.Stream,
|
Stream: ver.Stream,
|
||||||
Kind: versionsapi.VersionKindImage,
|
Kind: kind,
|
||||||
}
|
}
|
||||||
latest, err := client.FetchVersionLatest(ctx, latest)
|
latest, err := client.FetchVersionLatest(ctx, latest)
|
||||||
var notFoundErr *verclient.NotFoundError
|
var notFoundErr *verclient.NotFoundError
|
||||||
@ -167,7 +168,7 @@ func updateLatest(ctx context.Context, client *verclient.Client, ver versionsapi
|
|||||||
Ref: ver.Ref,
|
Ref: ver.Ref,
|
||||||
Stream: ver.Stream,
|
Stream: ver.Stream,
|
||||||
Version: ver.Version,
|
Version: ver.Version,
|
||||||
Kind: versionsapi.VersionKindImage,
|
Kind: kind,
|
||||||
}
|
}
|
||||||
if err := client.UpdateVersionLatest(ctx, latest); err != nil {
|
if err := client.UpdateVersionLatest(ctx, latest); err != nil {
|
||||||
return fmt.Errorf("updating latest version: %w", err)
|
return fmt.Errorf("updating latest version: %w", err)
|
||||||
@ -186,6 +187,7 @@ type addFlags struct {
|
|||||||
region string
|
region string
|
||||||
bucket string
|
bucket string
|
||||||
distributionID string
|
distributionID string
|
||||||
|
kind versionsapi.VersionKind
|
||||||
logLevel zapcore.Level
|
logLevel zapcore.Level
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +203,10 @@ func (f *addFlags) validate(log *logger.Logger) error {
|
|||||||
return fmt.Errorf("either --ref or --release must be set")
|
return fmt.Errorf("either --ref or --release must be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if f.kind == versionsapi.VersionKindUnknown {
|
||||||
|
return fmt.Errorf("unknown version kind %q", f.kind)
|
||||||
|
}
|
||||||
|
|
||||||
if f.release {
|
if f.release {
|
||||||
log.Debugf("Setting ref to %q, as release flag is set", versionsapi.ReleaseRef)
|
log.Debugf("Setting ref to %q, as release flag is set", versionsapi.ReleaseRef)
|
||||||
f.ref = versionsapi.ReleaseRef
|
f.ref = versionsapi.ReleaseRef
|
||||||
@ -230,6 +236,11 @@ func parseAddFlags(cmd *cobra.Command) (addFlags, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return addFlags{}, err
|
return addFlags{}, err
|
||||||
}
|
}
|
||||||
|
kindFlag, err := cmd.Flags().GetString("kind")
|
||||||
|
if err != nil {
|
||||||
|
return addFlags{}, err
|
||||||
|
}
|
||||||
|
kind := versionsapi.VersionKindFromString(kindFlag)
|
||||||
version, err := cmd.Flags().GetString("version")
|
version, err := cmd.Flags().GetString("version")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return addFlags{}, err
|
return addFlags{}, err
|
||||||
@ -278,5 +289,6 @@ func parseAddFlags(cmd *cobra.Command) (addFlags, error) {
|
|||||||
bucket: bucket,
|
bucket: bucket,
|
||||||
distributionID: distributionID,
|
distributionID: distributionID,
|
||||||
logLevel: logLevel,
|
logLevel: logLevel,
|
||||||
|
kind: kind,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func (l List) ValidateRequest() error {
|
|||||||
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
||||||
retErr = errors.Join(retErr, fmt.Errorf("granularity %q is not supported", l.Granularity))
|
retErr = errors.Join(retErr, fmt.Errorf("granularity %q is not supported", l.Granularity))
|
||||||
}
|
}
|
||||||
if l.Kind != VersionKindImage {
|
if l.Kind == VersionKindUnknown {
|
||||||
retErr = errors.Join(retErr, fmt.Errorf("kind %q is not supported", l.Kind))
|
retErr = errors.Join(retErr, fmt.Errorf("kind %q is not supported", l.Kind))
|
||||||
}
|
}
|
||||||
if !semver.IsValid(l.Base) {
|
if !semver.IsValid(l.Base) {
|
||||||
@ -117,7 +117,7 @@ func (l List) Validate() error {
|
|||||||
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
||||||
retErr = errors.Join(retErr, fmt.Errorf("granularity %q is not supported", l.Granularity))
|
retErr = errors.Join(retErr, fmt.Errorf("granularity %q is not supported", l.Granularity))
|
||||||
}
|
}
|
||||||
if l.Kind != VersionKindImage {
|
if l.Kind == VersionKindUnknown {
|
||||||
retErr = errors.Join(retErr, fmt.Errorf("kind %q is not supported", l.Kind))
|
retErr = errors.Join(retErr, fmt.Errorf("kind %q is not supported", l.Kind))
|
||||||
}
|
}
|
||||||
if !semver.IsValid(l.Base) {
|
if !semver.IsValid(l.Base) {
|
||||||
|
Loading…
Reference in New Issue
Block a user