@@ -216,10 +216,12 @@ function run() {
216216 const shouldTagIndividualFeatures = core.getInput('tag-individual-features').toLowerCase() === 'true';
217217 const shouldPublishToNPM = core.getInput('publish-to-npm').toLowerCase() === 'true';
218218 const shouldPublishReleaseArtifacts = core.getInput('publish-release-artifacts').toLowerCase() === 'true';
219+ const shouldPublishToOCI = core.getInput('publish-to-oci').toLowerCase() === 'true';
219220 const opts = {
220221 shouldTagIndividualFeatures,
221222 shouldPublishToNPM,
222- shouldPublishReleaseArtifacts
223+ shouldPublishReleaseArtifacts,
224+ shouldPublishToOCI
223225 };
224226 const featuresBasePath = core.getInput('base-path-to-features');
225227 const templatesBasePath = core.getInput('base-path-to-templates');
@@ -440,9 +442,45 @@ function addCollectionsMetadataFile(featuresMetadata, templatesMetadata) {
440442 });
441443}
442444exports.addCollectionsMetadataFile = addCollectionsMetadataFile;
445+ function pushArtifactToOCI(repositoryOwner, version, featureName, artifactPath) {
446+ return __awaiter(this, void 0, void 0, function* () {
447+ const exec = (0, util_1.promisify)(child_process.exec);
448+ const ociRepo = `${repositoryOwner}/${featureName}:${version}`;
449+ try {
450+ const cmd = `oras push ghcr.io/${ociRepo} \
451+ --manifest-config /dev/null:application/vnd.devcontainers \
452+ ./${artifactPath}:application/vnd.devcontainers.layer.v1+tar`;
453+ yield exec(cmd);
454+ console.log(`Pushed artifact to '${ociRepo}'`);
455+ }
456+ catch (error) {
457+ if (error instanceof Error)
458+ core.setFailed(`Failed to push '${ociRepo}': ${error.message}`);
459+ }
460+ });
461+ }
462+ function loginToGHCR() {
463+ return __awaiter(this, void 0, void 0, function* () {
464+ const exec = (0, util_1.promisify)(child_process.exec);
465+ // Get GITHUB_TOKEN from environment
466+ const githubToken = process.env.GITHUB_TOKEN;
467+ if (!githubToken) {
468+ core.setFailed('GITHUB_TOKEN environment variable is not set.');
469+ return;
470+ }
471+ try {
472+ yield exec(`oras login ghcr.io -u USERNAME -p ${githubToken}`);
473+ console.log('Oras logged in successfully!');
474+ }
475+ catch (error) {
476+ if (error instanceof Error)
477+ core.setFailed(` Oras login failed!`);
478+ }
479+ });
480+ }
443481function getFeaturesAndPackage(basePath, opts) {
444482 return __awaiter(this, void 0, void 0, function* () {
445- const { shouldPublishToNPM, shouldTagIndividualFeatures, shouldPublishReleaseArtifacts } = opts;
483+ const { shouldPublishToNPM, shouldTagIndividualFeatures, shouldPublishReleaseArtifacts, shouldPublishToOCI } = opts;
446484 const featureDirs = fs.readdirSync(basePath);
447485 let metadatas = [];
448486 const exec = (0, util_1.promisify)(child_process.exec);
@@ -464,6 +502,24 @@ function getFeaturesAndPackage(basePath, opts) {
464502 }
465503 metadatas.push(featureMetadata);
466504 const sourceInfo = getGitHubMetadata();
505+ if (!sourceInfo.owner) {
506+ core.setFailed('Could not determine repository owner.');
507+ return;
508+ }
509+ const archiveName = `${f}.tgz`;
510+ // ---- PUBLISH RELEASE ARTIFACTS (classic method) ----
511+ if (shouldPublishReleaseArtifacts || shouldPublishToOCI) {
512+ core.info(`** Tar'ing feature`);
513+ yield tarDirectory(featureFolder, archiveName);
514+ }
515+ // ---- PUBLISH TO NPM ----
516+ if (shouldPublishToOCI) {
517+ core.info(`** Publishing to OCI`);
518+ // HACK TO GET THE GITHUB UI TO NOT 500
519+ // END HACK
520+ yield loginToGHCR();
521+ yield pushArtifactToOCI(sourceInfo.owner, featureMetadata.version, f, archiveName);
522+ }
467523 // ---- TAG INDIVIDUAL FEATURES ----
468524 if (shouldTagIndividualFeatures) {
469525 core.info(`** Tagging individual feature`);
@@ -498,12 +554,6 @@ function getFeaturesAndPackage(basePath, opts) {
498554 core.error(`${publishOutput.stderr}`);
499555 }
500556 }
501- // ---- PUBLISH RELEASE ARTIFACTS (classic method) ----
502- if (shouldPublishReleaseArtifacts) {
503- core.info(`** Publishing release`);
504- const archiveName = `${f}.tgz`;
505- yield tarDirectory(featureFolder, archiveName);
506- }
507557 }
508558 })));
509559 if (metadatas.length === 0) {
0 commit comments