Skip to content

Commit

Permalink
Fix github preRelease option (fixes #679)
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Aug 22, 2020
1 parent ea67fbe commit 49742cb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/plugin/github/GitHub.js
Expand Up @@ -169,7 +169,7 @@ class GitHub extends Release {

getOctokitReleaseOptions(options = {}) {
const { owner, project: repo } = this.getContext('repo');
const { draft = false, releaseName } = this.options;
const { releaseName, draft = false, preRelease = false } = this.options;
const { version, tagName, releaseNotes } = this.getContext();
const { isPreRelease } = parseVersion(version);
const name = format(releaseName, this.config.getContext());
Expand All @@ -182,7 +182,7 @@ class GitHub extends Release {
name,
body,
draft,
prerelease: isPreRelease
prerelease: isPreRelease || preRelease
});
}

Expand Down
28 changes: 28 additions & 0 deletions test/github.js
Expand Up @@ -64,6 +64,34 @@ test('should release and upload assets', async t => {
exec.restore();
});

test('should create a pre-release and draft release notes', async t => {
const options = {
git,
github: {
pushRepo,
tokenRef,
release: true,
releaseName: 'Release ${tagName}',
preRelease: true,
draft: true
}
};
const github = factory(GitHub, { options });
const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git describe --tags --abbrev=0').resolves('2.0.1');

interceptAuthentication();
interceptCollaborator();
interceptCreate({ body: { tag_name: '2.0.2', name: 'Release 2.0.2', body: null, prerelease: true, draft: true } });

await runTasks(github);

const { isReleased, releaseUrl } = github.getContext();
t.true(isReleased);
t.is(releaseUrl, 'https://github.com/user/repo/releases/tag/2.0.2');
exec.restore();
});

test('should update release and upload assets', async t => {
const asset = 'file1';
const options = {
Expand Down

0 comments on commit 49742cb

Please sign in to comment.