-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add additional release links to the release
A new option `addReleases` has been added. Setting this option will instruct the plugin to append all additional releases to the Github release on the top. Closes #281
- Loading branch information
Nils Plaschke
committed
Sep 1, 2020
1 parent
32654fb
commit 614d748
Showing
10 changed files
with
337 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const {RELEASE_NAME} = require('./definitions/constants'); | ||
|
||
const linkify = (releaseInfo) => | ||
`${ | ||
releaseInfo.url | ||
? releaseInfo.url.startsWith('http') | ||
? `[${releaseInfo.name}](${releaseInfo.url})` | ||
: `${releaseInfo.name}: \`${releaseInfo.url}\`` | ||
: `\`${releaseInfo.name}\`` | ||
}`; | ||
|
||
const filterReleases = (releaseInfos) => | ||
releaseInfos.filter((releaseInfo) => releaseInfo.name && releaseInfo.name !== RELEASE_NAME); | ||
|
||
module.exports = (releaseInfos) => | ||
`${ | ||
filterReleases(releaseInfos).length > 0 | ||
? `This release is also available on:\n${filterReleases(releaseInfos) | ||
.map((releaseInfo) => `- ${linkify(releaseInfo)}`) | ||
.join('\n')}\n---\n` | ||
: '' | ||
}`; |
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
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
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const test = require('ava'); | ||
const getReleaseLinks = require('../lib/get-release-links'); | ||
const {RELEASE_NAME} = require('../lib/definitions/constants'); | ||
|
||
test('Comment for release with multiple releases', (t) => { | ||
const releaseInfos = [ | ||
{name: RELEASE_NAME, url: 'https://github.com/release'}, | ||
{name: 'Http release', url: 'https://release.com/release'}, | ||
{name: 'npm release', url: 'https://npm.com/release'}, | ||
]; | ||
const comment = getReleaseLinks(releaseInfos); | ||
|
||
t.is( | ||
comment, | ||
`This release is also available on: | ||
- [Http release](https://release.com/release) | ||
- [npm release](https://npm.com/release) | ||
--- | ||
` | ||
); | ||
}); | ||
|
||
test('Release with missing release URL', (t) => { | ||
const releaseInfos = [ | ||
{name: RELEASE_NAME, url: 'https://github.com/release'}, | ||
{name: 'Http release', url: 'https://release.com/release'}, | ||
{name: 'npm release'}, | ||
]; | ||
const comment = getReleaseLinks(releaseInfos); | ||
|
||
t.is( | ||
comment, | ||
`This release is also available on: | ||
- [Http release](https://release.com/release) | ||
- \`npm release\` | ||
--- | ||
` | ||
); | ||
}); | ||
|
||
test('Release with one release', (t) => { | ||
const releaseInfos = [ | ||
{name: RELEASE_NAME, url: 'https://github.com/release'}, | ||
{name: 'Http release', url: 'https://release.com/release'}, | ||
]; | ||
const comment = getReleaseLinks(releaseInfos); | ||
|
||
t.is( | ||
comment, | ||
`This release is also available on: | ||
- [Http release](https://release.com/release) | ||
--- | ||
` | ||
); | ||
}); | ||
|
||
test('Release with non http releases', (t) => { | ||
const releaseInfos = [{name: 'S3', url: 's3://my-bucket/release-asset'}]; | ||
const comment = getReleaseLinks(releaseInfos); | ||
|
||
t.is( | ||
comment, | ||
`This release is also available on: | ||
- S3: \`s3://my-bucket/release-asset\` | ||
--- | ||
` | ||
); | ||
}); | ||
|
||
test('Release with only github release', (t) => { | ||
const releaseInfos = [{name: RELEASE_NAME, url: 'https://github.com/release'}]; | ||
const comment = getReleaseLinks(releaseInfos); | ||
|
||
t.is(comment, ''); | ||
}); | ||
|
||
test('Comment with no release object', (t) => { | ||
const releaseInfos = []; | ||
const comment = getReleaseLinks(releaseInfos); | ||
|
||
t.is(comment, ''); | ||
}); |
Oops, something went wrong.