@@ -247,7 +247,7 @@ function run() {
247247 }
248248 // -- Programatically add feature/template metadata to collections file.
249249 core.info('Generating metadata file: devcontainer-collection.json');
250- yield (0, utils_1.addCollectionsMetadataFile)(featuresMetadata, templatesMetadata);
250+ yield (0, utils_1.addCollectionsMetadataFile)(featuresMetadata, templatesMetadata, opts );
251251 });
252252}
253253function packageFeatures(basePath, opts) {
@@ -328,7 +328,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
328328 return (mod && mod.__esModule) ? mod : { "default": mod };
329329};
330330Object.defineProperty(exports, "__esModule", ({ value: true }));
331- exports.getTemplatesAndPackage = exports.getFeaturesAndPackage = exports.addCollectionsMetadataFile = exports.tarDirectory = exports.renameLocal = exports.mkdirLocal = exports.writeLocalFile = exports.readLocalFile = void 0;
331+ exports.getTemplatesAndPackage = exports.getFeaturesAndPackage = exports.pushCollectionsMetadataToOCI = exports. addCollectionsMetadataFile = exports.tarDirectory = exports.renameLocal = exports.mkdirLocal = exports.writeLocalFile = exports.readLocalFile = void 0;
332332const github = __importStar(__nccwpck_require__(5438));
333333const tar = __importStar(__nccwpck_require__(4674));
334334const fs = __importStar(__nccwpck_require__(7147));
@@ -428,7 +428,7 @@ function tagFeatureAtVersion(featureMetaData) {
428428 }
429429 });
430430}
431- function addCollectionsMetadataFile(featuresMetadata, templatesMetadata) {
431+ function addCollectionsMetadataFile(featuresMetadata, templatesMetadata, opts ) {
432432 return __awaiter(this, void 0, void 0, function* () {
433433 const p = path_1.default.join('.', 'devcontainer-collection.json');
434434 const sourceInformation = getGitHubMetadata();
@@ -439,16 +439,19 @@ function addCollectionsMetadataFile(featuresMetadata, templatesMetadata) {
439439 };
440440 // Write to the file
441441 yield (0, exports.writeLocalFile)(p, JSON.stringify(metadata, undefined, 4));
442+ if (opts.shouldPublishToOCI) {
443+ pushCollectionsMetadataToOCI(p);
444+ }
442445 });
443446}
444447exports.addCollectionsMetadataFile = addCollectionsMetadataFile;
445- function pushArtifactToOCI(repositoryOwner, version, featureName, artifactPath) {
448+ function pushArtifactToOCI(version, featureName, artifactPath) {
446449 return __awaiter(this, void 0, void 0, function* () {
447450 const exec = (0, util_1.promisify)(child_process.exec);
448451 const versions = [version, '1.0', '1']; // TODO: don't hardcode ofc.
452+ const sourceInfo = getGitHubMetadata();
449453 yield Promise.all(versions.map((v) => __awaiter(this, void 0, void 0, function* () {
450- core.info(`Starting to push artifact (tag ${v}) to OCI...`);
451- const ociRepo = `${repositoryOwner}/${featureName}:${v}`;
454+ const ociRepo = `${sourceInfo.owner}/${sourceInfo.repo}/${featureName}:${v}`;
452455 try {
453456 const cmd = `oras push ghcr.io/${ociRepo} \
454457 --manifest-config /dev/null:application/vnd.devcontainers \
@@ -463,6 +466,25 @@ function pushArtifactToOCI(repositoryOwner, version, featureName, artifactPath)
463466 })));
464467 });
465468}
469+ function pushCollectionsMetadataToOCI(collectionJsonPath) {
470+ return __awaiter(this, void 0, void 0, function* () {
471+ const exec = (0, util_1.promisify)(child_process.exec);
472+ const sourceInfo = getGitHubMetadata();
473+ const ociRepo = `${sourceInfo.owner}/${sourceInfo.repo}:latest`;
474+ try {
475+ const cmd = `oras push ghcr.io/${ociRepo} \
476+ --manifest-config /dev/null:application/vnd.devcontainers \
477+ ./${collectionJsonPath}:application/vnd.devcontainers.collection.layer.v1+json`;
478+ yield exec(cmd);
479+ core.info(`Pushed collection metadata to '${ociRepo}'`);
480+ }
481+ catch (error) {
482+ if (error instanceof Error)
483+ core.setFailed(`Failed to push collection metadata '${ociRepo}': ${error.message}`);
484+ }
485+ });
486+ }
487+ exports.pushCollectionsMetadataToOCI = pushCollectionsMetadataToOCI;
466488function loginToGHCR() {
467489 return __awaiter(this, void 0, void 0, function* () {
468490 const exec = (0, util_1.promisify)(child_process.exec);
@@ -474,7 +496,7 @@ function loginToGHCR() {
474496 }
475497 try {
476498 yield exec(`oras login ghcr.io -u USERNAME -p ${githubToken}`);
477- console.log ('Oras logged in successfully!');
499+ core.info ('Oras logged in successfully!');
478500 }
479501 catch (error) {
480502 if (error instanceof Error)
@@ -522,7 +544,7 @@ function getFeaturesAndPackage(basePath, opts) {
522544 // ---- PUBLISH TO NPM ----
523545 if (shouldPublishToOCI) {
524546 core.info(`** Publishing to OCI`);
525- yield pushArtifactToOCI(sourceInfo.owner, featureMetadata.version, f, archiveName);
547+ yield pushArtifactToOCI(featureMetadata.version, f, archiveName);
526548 }
527549 // ---- TAG INDIVIDUAL FEATURES ----
528550 if (shouldTagIndividualFeatures) {
0 commit comments