-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use the
branch.main
flag to determine is the release need the …
…`prerelease` flag
- Loading branch information
Showing
5 changed files
with
52 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = ({type, channel}) => type === 'prerelease' || (type === 'release' && Boolean(channel)); | ||
module.exports = ({type, main}) => type === 'prerelease' || (type === 'release' && !main); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,14 +29,13 @@ test.serial('Update a release', async t => { | |
const repo = 'test_repo'; | ||
const env = {GITHUB_TOKEN: 'github_token'}; | ||
const pluginConfig = {}; | ||
const currentRelease = {gitTag: 'v1.0.0@next', channel: 'next', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`}; | ||
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; | ||
const releaseId = 1; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.reply(200, {id: releaseId}) | ||
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, { | ||
tag_name: nextRelease.gitTag, | ||
|
@@ -48,8 +47,7 @@ test.serial('Update a release', async t => { | |
const result = await addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'release'}, | ||
currentRelease, | ||
branch: {type: 'release', main: true}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}); | ||
|
@@ -59,21 +57,21 @@ test.serial('Update a release', async t => { | |
t.true(github.isDone()); | ||
}); | ||
|
||
test.serial('Update a LTS release', async t => { | ||
test.serial('Update a maintenance release', async t => { | ||
const owner = 'test_user'; | ||
const repo = 'test_repo'; | ||
const env = {GITHUB_TOKEN: 'github_token'}; | ||
const pluginConfig = {}; | ||
const currentRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: '[email protected]', channel: '1.x', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: 'v1.0.0', channel: '1.x', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`}; | ||
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; | ||
const releaseId = 1; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.reply(200, {id: releaseId}) | ||
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, { | ||
tag_name: nextRelease.gitTag, | ||
name: nextRelease.name, | ||
prerelease: false, | ||
}) | ||
|
@@ -82,8 +80,7 @@ test.serial('Update a LTS release', async t => { | |
const result = await addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'lts', channel: '1.x'}, | ||
currentRelease, | ||
branch: {type: 'maintenance', channel: '1.x', main: false}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}); | ||
|
@@ -98,19 +95,13 @@ test.serial('Update a prerelease', async t => { | |
const repo = 'test_repo'; | ||
const env = {GITHUB_TOKEN: 'github_token'}; | ||
const pluginConfig = {}; | ||
const currentRelease = { | ||
gitTag: 'v1.0.0-beta.1', | ||
channel: 'beta', | ||
name: 'v1.0.0-beta.1', | ||
notes: 'Test release note body', | ||
}; | ||
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`}; | ||
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; | ||
const releaseId = 1; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.reply(200, {id: releaseId}) | ||
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, { | ||
tag_name: nextRelease.gitTag, | ||
|
@@ -122,8 +113,7 @@ test.serial('Update a prerelease', async t => { | |
const result = await addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'lts', channel: '1.x'}, | ||
currentRelease, | ||
branch: {type: 'maintenance', channel: '1.x', main: false}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}); | ||
|
@@ -138,14 +128,13 @@ test.serial('Update a release with a custom github url', async t => { | |
const repo = 'test_repo'; | ||
const env = {GH_URL: 'https://othertesturl.com:443', GH_TOKEN: 'github_token', GH_PREFIX: 'prefix'}; | ||
const pluginConfig = {}; | ||
const currentRelease = {gitTag: 'v1.0.0@next', channel: 'next', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `${env.GH_URL}/${owner}/${repo}.git`}; | ||
const releaseUrl = `${env.GH_URL}/${owner}/${repo}/releases/${nextRelease.version}`; | ||
const releaseId = 1; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.reply(200, {id: releaseId}) | ||
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, { | ||
tag_name: nextRelease.gitTag, | ||
|
@@ -157,8 +146,7 @@ test.serial('Update a release with a custom github url', async t => { | |
const result = await addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'release'}, | ||
currentRelease, | ||
branch: {type: 'release', main: true}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}); | ||
|
@@ -173,17 +161,16 @@ test.serial('Update a release, retrying 4 times', async t => { | |
const repo = 'test_repo'; | ||
const env = {GITHUB_TOKEN: 'github_token'}; | ||
const pluginConfig = {}; | ||
const currentRelease = {gitTag: 'v1.0.0@next', channel: 'next', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`}; | ||
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; | ||
const releaseId = 1; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.times(3) | ||
.reply(404) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.reply(200, {id: releaseId}) | ||
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, { | ||
tag_name: nextRelease.gitTag, | ||
|
@@ -202,8 +189,7 @@ test.serial('Update a release, retrying 4 times', async t => { | |
const result = await addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'release'}, | ||
currentRelease, | ||
branch: {type: 'release', main: true}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}); | ||
|
@@ -218,13 +204,12 @@ test.serial('Create the new release if current one is missing', async t => { | |
const repo = 'test_repo'; | ||
const env = {GITHUB_TOKEN: 'github_token'}; | ||
const pluginConfig = {}; | ||
const currentRelease = {gitTag: 'v1.0.0@next', channel: 'next', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`}; | ||
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.times(4) | ||
.reply(404) | ||
.post(`/repos/${owner}/${repo}/releases`, { | ||
|
@@ -238,14 +223,13 @@ test.serial('Create the new release if current one is missing', async t => { | |
const result = await addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'release'}, | ||
currentRelease, | ||
branch: {type: 'release', main: true}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}); | ||
|
||
t.is(result.url, releaseUrl); | ||
t.deepEqual(t.context.log.args[0], ['There is no release for tag %s, creating a new one', currentRelease.gitTag]); | ||
t.deepEqual(t.context.log.args[0], ['There is no release for tag %s, creating a new one', nextRelease.gitTag]); | ||
t.deepEqual(t.context.log.args[1], ['Published GitHub release: %s', releaseUrl]); | ||
t.true(github.isDone()); | ||
}); | ||
|
@@ -255,21 +239,19 @@ test.serial('Throw error if cannot read current release', async t => { | |
const repo = 'test_repo'; | ||
const env = {GITHUB_TOKEN: 'github_token'}; | ||
const pluginConfig = {}; | ||
const currentRelease = {gitTag: 'v1.0.0@next', channel: 'next', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`}; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.times(4) | ||
.reply(500); | ||
|
||
const error = await t.throwsAsync( | ||
addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'release'}, | ||
currentRelease, | ||
branch: {type: 'release', main: true}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}) | ||
|
@@ -284,12 +266,11 @@ test.serial('Throw error if cannot create missing current release', async t => { | |
const repo = 'test_repo'; | ||
const env = {GITHUB_TOKEN: 'github_token'}; | ||
const pluginConfig = {}; | ||
const currentRelease = {gitTag: 'v1.0.0@next', channel: 'next', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`}; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.times(4) | ||
.reply(404) | ||
.post(`/repos/${owner}/${repo}/releases`, { | ||
|
@@ -305,8 +286,7 @@ test.serial('Throw error if cannot create missing current release', async t => { | |
addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'release'}, | ||
currentRelease, | ||
branch: {type: 'release', main: true}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}) | ||
|
@@ -321,13 +301,12 @@ test.serial('Throw error if cannot update release', async t => { | |
const repo = 'test_repo'; | ||
const env = {GITHUB_TOKEN: 'github_token'}; | ||
const pluginConfig = {}; | ||
const currentRelease = {gitTag: 'v1.0.0@next', channel: 'next', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'}; | ||
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`}; | ||
const releaseId = 1; | ||
|
||
const github = authenticate(env) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${currentRelease.gitTag}`) | ||
.get(`/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`) | ||
.reply(200, {id: releaseId}) | ||
.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, { | ||
tag_name: nextRelease.gitTag, | ||
|
@@ -341,8 +320,7 @@ test.serial('Throw error if cannot update release', async t => { | |
addChannel(pluginConfig, { | ||
env, | ||
options, | ||
branch: {type: 'release'}, | ||
currentRelease, | ||
branch: {type: 'release', main: true}, | ||
nextRelease, | ||
logger: t.context.logger, | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.