srm

semantic-release-ms-teams

A plugin for semantic-release which publish release notes in a Microsoft Teams channel

Showing:

Popularity

Downloads/wk

115

GitHub Stars

6

Maintenance

Last Commit

2mos ago

Contributors

3

Package

Dependencies

3

Size (min+gzip)

25.1KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

semantic-release-ms-teams

semantic-release plugin to send release notes to a teams channel when the release succeeds.

StepDescription
verifyConditionsCheck the webhookUrl option or TEAMS_WEBHOOK_URL variable
successSend a Teams message to notify of a new release.

Installation

npm install semantic-release-ms-teams --save-dev
# or
yarn add semantic-release-ms-teams --dev

This plugin is using an incoming webhook to notify a teams channel. Here is some documentation to create one.

Usage

// .releaserc.json
{
  "branches": ["main"],
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    ["semantic-release-ms-teams", {
      "webhookUrl": "...",
      "title": "A new version has been released",
      "imageUrl": "http://...",
      "showContributors": false
    }]
  ]
}
VariableDetailsDescription
webhookUrl or TEAMS_WEBHOOK_URLrequired, urlThe incoming webhook url of the channel to publish release notes to.
titleoptional, textThe title of the message. Default: A new version has been released
imageUrloptional, urlAn image displayed in the message, next to the title. The image must be less than 200x200.
showContributorsoptional, booleanWhether or not the contributors should be displayed in the message. Default: true

Notes

  • webhookUrl is a property of the config object in .releaserc.json, and, TEAMS_WEBHOOK_URL is an environment variable. The config object can be useful to try the plugin, but most of the time, production environments prefers environment variables. You can use both, but not in the same time as it does not make sense. If you do define both, the config object overrides the environment variable.

  • IMPORTANT: The webhookUrl variable you can use within your plugin configuration is meant to be used only for test purposes. Because you don't want to publicly publish this url and do let the world know a way to send messages to your teams channel, you will want to use the TEAMS_WEBHOOK_URL instead.

  • The default value for imageUrl is https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Gitlab_meaningful_logo.svg/144px-Gitlab_meaningful_logo.svg.png

  • The list of Contributors is built using the email associated with the commits (only the part before the "@" is kept). This list can be disable (mainly for privacy reasons).

  • The message is sent to Teams during the success step which is silenced in dryRun mode.

  • The official @semantic-release/git plugin may cause a second message to be sent (because the plugin potentially adds a commit on the current branch, to save changes in files like package.json, package-lock.json, CHANGELOG.md). In order to prevent that, an environment variable (HAS_PREVIOUS_SEM_REL_EXECUTION) is set to true after the first message, then this plugin won't send any other message, as long as the plugin is part of the config.

Screenshots

preview

Development

Here are some steps to test the plugin locally:

  • checkout the source code:
    git clone git@gitlab-ncsa.ubisoft.org:sragot/semantic-release-ms-teams.git
    cd semantic-release-ms-teams
    npm install
    
  • add a .releaserc.json file at the project's root, copy the code from the Usage section in this new file using the webhookUrl property, and add the following properties in the object:
    "ci": false,
    "dryRun": true,
    
  • open index.js and replace module.exports = { verifyConditions, success }; by module.exports = { verifyConditions, generateNotes: success }; to allow the publication within the dryRun mode
  • run semantic-release locally safely:
    npm link
    npm link semantic-release-ms-teams
    ./node_modules/.bin/semantic-release
    

Dependencies

Greatly inspired by semantic-release-slack-bot.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100