Skip to content

Commit

Permalink
fix(publish): fix publishing request
Browse files Browse the repository at this point in the history
- Change HTTP verb from PUT to POST.
- Remove `ref` and change `release_description` to `description` in body of request.
  • Loading branch information
DewarM authored and pvdlg committed Feb 9, 2018
1 parent 9cf0a55 commit 3ca17c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/publish.js
Expand Up @@ -14,10 +14,10 @@ module.exports = async (pluginConfig, {repositoryUrl}, {gitHead, gitTag, notes},
debug('release ref: %o', gitHead);

debug('Update git tag %o with commit %o and release description', gitTag, gitHead);
await got.put(urlJoin(apiUrl, `/projects/${repoId}/repository/tags/${gitTag}/release`), {
await got.post(urlJoin(apiUrl, `/projects/${repoId}/repository/tags/${gitTag}/release`), {
json: true,
headers: {'PRIVATE-TOKEN': gitlabToken},
body: {tag_name: gitTag, ref: gitHead, release_description: notes}, // eslint-disable-line camelcase
body: {tag_name: gitTag, description: notes}, // eslint-disable-line camelcase
});

logger.log('Published GitLab release: %s', gitTag);
Expand Down
10 changes: 4 additions & 6 deletions test/integration.test.js
Expand Up @@ -57,10 +57,9 @@ test.serial('Publish a release', async t => {
const gitlab = authenticate()
.get(`/projects/${owner}%2F${repo}`)
.reply(200, {permissions: {project_access: {access_level: 30}}})
.put(`/projects/${owner}%2F${repo}/repository/tags/${nextRelease.gitTag}/release`, {
.post(`/projects/${owner}%2F${repo}/repository/tags/${nextRelease.gitTag}/release`, {
tag_name: nextRelease.gitTag,
ref: nextRelease.gitHead,
release_description: nextRelease.notes,
description: nextRelease.notes,
})
.reply(200);

Expand All @@ -81,10 +80,9 @@ test.serial('Verify Github auth and release', async t => {
const gitlab = authenticate()
.get(`/projects/${owner}%2F${repo}`)
.reply(200, {permissions: {project_access: {access_level: 30}}})
.put(`/projects/${owner}%2F${repo}/repository/tags/${nextRelease.gitTag}/release`, {
.post(`/projects/${owner}%2F${repo}/repository/tags/${nextRelease.gitTag}/release`, {
tag_name: nextRelease.gitTag,
ref: nextRelease.gitHead,
release_description: nextRelease.notes,
description: nextRelease.notes,
})
.reply(200);

Expand Down
5 changes: 2 additions & 3 deletions test/publish.test.js
Expand Up @@ -39,10 +39,9 @@ test.serial('Publish a release', async t => {
const options = {repositoryUrl: `https://gitlab.com/${owner}/${repo}.git`};

const gitlab = authenticate()
.put(`/projects/${owner}%2F${repo}/repository/tags/${nextRelease.gitTag}/release`, {
.post(`/projects/${owner}%2F${repo}/repository/tags/${nextRelease.gitTag}/release`, {
tag_name: nextRelease.gitTag,
ref: nextRelease.gitHead,
release_description: nextRelease.notes,
description: nextRelease.notes,
})
.reply(200);

Expand Down

0 comments on commit 3ca17c6

Please sign in to comment.