mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-23 14:39:40 -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:
|
||||
description: --version flag
|
||||
required: false
|
||||
kind:
|
||||
description: --kind flag
|
||||
required: false
|
||||
version_path:
|
||||
description: --version-path flag
|
||||
required: false
|
||||
@ -65,6 +68,7 @@ runs:
|
||||
${{ inputs.ref != '' && format('--ref="{0}"', inputs.ref) || '' }} \
|
||||
${{ inputs.stream != '' && format('--stream="{0}"', inputs.stream) || '' }} \
|
||||
${{ 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.add_latest == 'true' && '--latest' || '' }} \
|
||||
${{ 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 }} \
|
||||
--version=${{ needs.build-settings.outputs.imageVersion }} \
|
||||
|
||||
add-version-to-versionsapi:
|
||||
add-image-version-to-versionsapi:
|
||||
needs: [upload-artifacts, build-settings]
|
||||
name: "Add version to versionsapi"
|
||||
name: "Add image version to versionsapi"
|
||||
if: needs.build-settings.outputs.ref != '-'
|
||||
permissions:
|
||||
contents: read
|
||||
@ -990,4 +990,21 @@ jobs:
|
||||
ref: ${{ needs.build-settings.outputs.ref }}
|
||||
stream: ${{ needs.build-settings.outputs.stream }}
|
||||
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
|
||||
|
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
|
||||
aws-region: eu-central-1
|
||||
|
||||
- name: Build versionsapi CLI
|
||||
working-directory: internal/versionsapi/cli
|
||||
run: go build -o versionsapi
|
||||
add-image-version-to-versionsapi:
|
||||
needs: [update]
|
||||
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
|
||||
working-directory: internal/versionsapi/cli
|
||||
run: |
|
||||
latest_flag=$([[ "${LATEST}" = "true" ]] && echo "--latest" || echo "")
|
||||
./versionsapi add \
|
||||
--release \
|
||||
--stream "stable" \
|
||||
--version "${TAG}" \
|
||||
"${latest_flag}"
|
||||
add-cli-version-to-versionsapi:
|
||||
needs: [update]
|
||||
name: "Add CLI 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: cli
|
||||
add_latest: true
|
||||
|
9
.github/workflows/versionsapi.yml
vendored
9
.github/workflows/versionsapi.yml
vendored
@ -24,6 +24,10 @@ on:
|
||||
description: --version flag
|
||||
required: false
|
||||
type: string
|
||||
kind:
|
||||
description: --kind flag
|
||||
required: false
|
||||
type: string
|
||||
version_path:
|
||||
description: --version-path flag
|
||||
required: false
|
||||
@ -66,6 +70,10 @@ on:
|
||||
description: --version flag
|
||||
required: false
|
||||
type: string
|
||||
kind:
|
||||
description: --kind flag
|
||||
required: false
|
||||
type: string
|
||||
version_path:
|
||||
description: --version-path flag
|
||||
required: false
|
||||
@ -180,6 +188,7 @@ jobs:
|
||||
ref: ${{ inputs.ref }}
|
||||
stream: ${{ inputs.stream }}
|
||||
version: ${{ inputs.version }}
|
||||
kind: ${{ inputs.kind }}
|
||||
version_path: ${{ inputs.version_path }}
|
||||
add_latest: ${{ inputs.add_latest }}
|
||||
add_release: ${{ inputs.add_release }}
|
||||
|
@ -26,7 +26,7 @@ func newAddCmd() *cobra.Command {
|
||||
Long: `Add a new version to the versions API.
|
||||
|
||||
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.
|
||||
`,
|
||||
@ -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("stream", "", "Stream of the version to add")
|
||||
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("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)")
|
||||
@ -64,7 +65,7 @@ func runAdd(cmd *cobra.Command, args []string) (retErr error) {
|
||||
Ref: flags.ref,
|
||||
Stream: flags.stream,
|
||||
Version: flags.version,
|
||||
Kind: versionsapi.VersionKindImage,
|
||||
Kind: flags.kind,
|
||||
}
|
||||
if err := ver.Validate(); err != nil {
|
||||
return err
|
||||
@ -83,16 +84,16 @@ func runAdd(cmd *cobra.Command, args []string) (retErr error) {
|
||||
}(&retErr)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -103,7 +104,7 @@ func runAdd(cmd *cobra.Command, args []string) (retErr error) {
|
||||
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,
|
||||
) error {
|
||||
verListReq := versionsapi.List{
|
||||
@ -111,7 +112,7 @@ func ensureVersion(ctx context.Context, client *verclient.Client, ver versionsap
|
||||
Stream: ver.Stream,
|
||||
Granularity: gran,
|
||||
Base: ver.WithGranularity(gran),
|
||||
Kind: versionsapi.VersionKindImage,
|
||||
Kind: kind,
|
||||
}
|
||||
verList, err := client.FetchVersionList(ctx, verListReq)
|
||||
var notFoundErr *verclient.NotFoundError
|
||||
@ -143,11 +144,11 @@ func ensureVersion(ctx context.Context, client *verclient.Client, ver versionsap
|
||||
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{
|
||||
Ref: ver.Ref,
|
||||
Stream: ver.Stream,
|
||||
Kind: versionsapi.VersionKindImage,
|
||||
Kind: kind,
|
||||
}
|
||||
latest, err := client.FetchVersionLatest(ctx, latest)
|
||||
var notFoundErr *verclient.NotFoundError
|
||||
@ -167,7 +168,7 @@ func updateLatest(ctx context.Context, client *verclient.Client, ver versionsapi
|
||||
Ref: ver.Ref,
|
||||
Stream: ver.Stream,
|
||||
Version: ver.Version,
|
||||
Kind: versionsapi.VersionKindImage,
|
||||
Kind: kind,
|
||||
}
|
||||
if err := client.UpdateVersionLatest(ctx, latest); err != nil {
|
||||
return fmt.Errorf("updating latest version: %w", err)
|
||||
@ -186,6 +187,7 @@ type addFlags struct {
|
||||
region string
|
||||
bucket string
|
||||
distributionID string
|
||||
kind versionsapi.VersionKind
|
||||
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")
|
||||
}
|
||||
|
||||
if f.kind == versionsapi.VersionKindUnknown {
|
||||
return fmt.Errorf("unknown version kind %q", f.kind)
|
||||
}
|
||||
|
||||
if f.release {
|
||||
log.Debugf("Setting ref to %q, as release flag is set", versionsapi.ReleaseRef)
|
||||
f.ref = versionsapi.ReleaseRef
|
||||
@ -230,6 +236,11 @@ func parseAddFlags(cmd *cobra.Command) (addFlags, error) {
|
||||
if err != nil {
|
||||
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")
|
||||
if err != nil {
|
||||
return addFlags{}, err
|
||||
@ -278,5 +289,6 @@ func parseAddFlags(cmd *cobra.Command) (addFlags, error) {
|
||||
bucket: bucket,
|
||||
distributionID: distributionID,
|
||||
logLevel: logLevel,
|
||||
kind: kind,
|
||||
}, nil
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func (l List) ValidateRequest() error {
|
||||
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
||||
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))
|
||||
}
|
||||
if !semver.IsValid(l.Base) {
|
||||
@ -117,7 +117,7 @@ func (l List) Validate() error {
|
||||
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
||||
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))
|
||||
}
|
||||
if !semver.IsValid(l.Base) {
|
||||
|
Loading…
Reference in New Issue
Block a user