Fixes #19 Bump dependencies & update octokit usage
This commit is contained in:
@@ -23,7 +23,7 @@ class Action {
|
||||
return await this.updateRelease(getResponse.data.id);
|
||||
}
|
||||
catch (error) {
|
||||
if (this.noPublishedRelease(error)) {
|
||||
if (Action.noPublishedRelease(error)) {
|
||||
return await this.updateDraftOrCreateRelease();
|
||||
}
|
||||
else {
|
||||
@@ -39,7 +39,7 @@ class Action {
|
||||
const response = await this.releases.update(id, this.inputs.tag, this.inputs.updatedReleaseBody, this.inputs.commit, this.inputs.draft, this.inputs.updatedReleaseName, this.inputs.prerelease);
|
||||
return response.data;
|
||||
}
|
||||
noPublishedRelease(error) {
|
||||
static noPublishedRelease(error) {
|
||||
const errorMessage = new ErrorMessage_1.ErrorMessage(error);
|
||||
return errorMessage.status == 404;
|
||||
}
|
||||
|
||||
@@ -18,18 +18,18 @@ class GithubArtifactUploader {
|
||||
await this.deleteUpdatedArtifacts(artifacts, releaseId);
|
||||
}
|
||||
for (const artifact of artifacts) {
|
||||
await this.uploadArtifact(artifact, uploadUrl);
|
||||
await this.uploadArtifact(artifact, releaseId, uploadUrl);
|
||||
}
|
||||
}
|
||||
async uploadArtifact(artifact, uploadUrl, retry = 3) {
|
||||
async uploadArtifact(artifact, releaseId, uploadUrl, retry = 3) {
|
||||
try {
|
||||
core.debug(`Uploading artifact ${artifact.name}...`);
|
||||
await this.releases.uploadArtifact(uploadUrl, artifact.contentLength, artifact.contentType, artifact.readFile(), artifact.name);
|
||||
await this.releases.uploadArtifact(uploadUrl, artifact.contentLength, artifact.contentType, artifact.readFile(), artifact.name, releaseId);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.status >= 500 && retry > 0) {
|
||||
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}. Retrying...`);
|
||||
await this.uploadArtifact(artifact, uploadUrl, retry - 1);
|
||||
await this.uploadArtifact(artifact, releaseId, uploadUrl, retry - 1);
|
||||
}
|
||||
else {
|
||||
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}.`);
|
||||
|
||||
@@ -28,7 +28,7 @@ async function run() {
|
||||
function createAction() {
|
||||
const token = core.getInput('token');
|
||||
const context = github.context;
|
||||
const git = new github.GitHub(token);
|
||||
const git = github.getOctokit(token);
|
||||
const globber = new ArtifactGlobber_1.FileArtifactGlobber();
|
||||
const inputs = new Inputs_1.CoreInputs(globber, context);
|
||||
const releases = new Releases_1.GithubReleases(context, git);
|
||||
|
||||
@@ -6,6 +6,7 @@ class GithubReleases {
|
||||
this.git = git;
|
||||
}
|
||||
async create(tag, body, commitHash, draft, name, prerelease) {
|
||||
// noinspection TypeScriptValidateJSTypes
|
||||
return this.git.repos.createRelease({
|
||||
body: body,
|
||||
name: name,
|
||||
@@ -25,7 +26,7 @@ class GithubReleases {
|
||||
});
|
||||
}
|
||||
async listArtifactsForRelease(releaseId) {
|
||||
return this.git.repos.listAssetsForRelease({
|
||||
return this.git.repos.listReleaseAssets({
|
||||
owner: this.context.repo.owner,
|
||||
release_id: releaseId,
|
||||
repo: this.context.repo.repo
|
||||
@@ -45,6 +46,7 @@ class GithubReleases {
|
||||
});
|
||||
}
|
||||
async update(id, tag, body, commitHash, draft, name, prerelease) {
|
||||
// noinspection TypeScriptValidateJSTypes
|
||||
return this.git.repos.updateRelease({
|
||||
release_id: id,
|
||||
body: body,
|
||||
@@ -57,15 +59,18 @@ class GithubReleases {
|
||||
tag_name: tag
|
||||
});
|
||||
}
|
||||
async uploadArtifact(assetUrl, contentLength, contentType, file, name) {
|
||||
async uploadArtifact(assetUrl, contentLength, contentType, file, name, releaseId) {
|
||||
return this.git.repos.uploadReleaseAsset({
|
||||
url: assetUrl,
|
||||
headers: {
|
||||
"content-length": contentLength,
|
||||
"content-type": contentType
|
||||
},
|
||||
file: file,
|
||||
name: name
|
||||
data: file,
|
||||
name: name,
|
||||
owner: this.context.repo.owner,
|
||||
release_id: releaseId,
|
||||
repo: this.context.repo.repo
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user