juliuscc / semantic-release-slack-bot

📦 🚀 A slack bot for semantic-release notifying release statuses
MIT License
113 stars 36 forks source link

Why `$package_name` is not define automatically? #119

Open Thenkei opened 7 months ago

Thenkei commented 7 months ago

Hello 👋

I'm a little bit confused with the indication in the documentation and the reality.

Here's the description of packageName.

Option Description Default
packageName Override or add package name instead of npm package name SEMANTIC_RELEASE_PACKAGE or npm package name

In my case, I want the default behavior. For some reason, I get an error yelling at me: A name for the package must be created. Run through npm (npm run <semantic-release-script> to use npm package name or define packageName in the plugin config or SEMANTIC_RELEASE_PACKAGE in the environment

https://github.com/juliuscc/semantic-release-slack-bot/blob/214aef05f05a6f79e6c437245bb592b83d3f8844/lib/verifyConditions.js#L34C3-L47C4

So I am confused, I just want the default package name without any override.

(We use the plugin within a mono repo setup with multi-semantic-release, could this lead to a different behavior?)

Thenkei commented 7 months ago

After some deeper investigation it's related to multi-semantic-release that doesn't provide packageName within pluginConfig but a property name instead..

I came up with a trick doing the job in our case using the $release_notes that already include the actual package released.

[
      'semantic-release-slack-bot',
      {
        markdownReleaseNotes: true,
        notifyOnSuccess: true,
        notifyOnFail: false,
        onSuccessTemplate: {
          text: 'A new ($npm_package_name@$npm_package_version) has been released!',
          blocks: [
            {
              type: 'section',
              text: {
                type: 'mrkdwn',
                text: '*Changes* of version $release_notes',
              },
            },
          ],
        },
        packageName: 'whatever',
      },
    ],