diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1af5c36c1..e129f2478 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,11 +15,13 @@ name: build on: push: - branches: main - + branches: + - main + - release-* pull_request: - branches: main - + branches: + - main + - release-* jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 38be08cb5..a655c968a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -15,9 +15,13 @@ name: CodeQL on: push: - branches: main + branches: + - main + - release-* pull_request: - branches: main + branches: + - main + - release-* schedule: - cron: '43 12 * * 6' diff --git a/.github/workflows/license-checker.yml b/.github/workflows/license-checker.yml index cc91c47ac..bbce88838 100644 --- a/.github/workflows/license-checker.yml +++ b/.github/workflows/license-checker.yml @@ -15,9 +15,13 @@ name: License Checker on: push: - branches: main + branches: + - main + - release-* pull_request: - branches: main + branches: + - main + - release-* permissions: contents: write diff --git a/cmd/oras/attach.go b/cmd/oras/attach.go index 0fbfe3fc3..05d2fbcec 100644 --- a/cmd/oras/attach.go +++ b/cmd/oras/attach.go @@ -122,7 +122,8 @@ func runAttach(opts attachOptions) error { desc, err := oras.PackArtifact( ctx, store, opts.artifactType, orasDescs, oras.PackArtifactOptions{ - Subject: &subject, + Subject: &subject, + ManifestAnnotations: annotations[option.AnnotationManifest], }) if err != nil { return err diff --git a/cmd/oras/logout.go b/cmd/oras/logout.go index b01cc0968..b057d6dd7 100644 --- a/cmd/oras/logout.go +++ b/cmd/oras/logout.go @@ -55,7 +55,7 @@ func runLogout(opts logoutOptions) error { logrus.SetLevel(logrus.DebugLevel) } - store, err := credential.NewStore() + store, err := credential.NewStore(opts.configs...) if err != nil { return err } diff --git a/cmd/oras/manifest/fetch.go b/cmd/oras/manifest/fetch.go index 16ba6a891..7173a5c42 100644 --- a/cmd/oras/manifest/fetch.go +++ b/cmd/oras/manifest/fetch.go @@ -103,7 +103,7 @@ func fetchManifest(opts fetchOptions) (fetchErr error) { return err } - manifests, err := opts.CachedTarget(repo.Manifests()) + src, err := opts.CachedTarget(repo) if err != nil { return err } @@ -113,7 +113,7 @@ func fetchManifest(opts fetchOptions) (fetchErr error) { // fetch manifest descriptor only fetchOpts := oras.DefaultResolveOptions fetchOpts.TargetPlatform = targetPlatform - desc, err = oras.Resolve(ctx, manifests, opts.targetRef, fetchOpts) + desc, err = oras.Resolve(ctx, src, opts.targetRef, fetchOpts) if err != nil { return err } @@ -122,7 +122,7 @@ func fetchManifest(opts fetchOptions) (fetchErr error) { var content []byte fetchOpts := oras.DefaultFetchBytesOptions fetchOpts.TargetPlatform = targetPlatform - desc, content, err = oras.FetchBytes(ctx, manifests, opts.targetRef, fetchOpts) + desc, content, err = oras.FetchBytes(ctx, src, opts.targetRef, fetchOpts) if err != nil { return err } diff --git a/cmd/oras/manifest/push.go b/cmd/oras/manifest/push.go index 2473f51b3..37f981095 100644 --- a/cmd/oras/manifest/push.go +++ b/cmd/oras/manifest/push.go @@ -17,11 +17,13 @@ package manifest import ( "bytes" + "context" "errors" "fmt" "os" "strings" + digest "github.com/opencontainers/go-digest" "github.com/spf13/cobra" "oras.land/oras-go/v2" "oras.land/oras-go/v2/content" @@ -127,12 +129,16 @@ func pushManifest(opts pushOptions) error { ref = desc.Digest.String() } + match, err := matchDigest(ctx, manifests, ref, desc.Digest) + if err != nil { + return err + } verbose := opts.Verbose && !opts.OutputDescriptor - got, err := manifests.Resolve(ctx, ref) - - // push the manifest if the reference does not exist; - // if the reference exists, then push the manifest if digests mismatch - if errors.Is(err, errdef.ErrNotFound) || (err == nil && got.Digest != desc.Digest) { + if match { + if err := display.PrintStatus(desc, "Exists", verbose); err != nil { + return err + } + } else { if err = display.PrintStatus(desc, "Uploading", verbose); err != nil { return err } @@ -142,10 +148,6 @@ func pushManifest(opts pushOptions) error { if err = display.PrintStatus(desc, "Uploaded ", verbose); err != nil { return err } - } else { - if err := display.PrintStatus(desc, "Exists", verbose); err != nil { - return err - } } tagBytesNOpts := oras.DefaultTagBytesNOptions @@ -175,3 +177,16 @@ func pushManifest(opts pushOptions) error { return nil } + +// matchDigest checks whether the manifest's digest matches to it in the remote +// repository. +func matchDigest(ctx context.Context, resolver content.Resolver, reference string, digest digest.Digest) (bool, error) { + got, err := resolver.Resolve(ctx, reference) + if err != nil { + if errors.Is(err, errdef.ErrNotFound) { + return false, nil + } + return false, err + } + return got.Digest == digest, nil +} diff --git a/internal/version/version.go b/internal/version/version.go index bcfa76c81..3c5d16932 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -17,7 +17,7 @@ package version var ( // Version is the current version of the oras. - Version = "0.15.0" + Version = "0.15.1" // BuildMetadata is the extra build time data BuildMetadata = "unreleased" // GitCommit is the git sha1