Files
release-action/lib/Releases.js
Nick Cipollo 455687cd65 Update scripts
2019-12-12 18:46:17 -05:00

68 lines
2.5 KiB
JavaScript

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
class GithubReleases {
constructor(context, git) {
this.context = context;
this.git = git;
}
create(tag, body, commitHash, draft, name) {
return __awaiter(this, void 0, void 0, function* () {
return this.git.repos.createRelease({
body: body,
name: name,
draft: draft,
owner: this.context.repo.owner,
repo: this.context.repo.repo,
target_commitish: commitHash,
tag_name: tag
});
});
}
getByTag(tag) {
return __awaiter(this, void 0, void 0, function* () {
return this.git.repos.getReleaseByTag({
owner: this.context.repo.owner,
repo: this.context.repo.repo,
tag: tag
});
});
}
update(id, tag, body, commitHash, draft, name) {
return __awaiter(this, void 0, void 0, function* () {
return this.git.repos.updateRelease({
release_id: id,
body: body,
name: name,
draft: draft,
owner: this.context.repo.owner,
repo: this.context.repo.repo,
target_commitish: commitHash,
tag_name: tag
});
});
}
uploadArtifact(assetUrl, contentLength, contentType, file, name) {
return __awaiter(this, void 0, void 0, function* () {
return this.git.repos.uploadReleaseAsset({
url: assetUrl,
headers: {
"content-length": contentLength,
"content-type": contentType
},
file: file,
name: name
});
});
}
}
exports.GithubReleases = GithubReleases;