Skip to content

Commit

Permalink
fix(deployment): warn "A release is already published" instead of error
Browse files Browse the repository at this point in the history
Close #1183
  • Loading branch information
develar committed Jan 28, 2017
1 parent dd1320d commit 5d64693
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/electron-builder/src/publish/PublishManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class PublishManager {
getOrCreatePublisher(publishConfig: PublishConfiguration, buildInfo: BuildInfo): Publisher | null {
let publisher = this.nameToPublisher.get(publishConfig.provider)
if (publisher == null) {
publisher = createPublisher(buildInfo, publishConfig, this.publishOptions, this.isPublishOptionGuessed)
publisher = createPublisher(buildInfo, publishConfig, this.publishOptions)
this.nameToPublisher.set(publishConfig.provider, publisher)
}
return publisher
Expand Down Expand Up @@ -242,12 +242,12 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu
}
}

function createPublisher(buildInfo: BuildInfo, publishConfig: PublishConfiguration, options: PublishOptions, isPublishOptionGuessed: boolean = false): Publisher | null {
function createPublisher(buildInfo: BuildInfo, publishConfig: PublishConfiguration, options: PublishOptions): Publisher | null {
const version = buildInfo.metadata.version!
if (publishConfig.provider === "github") {
const githubInfo: GithubOptions = publishConfig
log(`Creating Github Publisher — owner: ${githubInfo.owner}, project: ${githubInfo.repo}, version: ${version}`)
return new GitHubPublisher(githubInfo, version, options, isPublishOptionGuessed)
return new GitHubPublisher(githubInfo, version, options)
}
if (publishConfig.provider === "bintray") {
const bintrayInfo: BintrayOptions = publishConfig
Expand Down
13 changes: 4 additions & 9 deletions packages/electron-builder/src/publish/gitHubPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class GitHubPublisher extends Publisher {
return this._releasePromise
}

constructor(private readonly info: GithubOptions, private readonly version: string, private readonly options: PublishOptions = {}, private readonly isPublishOptionGuessed: boolean = false) {
constructor(private readonly info: GithubOptions, private readonly version: string, private readonly options: PublishOptions = {}) {
super()

let token = info.token
Expand Down Expand Up @@ -74,14 +74,9 @@ export class GitHubPublisher extends Publisher {
// if release created < 2 hours — allow to upload
const publishedAt = release.published_at == null ? null : new Date(release.published_at)
if (publishedAt != null && (Date.now() - publishedAt.getMilliseconds()) > (2 * 3600 * 1000)) {
const message = `Release with tag ${this.tag} published at ${publishedAt.toString()}, more than 2 hours ago`
if (this.isPublishOptionGuessed) {
warn(message)
return null
}
else {
throw new Error(message)
}
// https://github.com/electron-userland/electron-builder/issues/1183#issuecomment-275867187
warn(`Release with tag ${this.tag} published at ${publishedAt.toString()}, more than 2 hours ago`)
return null
}
return release
}
Expand Down

0 comments on commit 5d64693

Please sign in to comment.