Skip to content

Commit

Permalink
fix: fix release note on slack
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed May 25, 2022
1 parent 41a21e8 commit 257a5c3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 58 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
"proxyquire": "2.1.3",
"semantic-release": "19.0.2",
"semantic-release-slack-bot": "3.5.3",
"slackify-markdown": "^4.3.1",
"sinon": "13.0.1",
"sinon-chai": "3.7.0",
"supertest": "6.2.2",
Expand Down
58 changes: 2 additions & 56 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,4 @@
const getRepoInfo = require("semantic-release-slack-bot/lib/getRepoInfo");
const slackifyMarkdown = require("slackify-markdown");

function onSuccessFunction(pluginConfig, context) {
const {nextRelease, notes: releaseNotes, options} = context;
const repo = getRepoInfo(options.repositoryUrl);
const messageBlocks = [
{
type: "section",
text: {
type: "mrkdwn",
text: `A new version of \`Ts.ED\` has been released!\nCurrent version is *${nextRelease.version}*`
}
}
];

const slackMessage = {
blocks: messageBlocks
};

if (releaseNotes !== "") {
messageBlocks.push({
type: "section",
text: {
type: "mrkdwn",
text: slackifyMarkdown(releaseNotes)
}
});
}

if (repo.path) {
const gitTag = nextRelease.gitTag;
const gitTagPrefix = repo.hostname.startsWith("gitlab") ? "/-/releases/" : "/releases/tag/";
const gitTagUrl = repo.URL + gitTagPrefix + gitTag;

slackMessage.attachments = [
{
color: "#2cbe4e",
blocks: [
{
type: "context",
elements: [
{
type: "mrkdwn",
text: `:package: *<${repo.URL}|${repo.path}>:* <${gitTagUrl}|${gitTag}>`
}
]
}
]
}
];
}

return slackMessage;
}
process.env.SEMANTIC_RELEASE_PACKAGE = "Ts.ED";

module.exports = {
branches: [
Expand All @@ -78,7 +24,7 @@ module.exports = {
[
"semantic-release-slack-bot",
{
onSuccessFunction,
markdownReleaseNotes: true,
notifyOnSuccess: true
}
]
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21187,7 +21187,7 @@ sisteransi@^1.0.5:
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==

slackify-markdown@^4.3.0, slackify-markdown@^4.3.1:
slackify-markdown@^4.3.0:
version "4.3.1"
resolved "https://registry.yarnpkg.com/slackify-markdown/-/slackify-markdown-4.3.1.tgz#1bfaf03bc4a8d617827326e137a9316b165ba4ab"
integrity sha512-6Uktkq4rEB6JZlRguI/dpPDF6Rak6QXZm3Gv2IM0VMeYQRSufp+TLFfOylxwINnOeMRc9ciYRhsbt1hUFD+uuQ==
Expand Down

0 comments on commit 257a5c3

Please sign in to comment.