File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,11 +153,19 @@ jobs:
153153 const taggedVersions = versions.filter(version => version.metadata.container.tags.length > 0);
154154 const untaggedVersions = versions.filter(version => version.metadata.container.tags.length === 0);
155155
156- // Expected tagged version is 1 for unsigned images (tag) and 2 for signed images (tag, cosing legacy tag sha256-...)
157- const expectedTaggedVersions = process.env.SIGN === 'true' ? 2 : 1;
158-
159- // Expected untagged versions are 1 by platform for unsigned images and number of platforms + 1 (cosing legacy tag sha256-...) for signed images
160- const expectedUntaggedVersions = JSON.parse(process.env.PLATFORMS).length + (process.env.SIGN === 'true' ? 1 : 0);
156+ // With optimizations:
157+ // - No legacy cosign sha256-... tag is created anymore (using OCI 1.1 referrers)
158+ // - Single platform images don't create a multiarch manifest
159+ const platforms = JSON.parse(process.env.PLATFORMS);
160+ const isSinglePlatform = platforms.length === 1;
161+
162+ // Expected tagged version is always 1 (the main tag)
163+ const expectedTaggedVersions = 1;
164+
165+ // Expected untagged versions:
166+ // - For single platform: 0 (no multiarch manifest created)
167+ // - For multi platform: number of platforms (one per platform)
168+ const expectedUntaggedVersions = isSinglePlatform ? 0 : platforms.length;
161169
162170 assert.equal(
163171 taggedVersions.length,
Original file line number Diff line number Diff line change @@ -117,6 +117,30 @@ runs:
117117 return `${builtImage.registry}/${builtImage.repository}:${tag}`;
118118 });
119119
120+ // Skip multiarch manifest creation for single platform images
121+ if (builtImage.platforms.length <= 1) {
122+ core.info(`Skipping multiarch manifest creation for "${builtImage.name}" (single platform: ${builtImage.platforms[0] || 'none'})`);
123+
124+ return new Promise(async (resolve, reject) => {
125+ try {
126+ // For single platform, just tag the existing image
127+ const sourceImage = builtImage.images[0];
128+ for (const targetImage of imagesWithTags) {
129+ const tagCommand = `docker buildx imagetools create --tag ${targetImage} ${sourceImage}`;
130+ await exec.exec(tagCommand);
131+ core.debug(`Tag single-platform image "${builtImage.name}" ("${tagCommand}") executed`);
132+ }
133+
134+ // Update builtImage with the images with tags
135+ builtImage.images = imagesWithTags;
136+
137+ resolve();
138+ } catch(error){
139+ reject(error);
140+ }
141+ });
142+ }
143+
120144 const platformsOption = builtImage.platforms.map(platform => `--platform ${platform}`).join(" ");
121145
122146 const tagsOption = imagesWithTags.map(image => {
Original file line number Diff line number Diff line change 8888 // Sign the images
8989 const annotationsArgs = tags.size > 0 ? `-a tag=${Array.from(tags).at(-1)}` : "";
9090 const imagesArgs = Array.from(imagesToSign).join(" ");
91- const signImageCommand = `cosign sign ${annotationsArgs} --yes ${imagesArgs}`;
91+ // Use OCI 1.1 referrers mode to avoid creating legacy sha256-... tags
92+ const signImageCommand = `cosign sign ${annotationsArgs} --registry-referrers-mode=oci-1-1 --yes ${imagesArgs}`;
9293
9394 core.debug(`Signing images with command: "${signImageCommand}"`);
9495 await exec.exec(signImageCommand);
You can’t perform that action at this time.
0 commit comments