Skip to content

Commit

Permalink
Update upload-bundle action
Browse files Browse the repository at this point in the history
  • Loading branch information
mvlassis committed Aug 27, 2024
1 parent 0f04d2b commit 27483d0
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 89 deletions.
26 changes: 15 additions & 11 deletions dist/channel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42646,19 +42646,23 @@ class Bundle {
core.exportVariable('CHARMCRAFT_AUTH', core.getInput('credentials'));
process.chdir(path);
const result = yield exec.getExecOutput('charmcraft', ['pack']);
core.info(result.stdout);
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
if (result.exitCode === 0) {
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
}
else {
throw new Error('Failed to extract the bundle name from the output of charmcraft pack.');
}
}
else {
throw new Error('charmcraft pack ran unsuccessfully');
throw new Error(`charmcraft pack ran unsuccessfully with exit code ${result.exitCode}.`);
}
});
}
Expand Down
26 changes: 15 additions & 11 deletions dist/check-libraries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42841,19 +42841,23 @@ class Bundle {
core.exportVariable('CHARMCRAFT_AUTH', core.getInput('credentials'));
process.chdir(path);
const result = yield exec.getExecOutput('charmcraft', ['pack']);
core.info(result.stdout);
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
if (result.exitCode === 0) {
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
}
else {
throw new Error('Failed to extract the bundle name from the output of charmcraft pack.');
}
}
else {
throw new Error('charmcraft pack ran unsuccessfully');
throw new Error(`charmcraft pack ran unsuccessfully with exit code ${result.exitCode}.`);
}
});
}
Expand Down
26 changes: 15 additions & 11 deletions dist/promote-charm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42725,19 +42725,23 @@ class Bundle {
core.exportVariable('CHARMCRAFT_AUTH', core.getInput('credentials'));
process.chdir(path);
const result = yield exec.getExecOutput('charmcraft', ['pack']);
core.info(result.stdout);
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
if (result.exitCode === 0) {
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
}
else {
throw new Error('Failed to extract the bundle name from the output of charmcraft pack.');
}
}
else {
throw new Error('charmcraft pack ran unsuccessfully');
throw new Error(`charmcraft pack ran unsuccessfully with exit code ${result.exitCode}.`);
}
});
}
Expand Down
26 changes: 15 additions & 11 deletions dist/release-charm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42737,19 +42737,23 @@ class Bundle {
core.exportVariable('CHARMCRAFT_AUTH', core.getInput('credentials'));
process.chdir(path);
const result = yield exec.getExecOutput('charmcraft', ['pack']);
core.info(result.stdout);
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
if (result.exitCode === 0) {
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
}
else {
throw new Error('Failed to extract the bundle name from the output of charmcraft pack.');
}
}
else {
throw new Error('charmcraft pack ran unsuccessfully');
throw new Error(`charmcraft pack ran unsuccessfully with exit code ${result.exitCode}.`);
}
});
}
Expand Down
26 changes: 15 additions & 11 deletions dist/release-libraries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42868,19 +42868,23 @@ class Bundle {
core.exportVariable('CHARMCRAFT_AUTH', core.getInput('credentials'));
process.chdir(path);
const result = yield exec.getExecOutput('charmcraft', ['pack']);
core.info(result.stdout);
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
if (result.exitCode === 0) {
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
}
else {
throw new Error('Failed to extract the bundle name from the output of charmcraft pack.');
}
}
else {
throw new Error('charmcraft pack ran unsuccessfully');
throw new Error(`charmcraft pack ran unsuccessfully with exit code ${result.exitCode}.`);
}
});
}
Expand Down
26 changes: 15 additions & 11 deletions dist/upload-bundle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42716,19 +42716,23 @@ class Bundle {
core.exportVariable('CHARMCRAFT_AUTH', core.getInput('credentials'));
process.chdir(path);
const result = yield exec.getExecOutput('charmcraft', ['pack']);
core.info(result.stdout);
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
if (result.exitCode === 0) {
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
}
else {
throw new Error('Failed to extract the bundle name from the output of charmcraft pack.');
}
}
else {
throw new Error('charmcraft pack ran unsuccessfully');
throw new Error(`charmcraft pack ran unsuccessfully with exit code ${result.exitCode}.`);
}
});
}
Expand Down
26 changes: 15 additions & 11 deletions dist/upload-charm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42756,19 +42756,23 @@ class Bundle {
core.exportVariable('CHARMCRAFT_AUTH', core.getInput('credentials'));
process.chdir(path);
const result = yield exec.getExecOutput('charmcraft', ['pack']);
core.info(result.stdout);
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
if (result.exitCode === 0) {
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
yield exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
}
else {
throw new Error('Failed to extract the bundle name from the output of charmcraft pack.');
}
}
else {
throw new Error('charmcraft pack ran unsuccessfully');
throw new Error(`charmcraft pack ran unsuccessfully with exit code ${result.exitCode}.`);
}
});
}
Expand Down
30 changes: 18 additions & 12 deletions src/services/bundle/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ class Bundle {
process.chdir(path);

const result = await exec.getExecOutput('charmcraft', ['pack']);
core.info(result.stdout);
const lastLine = result.stderr.trim().split('\n').pop();

if (lastLine) {
const bundleName = lastLine.split(' ')[1];
await exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
if (result.exitCode === 0) {
const lastLine = result.stderr.trim().split('\n').pop();
if (lastLine) {
const bundleName = lastLine.split(' ')[1];
await exec.exec('charmcraft', [
'upload',
bundleName,
'--release',
channel,
]);
} else {
throw new Error(
'Failed to extract the bundle name from the output of charmcraft pack.',
);
}
} else {
throw new Error('charmcraft pack ran unsuccessfully');
throw new Error(
`charmcraft pack ran unsuccessfully with exit code ${result.exitCode}.`,
);
}
}
}
Expand Down

0 comments on commit 27483d0

Please sign in to comment.