Skip to content

Commit 20ee38e

Browse files
michael-wolfendengr2m
authored andcommitted
fix: return the url of the final release rather than the url the draft (#214)
Fixes #212
1 parent a418ba0 commit 20ee38e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/publish.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = async (pluginConfig, context) => {
5050
const draftRelease = {...releaseData, draft: true};
5151

5252
const {
53-
data: {html_url: url, upload_url: uploadUrl, id: releaseId},
53+
data: {upload_url: uploadUrl, id: releaseId},
5454
} = await github.repos.createRelease(draftRelease);
5555

5656
// Append assets to the release
@@ -108,7 +108,9 @@ module.exports = async (pluginConfig, context) => {
108108
};
109109
/* eslint-enable */
110110

111-
await github.repos.updateRelease(release);
111+
const {
112+
data: {html_url: url},
113+
} = await github.repos.updateRelease(release);
112114

113115
logger.log('Published GitHub release: %s', url);
114116
return {url, name: 'GitHub release'};

test/publish.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ test.serial('Publish a release with one asset', async t => {
101101
};
102102
const nextRelease = {version: '1.0.0', gitHead: '123', gitTag: 'v1.0.0', notes: 'Test release note body'};
103103
const options = {branch: 'master', repositoryUrl: `https://github.com/${owner}/${repo}.git`};
104+
const untaggedReleaseUrl = `https://github.com/${owner}/${repo}/releases/untagged-123`;
104105
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`;
105106
const assetUrl = `https://github.com/${owner}/${repo}/releases/download/${nextRelease.version}/.dotfile`;
106107
const releaseId = 1;
@@ -115,7 +116,7 @@ test.serial('Publish a release with one asset', async t => {
115116
body: nextRelease.notes,
116117
draft: true,
117118
})
118-
.reply(200, {upload_url: uploadUrl, html_url: releaseUrl, id: releaseId})
119+
.reply(200, {upload_url: uploadUrl, html_url: untaggedReleaseUrl, id: releaseId})
119120
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, {
120121
draft: false,
121122
})
@@ -146,6 +147,7 @@ test.serial('Publish a release with one asset and custom github url', async t =>
146147
};
147148
const nextRelease = {version: '1.0.0', gitHead: '123', gitTag: 'v1.0.0', notes: 'Test release note body'};
148149
const options = {branch: 'master', repositoryUrl: `https://github.com/${owner}/${repo}.git`};
150+
const untaggedReleaseUrl = `${env.GH_URL}/${owner}/${repo}/releases/untagged-123`;
149151
const releaseUrl = `${env.GH_URL}/${owner}/${repo}/releases/${nextRelease.version}`;
150152
const assetUrl = `${env.GH_URL}/${owner}/${repo}/releases/download/${nextRelease.version}/upload.txt`;
151153
const releaseId = 1;
@@ -160,7 +162,7 @@ test.serial('Publish a release with one asset and custom github url', async t =>
160162
body: nextRelease.notes,
161163
draft: true,
162164
})
163-
.reply(200, {upload_url: uploadUrl, html_url: releaseUrl, id: releaseId})
165+
.reply(200, {upload_url: uploadUrl, html_url: untaggedReleaseUrl, id: releaseId})
164166
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, {
165167
draft: false,
166168
})
@@ -190,6 +192,7 @@ test.serial('Publish a release with an array of missing assets', async t => {
190192
const pluginConfig = {assets: [emptyDirectory, {path: 'missing.txt', name: 'missing.txt'}]};
191193
const nextRelease = {version: '1.0.0', gitHead: '123', gitTag: 'v1.0.0', notes: 'Test release note body'};
192194
const options = {branch: 'master', repositoryUrl: `https://github.com/${owner}/${repo}.git`};
195+
const untaggedReleaseUrl = `https://github.com/${owner}/${repo}/releases/untagged-123`;
193196
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`;
194197
const releaseId = 1;
195198
const uploadUri = `/api/uploads/repos/${owner}/${repo}/releases/${releaseId}/assets`;
@@ -203,7 +206,7 @@ test.serial('Publish a release with an array of missing assets', async t => {
203206
body: nextRelease.notes,
204207
draft: true,
205208
})
206-
.reply(200, {upload_url: uploadUrl, html_url: releaseUrl, id: releaseId})
209+
.reply(200, {upload_url: uploadUrl, html_url: untaggedReleaseUrl, id: releaseId})
207210
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, {
208211
draft: false,
209212
})

0 commit comments

Comments
 (0)