diff --git a/src/gitHubPublisher.ts b/src/gitHubPublisher.ts index 4539ac0bfaf..b31ca4f662f 100644 --- a/src/gitHubPublisher.ts +++ b/src/gitHubPublisher.ts @@ -40,15 +40,19 @@ export class GitHubPublisher implements Publisher { return this._releasePromise } - constructor(private owner: string, private repo: string, version: string, private options: PublishOptions, private isPublishOptionGuessed: boolean = false) { + constructor(private owner: string, private repo: string, private version: string, private options: PublishOptions, private isPublishOptionGuessed: boolean = false) { if (isEmptyOrSpaces(options.githubToken)) { throw new Error("GitHub Personal Access Token is not specified") } this.token = options.githubToken! - this.policy = options.publish! + this.policy = options.publish || "always" - this.tag = "v" + version + if (version.startsWith("v")) { + throw new Error(`Version must not starts with "v": ${version}`) + } + + this.tag = `v${version}` this._releasePromise = >this.init() } @@ -75,6 +79,9 @@ export class GitHubPublisher implements Publisher { } return null } + else if (release.tag_name === this.version) { + throw new Error(`Tag name must starts with "v": ${release.tag_name}`) + } } if (createReleaseIfNotExists) { diff --git a/src/targets/nsis.ts b/src/targets/nsis.ts index 7001104fd6f..71ea1b21bf6 100644 --- a/src/targets/nsis.ts +++ b/src/targets/nsis.ts @@ -84,7 +84,7 @@ export default class NsisTarget extends Target { defines.MUI_HEADERIMAGE_BITMAP = installerHeader } - const headerIcon = oneClick ? await this.getResource(this.options.installerHeader, "headerIcon.ico") : null + const headerIcon = oneClick ? await this.getResource(this.options.headerIcon, "headerIcon.ico") : null if (headerIcon != null) { defines.HEADER_ICO = headerIcon } diff --git a/test/src/ArtifactPublisherTest.ts b/test/src/ArtifactPublisherTest.ts index 461881afb83..da36e93ded4 100644 --- a/test/src/ArtifactPublisherTest.ts +++ b/test/src/ArtifactPublisherTest.ts @@ -79,6 +79,28 @@ testAndIgnoreApiRate("prerelease", async () => { } }) +testAndIgnoreApiRate("incorrect tag name", async () => { + const publisher = new GitHubPublisher("actperepo", "ecb2", "5.0", { + githubToken: token, + draft: false, + prerelease: true, + publish: "onTagOrDraft", + }) + try { + await publisher.releasePromise + //noinspection ExceptionCaughtLocallyJS + throw new Error("No expected error") + } + catch (e) { + if (e.message !== 'Tag name must starts with "v": 5.0') { + throw e + } + } + finally { + await publisher.deleteRelease() + } +}) + testAndIgnoreApiRate("GitHub upload org", async () => { //noinspection SpellCheckingInspection const publisher = new GitHubPublisher("builder-gh-test", "darpa", versionNumber(), {