Giter Site home page Giter Site logo

yllieth / semantic-release-ms-teams Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 14.0 530 KB

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

License: MIT License

JavaScript 100.00%
semantic-release-plugin teams release-notes webhook

semantic-release-ms-teams's Introduction

semantic-release-ms-teams

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

Step Description
verifyConditions Check the webhookUrl option or TEAMS_WEBHOOK_URL variable.
generateNotes Allow sending release note to MS Teams in dry-run mode.
success Send 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,
      "notifyInDryRun": true,
    }]
  ]
}
Variable Details Description
webhookUrl or TEAMS_WEBHOOK_URL required, url The incoming webhook url of the channel to publish release notes to.
webhookUrlDryRun or TEAMS_WEBHOOK_URL_DRYRUN optional, url Similar to webhookUrl or TEAMS_WEBHOOK_URL, but will be used in dryRun mode. Default: webhookUrl or TEAMS_WEBHOOK_URL
title optional, text The title of the message. Default: A new version has been released
imageUrl optional, url An image displayed in the message, next to the title. The image must be less than 200x200.
showContributors optional, boolean Whether or not the contributors should be displayed in the message. Default: true
notifyInDryRun optional, boolean Whether or not the release notes will be send to Teams when semantic-release runs in dry-run mode. 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.

  • When in dry-run mode, here are the order of considered urls: webhookUrlDryRun, TEAMS_WEBHOOK_URL_DRY_RUN, webhookUrl, TEAMS_WEBHOOK_URL

  • 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 disabled (mainly for privacy reasons).

  • 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 preview

Development

Here are some steps to test the plugin locally:

  • checkout the source code:
    git clone [email protected]:sragot/semantic-release-ms-teams.git
    cd semantic-release-ms-teams
    npm install
  • create a personal access token in github, then export GH_TOKEN=...
  • run semantic-release locally safely:
    npm link
    npm link semantic-release-ms-teams
    npm run release -- --dry-run --no-ci

Dependencies

Greatly inspired by semantic-release-slack-bot ... Thanks ;)

semantic-release-ms-teams's People

Contributors

pgoudreau avatar sedx avatar semantic-release-bot avatar yllieth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

semantic-release-ms-teams's Issues

An error occurred while running semantic-release: Error: Cannot find module 'aggregate-error'

I'm facing an issue with the plugin resulting in a Error: Cannot find module 'aggregate-error' error. My semantic-release process did work before without any issue.

Steps - what I did so far:

  • ✅ Create MS Teams Webhook URL
  • ✅ Set TEAMS_WEBHOOK_URL as ENV for the pipeline
  • ✅ add plugin to .releaserc (see file below)
  • ✅ install plugin into my build docker image

With all of theses steps done I get the following error during the pipeline execution:

Gitlab CI Logs

9:45:05 AM] [semantic-release] › ℹ  Running semantic-release version 19.0.5
[9:45:05 AM] [semantic-release] › ✖  An error occurred while running semantic-release: Error: Cannot find module 'aggregate-error'
Require stack:
- /usr/local/lib/node_modules/semantic-release-ms-teams/lib/lifecycle-verify-conditions.js
- /usr/local/lib/node_modules/semantic-release-ms-teams/index.js
- /usr/local/lib/node_modules/semantic-release/lib/plugins/utils.js
- /usr/local/lib/node_modules/semantic-release/lib/plugins/index.js
- /usr/local/lib/node_modules/semantic-release/lib/get-config.js
- /usr/local/lib/node_modules/semantic-release/index.js
- /usr/local/lib/node_modules/semantic-release/cli.js
- /usr/local/lib/node_modules/semantic-release/bin/semantic-release.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/semantic-release-ms-teams/lib/lifecycle-verify-conditions.js:1:[24](https://gitlab.com/farmact/services/mail-service/-/jobs/3109036572#L24))
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/semantic-release-ms-teams/lib/lifecycle-verify-conditions.js',
    '/usr/local/lib/node_modules/semantic-release-ms-teams/index.js',
    '/usr/local/lib/node_modules/semantic-release/lib/plugins/utils.js',
    '/usr/local/lib/node_modules/semantic-release/lib/plugins/index.js',
    '/usr/local/lib/node_modules/semantic-release/lib/get-config.js',
    '/usr/local/lib/node_modules/semantic-release/index.js',
    '/usr/local/lib/node_modules/semantic-release/cli.js',
    '/usr/local/lib/node_modules/semantic-release/bin/semantic-release.js'
  ]
}
Error: Cannot find module 'aggregate-error'
Require stack:
- /usr/local/lib/node_modules/semantic-release-ms-teams/lib/lifecycle-verify-conditions.js
- /usr/local/lib/node_modules/semantic-release-ms-teams/index.js
- /usr/local/lib/node_modules/semantic-release/lib/plugins/utils.js
- /usr/local/lib/node_modules/semantic-release/lib/plugins/index.js
- /usr/local/lib/node_modules/semantic-release/lib/get-config.js
- /usr/local/lib/node_modules/semantic-release/index.js
- /usr/local/lib/node_modules/semantic-release/cli.js
- /usr/local/lib/node_modules/semantic-release/bin/semantic-release.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/semantic-release-ms-teams/lib/lifecycle-verify-conditions.js:1:24)
    at Module._compile (node:internal/modules/cjs/loader:11[26](https://gitlab.com/farmact/services/mail-service/-/jobs/3109036572#L26):14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:10[28](https://gitlab.com/farmact/services/mail-service/-/jobs/3109036572#L28):19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/semantic-release-ms-teams/lib/lifecycle-verify-conditions.js',
    '/usr/local/lib/node_modules/semantic-release-ms-teams/index.js',
    '/usr/local/lib/node_modules/semantic-release/lib/plugins/utils.js',
    '/usr/local/lib/node_modules/semantic-release/lib/plugins/index.js',
    '/usr/local/lib/node_modules/semantic-release/lib/get-config.js',
    '/usr/local/lib/node_modules/semantic-release/index.js',
    '/usr/local/lib/node_modules/semantic-release/cli.js',
    '/usr/local/lib/node_modules/semantic-release/bin/semantic-release.js'
  ]
}

.releaserc

{
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "angular",
        "releaseRules": [
          {
            "type": "bump",
            "release": "minor"
          },
          {
            "type": "bump",
            "scope": "minor",
            "release": "minor"
          },
          {
            "type": "bump",
            "scope": "major",
            "release": "major"
          }
        ]
      }
    ],
    [
      "@semantic-release/release-notes-generator"
    ],
    [
      "@semantic-release/changelog",
      {
        "changelogFile": "CHANGELOG.md"
      }
    ],
    [
      "@semantic-release/exec",
      {
        "publishCmd": "echo 'VERSION=${nextRelease.version}' >> .env",
        "shell": true
      }
    ],
    "semantic-release-ms-teams",
    [
      "@semantic-release/gitlab",
      {
        "gitlabUrl": "${CI_PROJECT_URL}"
      }
    ]
  ],
  "branches": [
    "+([0-9])?(.{+([0-9]),x}).x",
    "main",
    {
      "name": "beta",
      "prerelease": "beta"
    },
    {
      "name": "dev",
      "prerelease": "dev"
    }
  ]
}

Dockerfile for my build image

FROM node:lts

LABEL maintainer "Jonas Schmitt <[email protected]>"

RUN curl -O https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh && bash script.deb.sh
RUN apt-get install git-lfs

RUN npm install -g semantic-release \
  @semantic-release/gitlab \
  @semantic-release/git \
  @semantic-release/exec \
  @semantic-release/release-notes-generator \
  @semantic-release/changelog \
  semantic-release-slack-bot \
  semantic-release-ms-teams

Am I missing something here?

Improve section detection

Right now, we’re looking only for the 3 main sections (Bug Fixes, Features, and BREAKING CHANGES), but this lacks flexibility to discover any section available.

Looser semantic-release peer dependency version

Hi 👋,

With latest [email protected] when installing this plugin with npm I get following error:

Could not resolve dependency:
npm ERR! peer semantic-release@">=17.0.0 <18.0.0" from [email protected]
npm ERR! node_modules/semantic-release-ms-teams

This happens because semantic-release peer dependency version is to strict, link

I would suggestion something like this:

{
 "peerDependencies": {
    "semantic-release": "^18 || ^19",
  },
}

Add Proxy-Configuration for business and special environments

Background:
As mentioned in this pull-request, this plugin would be much more powerful with an proxy configuration option. Foremost in business-environments.
I opened this issue so discussions can take place.

What we need:
We use proxies internally, so we need an option to configure this specific proxy for node-fetch

What to do?

  • Allow to set "proxyUrl" in the configuration file
  • Allow to use "PROXY_URL", "http_proxy", "https_proxy" in the environment vars
  • Pass configuration to node-fetch

Alternatives?

  • replace node-fetch with node-fetch-with-proxy which supports the HTTP_PROXY env-var

Our Solution:
We can deploy the plugin for our need internally but i wanted to share this feature with the world. We are not in need to see this feature coming officially, but it would be great.

Yarn v2 required

First and foremost, thank you for your work and open-sourcing this :)

I have an issue with using this in a repository still on classic yarn. Is yarn v2 required to use this package? I believe many people out there don't like the v2 yarn and are not planning to upgrade, and setting the min version to v2 through engines is a bit of a problem.

I'm a maintainer of a bunch of (private) npm libraries and the only thing I set in package.json's engines is a min version of node.

Error while running for the first time

[semantic-release] » ×  An error occurred while running semantic-release: Error: Cannot handle value ``, expected node
    at Object.invalid (___\semantic-release-ms-teams\node_modules\mdast-util-to-markdown\lib\index.js:61:9)
    at Object.one [as handle] (___\semantic-release-ms-teams\node_modules\zwitch\index.js:20:25)
    at flow (___\semantic-release-ms-teams\node_modules\mdast-util-to-markdown\lib\util\container-flow.js:15:15)
    at Object.root (___\semantic-release-ms-teams\node_modules\mdast-util-to-markdown\lib\handle\root.js:6:10)
    at Object.one [as handle] (___\semantic-release-ms-teams\node_modules\zwitch\index.js:20:25)
    at toMarkdown (___\semantic-release-ms-teams\node_modules\mdast-util-to-markdown\lib\index.js:38:20)
    at extractBugfixes (___\semantic-release-ms-teams\src\teamsify.js:85:10)
    at releaseSections (___\semantic-release-ms-teams\src\teamsify.js:152:15)
    at module.exports (___\semantic-release-ms-teams\src\teamsify.js:199:20)
    at module.exports (___\semantic-release-ms-teams\src\success.js:9:37) {
  pluginName: 'semantic-release-ms-teams'
}
Error: Cannot handle value ``, expected node
    at Object.invalid (___\semantic-release-ms-teams\node_modules\mdast-util-to-markdown\lib\index.js:61:9)
    at Object.one [as handle] (___\semantic-release-ms-teams\node_modules\zwitch\index.js:20:25)
    at flow (___\semantic-release-ms-teams\node_modules\mdast-util-to-markdown\lib\util\container-flow.js:15:15)
    at Object.root (___\semantic-release-ms-teams\node_modules\mdast-util-to-markdown\lib\handle\root.js:6:10)
    at Object.one [as handle] (___\semantic-release-ms-teams\node_modules\zwitch\index.js:20:25)
    at toMarkdown (___\semantic-release-ms-teams\node_modules\mdast-util-to-markdown\lib\index.js:38:20)
    at extractBugfixes (___\semantic-release-ms-teams\src\teamsify.js:85:10)
    at releaseSections (___\semantic-release-ms-teams\src\teamsify.js:152:15)
    at module.exports (___\semantic-release-ms-teams\src\teamsify.js:199:20)
    at module.exports (___\semantic-release-ms-teams\src\success.js:9:37) {
  pluginName: 'semantic-release-ms-teams'
}

Support `[email protected]`

The Problem

There is a PeerDep for semantic-release@19 in place which won't allow the usage of this plugin with the most recent version of semantic release (21.0.2).

"semantic-release": "19"

Running semantic-release with the following plugins results in this:

Error: Command failed: npm install @semantic-release/changelog @semantic-release/git @semantic-release/exec @semantic-release/release-notes-generator @semantic-release/changelog semantic-release-slack-bot semantic-release-ms-teams [email protected] --no-audit 
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @cycjimmy/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/semantic-release
npm ERR!   semantic-release@"^21.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer semantic-release@"19" from [email protected]
npm ERR! node_modules/semantic-release-ms-teams
npm ERR!   semantic-release-ms-teams@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /root/.npm/_logs/2023-05-02T06_30_26_475Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-05-02T06_30_26_475Z-debug-0.log

Q: Is there support for semantic-release@21 planned in the near future?

Message is sent to teams twice

When adding @semantic-release/git in the list of plugins, we start to see the message sent to MS Teams twice, and the second one is "weird".

image

The second message is triggered by @semantic-release/git which create a new commit on the branch watched by semantic release to save changes in files like package.json or CHANGELOG.md.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.