Skip to content

Commit

Permalink
Guard the prepare-npm-artifacts mode against missing esy.release config
Browse files Browse the repository at this point in the history
  • Loading branch information
ManasJayanth committed Jul 27, 2024
1 parent 109ec16 commit c61e0ff
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 39 deletions.
36 changes: 20 additions & 16 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141549,23 +141549,27 @@ function prepareNPMArtifacts() {
const manifest = JSON.parse(external_fs_.readFileSync(manifestFilePath).toString());
if ((_a = manifest.esy) === null || _a === void 0 ? void 0 : _a.release) {
yield runEsyCommand("Running esy npm-release", ["npm-release"]);
let tarFile = `npm-tarball.tgz`;
yield compress(external_path_.join(workingDirectory, "_release"), tarFile);
const artifactName = `esy-npm-release-${index_platform}-${arch}`;
console.log("Artifact name: ", artifactName);
const { id, size } = yield artifact_default().uploadArtifact(artifactName, [tarFile], process.env.GITHUB_WORKSPACE, {
// The level of compression for Zlib to be applied to the artifact archive.
// - 0: No compression
// - 1: Best speed
// - 6: Default compression (same as GNU Gzip)
// - 9: Best compression
compressionLevel: 0,
// optional: how long to retain the artifact
// if unspecified, defaults to repository/org retention settings (the limit of this value)
retentionDays: 10,
});
console.log(`Created artifact with id: ${id} (bytes: ${size}`);
}
else {
console.error(external_fs_.readFileSync(manifestFilePath).toString());
throw new Error(`No config found in ${manifestFilePath} for npm-release. See https://esy.sh/docs/npm-release to learn more.`);
}
let tarFile = `npm-tarball.tgz`;
yield compress(external_path_.join(workingDirectory, "_release"), tarFile);
const artifactName = `esy-npm-release-${index_platform}-${arch}`;
console.log("Artifact name: ", artifactName);
const { id, size } = yield artifact_default().uploadArtifact(artifactName, [tarFile], process.env.GITHUB_WORKSPACE, {
// The level of compression for Zlib to be applied to the artifact archive.
// - 0: No compression
// - 1: Best speed
// - 6: Default compression (same as GNU Gzip)
// - 9: Best compression
compressionLevel: 0,
// optional: how long to retain the artifact
// if unspecified, defaults to repository/org retention settings (the limit of this value)
retentionDays: 10,
});
console.log(`Created artifact with id: ${id} (bytes: ${size}`);
}
catch (error) {
if (error instanceof Error) {
Expand Down
51 changes: 28 additions & 23 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,30 +293,35 @@ async function prepareNPMArtifacts() {
const manifest = JSON.parse(fs.readFileSync(manifestFilePath).toString());
if (manifest.esy?.release) {
await runEsyCommand("Running esy npm-release", ["npm-release"]);
}
let tarFile = `npm-tarball.tgz`;
await compress(path.join(workingDirectory, "_release"), tarFile);

const artifactName = `esy-npm-release-${platform}-${arch}`;
console.log("Artifact name: ", artifactName);
const { id, size } = await artifact.uploadArtifact(
artifactName,
[tarFile],
process.env.GITHUB_WORKSPACE!,
{
// The level of compression for Zlib to be applied to the artifact archive.
// - 0: No compression
// - 1: Best speed
// - 6: Default compression (same as GNU Gzip)
// - 9: Best compression
compressionLevel: 0,
// optional: how long to retain the artifact
// if unspecified, defaults to repository/org retention settings (the limit of this value)
retentionDays: 10,
}
);
let tarFile = `npm-tarball.tgz`;
await compress(path.join(workingDirectory, "_release"), tarFile);

const artifactName = `esy-npm-release-${platform}-${arch}`;
console.log("Artifact name: ", artifactName);
const { id, size } = await artifact.uploadArtifact(
artifactName,
[tarFile],
process.env.GITHUB_WORKSPACE!,
{
// The level of compression for Zlib to be applied to the artifact archive.
// - 0: No compression
// - 1: Best speed
// - 6: Default compression (same as GNU Gzip)
// - 9: Best compression
compressionLevel: 0,
// optional: how long to retain the artifact
// if unspecified, defaults to repository/org retention settings (the limit of this value)
retentionDays: 10,
}
);

console.log(`Created artifact with id: ${id} (bytes: ${size}`);
console.log(`Created artifact with id: ${id} (bytes: ${size}`);
} else {
console.error(fs.readFileSync(manifestFilePath).toString());
throw new Error(
`No config found in ${manifestFilePath} for npm-release. See https://esy.sh/docs/npm-release to learn more.`
);
}
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
Expand Down

0 comments on commit c61e0ff

Please sign in to comment.