Skip to content

Commit

Permalink
feat(publisher-github): allow to override existing assets
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #1760
  • Loading branch information
mahnunchik committed Dec 18, 2020
1 parent 96cb015 commit 00c419a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/publisher/github/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ export interface PublisherGitHubConfig {
* Whether or not this release should be tagged as a draft
*/
draft?: boolean;
/**
* Re-upload the new asset if you upload an asset with the same filename as existing asset
*/
override?: boolean;
}
14 changes: 12 additions & 2 deletions packages/publisher/github/src/PublisherGithub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,19 @@ export default class PublisherGithub extends PublisherBase<PublisherGitHubConfig
.replace(/\.$/g, '')
.replace(/[^\w.-]/g, '-');
// eslint-disable-next-line max-len
if (release!.assets.find((asset: OctokitReleaseAsset) => asset.name === artifactName)) {
return done();
const asset = release!.assets.find((asset: OctokitReleaseAsset) => item.name === artifactName);
if (asset !== undefined) {
if (config.override === true) {
await github.getGitHub().repos.deleteReleaseAsset({
owner: config.repository.owner,
repo: config.repository.name,
asset_id: asset.id,
});
} else {
return done();
}
}

await github.getGitHub().repos.uploadReleaseAsset({
owner: config.repository.owner,
repo: config.repository.name,
Expand Down

0 comments on commit 00c419a

Please sign in to comment.