Giter Site home page Giter Site logo

momocow / semantic-release-gitmoji Goto Github PK

View Code? Open in Web Editor NEW
86.0 3.0 18.0 1.68 MB

โœจ๐Ÿ›๐Ÿ’ฅ A semantic-release plugin for gitmojis. Different from conventional changelog, Gitmoji commits are used to determine a release type and generate release notes.

License: MIT License

JavaScript 90.83% Handlebars 9.17%
semantic-release semantic-release-plugin github release publish release-notes commit-analyzer gitmoji emoji changelog

semantic-release-gitmoji's Introduction

semantic-release-gitmoji

Test Status Release Status npm semantic-release Gitmoji

โœจ๐Ÿ›๐Ÿ’ฅ A semantic-release plugin for gitmojis.

Different from conventional changelog, Gitmoji commits are used to determine a release type and generate release notes.

Step Description
analyzeCommits Determine the type of release by analyzing commits with Gitmoji.
generateNotes Generate release notes for the commits added since the last release with Gitmoji.

Features

  • Categorize commits according to Gitmojis
  • Progressive commits composed of a final commit and several WIP (๐Ÿšง) commits

Install

npm install semantic-release-gitmoji -D

Usage

The plugin can be configured in the semantic-release configuration file:

// in ".releaserc.js" or "release.config.js"

const { promisify } = require('util')
const dateFormat = require('dateformat')
const readFileAsync = promisify(require('fs').readFile)

// Given a `const` variable `TEMPLATE_DIR` which points to "<semantic-release-gitmoji>/lib/assets/templates"

// the *.hbs template and partials should be passed as strings of contents
const template = readFileAsync(path.join(TEMPLATE_DIR, 'default-template.hbs'))
const commitTemplate = readFileAsync(path.join(TEMPLATE_DIR, 'commit-template.hbs'))

module.exports = {
  plugins: [
    [
      'semantic-release-gitmoji', {
        releaseRules: {
          major: [ ':boom:' ],
          minor: [ ':sparkles:' ],
          patch: [
            ':bug:',
            ':ambulance:',
            ':lock:'
          ]
        },
        releaseNotes: {
          template,
          partials: { commitTemplate },
          helpers: {
            datetime: function (format = 'UTC:yyyy-mm-dd') {
              return dateFormat(new Date(), format)
            }
          },
          issueResolution: {
            template: '{baseUrl}/{owner}/{repo}/issues/{ref}',
            baseUrl: 'https://github.com',
            source: 'github.com',
            removeFromCommit: false,
            regex: /#\d+/g
          }
        }
      }
    ],
    '@semantic-release/github',
    '@semantic-release/npm'
  ]
}

This configuration is the same semantic as the default configuration of semantic-release-gitmoji.

semantic-release-gitmoji should be used in place of both @semantic-release/commit-analyzer and @semantic-release/release-notes-generator since the both plugins parse commits following the conventional changelog while this plugin requires Gitmoji commits.

Configuration

It is recommended to write the configuration in a javascript file since templates are required to be strings of their contents.

interface SemanticReleaseGitmojiOptions {
  releaseRules?: ReleaseRules
  releaseNotes?: ReleaseNotesOptions
}

ReleaseRules

The ReleaseRules is a map from a release type to a set of emojis.

interface ReleaseRules {
  major?:      Array<Emoji> | EmojiArrayModifier
  premajor?:   Array<Emoji> | EmojiArrayModifier
  minor?:      Array<Emoji> | EmojiArrayModifier
  preminor?:   Array<Emoji> | EmojiArrayModifier
  patch?:      Array<Emoji> | EmojiArrayModifier
  prepatch?:   Array<Emoji> | EmojiArrayModifier
  prerelease?: Array<Emoji> | EmojiArrayModifier
}

Emoji

Emoji is a string of valid GitHub emoji markup (e.g. ":boom:", ":collision:") or raw emoji characters (e.g. "๐Ÿ’ฅ").

No need to worry about which format to use since this plugin handles it for you!

See https://github.com/omnidan/node-emoji for more information about emojis.

type Emoji = string

EmojiArrayModifier

interface EmojiArrayModifier {
  include?: Array<Emoji>
  exclude?: Array<Emoji>
}

ReleaseNotesOptions

ReleaseNotesOptions defines how to render the release notes from a given set of Gitmoji commits.

All templates file are compiled and renderered by handlebars, therefore you may need to get familiar with the .hbs format before starting to customize your own templates.

semver is a boolean to define if releaseNotes should be based on Gitmoji only or on key semver associated to gitmoji used in commit to determine the next release tag.

partials is a map from the partial name to the content of the partial template.

helpers is a map from the helper name to the helper function. There is already a default helper datetime which takes a format string as the first argument and return a formatted current timestamp. See npm/dateformat for more information about how to format a timestamp and see the default template as an example.

Besides, You are allowed to provide helpers with the same names to override default helpers.

issueResolution defines how issues are resolved to. The default and the only supported source currently is github.com, or you can provide your own issueResolution.template to override the default resolution to GitHub.

There are five variables that can be used in issueResolution.template:

  • baseUrl
  • owner
  • repo
  • ref, which is the numeric ID of issue
  • issue, which is the full issue
interface ReleaseNotesOptions {
  template?: TemplateContent
  semver?: Boolean
  partials?: Record<string, TemplateContent>
  helpers?: Record<string, Function>
  issueResolution?: {
    template?: string
    baseUrl?: string
    source?: 'github.com' | null // currently only GitHub is supported, PR welcome :)
    regex?: RegExp, // regex to match the issue(s). If not provided, will find issues thanks to [issue-regex](https://www.npmjs.com/package/issue-regex)
    removeFromCommit?: boolean // if true, will remove found issue(s) from commit name
  }
}

TemplateContent

type TemplateContent = string | Buffer | Promise<string> | Promise<Buffer>

Templates

Context

The context for templates is inherited from semantic-release context with some modifications such as owner, repo and compareUrl.

commits is a map from Emoji (don't worry about the format) to a list of extended commits. Values of commits are extended to contain more information related to Gitmoji. See CommitContext

interface TemplateContext {
  owner: string
  repo: string
  source: string
  commits: Record<string, Array<CommitContext>>
  lastRelease: {
    gitHead: string
    version: string
    gitTag: string
  }
  nextRelease: {
    type: string
    gitHead: string
    version: string
    gitTag: string
  }
  compareUrl: string
}

CommitContext

CommitContext is extended from SemanticReleaseCommitObj.

Note that emojis at the beginning of message and subject are trimmed, which are the same emoji in gitmoji.

gitmoji is a raw emoji since an emoji may have more than one GitHub emoji markup representation, e.g. ":boom:" and ":collision:" both represent for th emoji, "๐Ÿ’ฅ".

interface CommitContext extends SemanticReleaseCommitObj {
  message: string
  subject: string
  owner: string
  repo: string
  source: string
  gitmoji: string
  issues: Array<IssueLink>
  wip: Array<CommitContext>
}

IssueLink

interface IssueLink {
  text: string
  link: string
}

Progressive commits

Assume you file an issue (e.g. #1) to implement a new feature, then you make 3 commits as belows (the toppest is the latest).

  • โœจ Add a new feature.\n\n#1
  • ๐Ÿšง Implement part B.\n\n#1
  • ๐Ÿšง Implement part A.\n\n#1

The โœจ commit will be the final commit composed of two ๐Ÿšง commits. They are linked together via #1 in the commit message.

Therefore the commits of the template context will be as follows.

{
  "commits": {

    "sparkles": [
      {
        "message": "Add a new feature.\n\n#1",
        "subject": "Add a new feature.",
        "body": "#1",
        "gitmoji": "โœจ",
        "// repo": "",
        "// owner": "",
        "source": "github.com",
        "issues": [{
          "text": "#1",
          "// link": ""
        }],

        "wip": [
          {
            "message": "Implement part B.\n\n#1",
            "subject": "Implement part B.",
            "body": "#1",
            "gitmoji": "๐Ÿšง",
            "// repo": "",
            "// owner": "",
            "source": "github.com",
            "issues": [{
              "text": "#1",
              "// link": ""
            }]
          },
          {
            "message": "Implement part A.\n\n#1",
            "subject": "Implement part A.",
            "body": "#1",
            "gitmoji": "๐Ÿšง",
            "// repo": "",
            "// owner": "",
            "source": "github.com",
            "issues": [{
              "text": "#1",
              "// link": ""
            }]
          }
        ]
      }
    ],

    "// other gitmojis": ""
  }
}

Commit Syntax

Beside using issue number to link commits, the following syntax is also available to link commits together.

wip#{target_name}

While target_name is an identifier for those progressive commits, for example, wip#feature-A.

  • target_name can contain numbers, letters (both cases), _ or -.
  • target_name should not start with _ or -.

Contribution

PRs are welcome.

Before sending PRs, please follow the steps below.

  • Fork the branch dev.
  • Make commits.
  • Run npm run lint and ensure you pass the linter.
  • Run npm test and ensure nothing broken.
    • If you introduce new features in the PR, ensure tests have been written for each feature.
  • Send your PR to branch dev and wait for reviews.

Thanks for all lovers and contributers of this project!

semantic-release-gitmoji's People

Contributors

aaditmshah avatar beaussan avatar bryanjtc avatar dependabot[bot] avatar inazuma-bot avatar momocow avatar rdeville avatar semantic-release-bot avatar ssalka avatar xylocone avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

semantic-release-gitmoji's Issues

overwriting config for custom templates does seem to work

With the following config:

const fs = require('fs')
const path = require('path')
const { promisify } = require('util')
const readFileAsync = promisify(fs.readFile)

const TEMPLATE_DIR = path.join(__dirname, 'config')

module.exports = {
  plugins: [
    'semantic-release-gitmoji',
    {
      releaseNotes: {
        template: readFileAsync(
          path.join(TEMPLATE_DIR, 'my-default-template.hbs')
        ),
        partials: {
          commitTemplate: readFileAsync(
            path.join(TEMPLATE_DIR, 'my-commit-template.hbs')
          )
        }
      }
    },
    '@semantic-release/changelog'
  ]
}

The plugin still uses the default .hbs templates from the node_modules folder.

I could provide a test repo if it's helpful. Let me know :)

[HELP] doesnt work

My Repo
I set up the release.config.js, but it just says:

[9:10:21 AM] [semantic-release] [@semantic-release/commit-analyzer] โ€บ โ„น  Analyzing commit: โœจ Gitmoji Semantic Release
[9:10:21 AM] [semantic-release] [@semantic-release/commit-analyzer] โ€บ โ„น  The commit should not trigger a release

Even though it is a feature so it should trigger a release. What did I do wrong or do I have to setup the Template and stuff by myself?

Question: Can the tool also generate the changelog.md?

Not sure if the tool can generate a changelog just like the semantic-release tool does with the changelog plugin

At the end of the day the content it writes into the changelog is the same that goes into the release notes, if it is possible I appreciate any example config.

I am a little bit new into this kind of configurations/automatization, I imagine that also in case it is not possible to generate it just with this tool, it could be possible to use the changelog plugin in the same pipeline running your semantic-release-gitmoji tool, but I wonder how to tell the changelog plugin to identify the emojis also as features or bugfixes or breaking changes, etc. Because I think that it only works with conventional commits and not sure if you can modify that behaviour or template

๐Ÿ› reusing ReleaseNotes._instance breaks monorepo package-specific commits

Hi @momocow

I love this plugin and using emojis instead of angular commit msgs, so thank you!

I'm seeing a bug when using a monorepo where ReleaseNotes' knowledge of commits persists when semantic-release is iterating across packages in a monorepo. Whichever package is first, the commits related to that package are the only commits listed for all subsequent packages.

Example repo: https://github.com/scottnath/experiments

Monorepo plugin: https://github.com/qiwi/multi-semantic-release

The fix I found

The ReleaseNotes class .get reuses the ._instance instead of using the current set of commits it should be receiving. I was able to make the monorepo packages have separate release notes by having .get freshly instantiate the class each time:

see the change: scottnath/semantic-release-gitmoji@main...release-notes-class

  static get (context, releaseNotesOptions) {
    ReleaseNotes._instance = new ReleaseNotes(context, releaseNotesOptions)
    return ReleaseNotes._instance
  }

I don't know if this is a valid fix because I'm not sure what use case(s) exist for not using the class with new, but figured it would be a good place to start to find a final fix.

Using current semantic-release-gitmoji

The dependencies:

  "dependencies": {
    "@qiwi/multi-semantic-release": "^7.0.0",
    "semantic-release": "^21.1.1",
    "semantic-release-gitmoji": "v1.6.4"
  }

example PR: scottnath/experiments#1
Release output in GitHub Actions: https://github.com/scottnath/experiments/actions/runs/6100581263/job/16555183681

Release Notes for package scottnath-experiment-a

# v0.1.0-add-release.1 (https://github.com/scottnath/experiments/compare/scottnath-experiments-a@0.0.2-add-release.1...scottnath-experiments-a@0.1.0-add-release.1) (2023-09-06)

## โœจ New Features

    * 67f2e78 (https://github.com/scottnath/experiments/commit/67f2e78) โœจ another change in A

## ๐Ÿ› Fixes

    * fd83f3d (https://github.com/scottnath/experiments/commit/fd83f3d) ๐Ÿ†• change to A

Release notes for package scottnath-experiment-b

# v0.1.0-add-release.1 (https://github.com/scottnath/experiments/compare/scottnath-experiments-b@0.0.2-add-release.1...scottnath-experiments-b@0.1.0-add-release.1) (2023-09-06)

## โœจ New Features

    * 67f2e78 (https://github.com/scottnath/experiments/commit/67f2e78) โœจ another change in A

## ๐Ÿ› Fixes

    * fd[83](https://github.com/scottnath/experiments/actions/runs/6100581263/job/16555183681#step:6:84)f3d (https://github.com/scottnath/experiments/commit/fd83f3d) ๐Ÿ†• change to A

### Dependencies

    * scottnath-experiments-a: upgraded to 0.1.0-add-release.1

Using the adjusted package at scottnath/semantic-release-gitmoji

scottnath/semantic-release-gitmoji@main...release-notes-class

The dependencies:

  "dependencies": {
    "@qiwi/multi-semantic-release": "^7.0.0",
    "semantic-release": "^21.1.1",
    "semantic-release-gitmoji": "github:scottnath/semantic-release-gitmoji#release-notes-class"
  }

example PR: scottnath/experiments#2
Release output in GitHub Actions: https://github.com/scottnath/experiments/actions/runs/6100581263/job/16555183681

Release Notes for package scottnath-experiment-a

# v0.1.0-add-release-experiment.1 (https://github.com/scottnath/experiments/compare/[email protected]@0.1.0-add-release-experiment.1) (2023-09-06)

## โœจ New Features

    * 67f2e78 (https://github.com/scottnath/experiments/commit/67f2e78) โœจ another change in A

## ๐Ÿ› Fixes

    * a3349cb (https://github.com/scottnath/experiments/commit/a3349cb) ๐Ÿ› add basic files to packages 
    * 2c1d02a (https://github.com/scottnath/experiments/commit/2c1d02a) ๐Ÿ› changes to b 
    * af83eca (https://github.com/scottnath/experiments/commit/af83eca) ๐Ÿ› only in a 
    * bfbfadb (https://github.com/scottnath/experiments/commit/bfbfadb) ๐Ÿ› change in A 
    * 9ef89fc (https://github.com/scottnath/experiments/commit/9ef89fc) ๐Ÿš€ set up one pkg fully 
    * 4eb481b (https://github.com/scottnath/experiments/commit/4eb481b) ๐ŸŽจ changes to A only 
    * fd83f3d (https://github.com/scottnath/experiments/commit/fd83f3d) ๐Ÿ†• change to A

Release notes for package scottnath-experiment-b

# v0.0.2-add-release-experiment.1 (https://github.com/scottnath/experiments/compare/[email protected]@0.0.2-add-release-experiment.1) (2023-09-06)

## ๐Ÿ› Fixes

    * a3349cb (https://github.com/scottnath/experiments/commit/a3349cb) ๐Ÿ› add basic files to packages 
    * 2c1d02a (https://github.com/scottnath/experiments/commit/2c1d02a) ๐Ÿ› changes to b 
    * 56cf3f9 (https://github.com/scottnath/experiments/commit/56cf3f9) ๐Ÿ› change to B 
    * b6ea03a (https://github.com/scottnath/experiments/commit/b6ea03a) ๐Ÿ› change in B 
    * 9ef[89](https://github.com/scottnath/experiments/actions/runs/6101134859/job/16556837347#step:6:90)fc (https://github.com/scottnath/experiments/commit/9ef89fc) ๐Ÿš€ set up one pkg fully 
    * 2673e5c (https://github.com/scottnath/experiments/commit/2673e5c) ๐Ÿš€ fixing tagformat in b 
    * ecc71ca (https://github.com/scottnath/experiments/commit/ecc71ca) ๐ŸŽจ changes to B only

### Dependencies

    * scottnath-experiments-a: upgraded to 0.1.0-add-release-experiment.1

thank you for any help!

default to patch releases for messages which do not contain a specific emoji, or any unlisted emoji

We want to rollout gitmojis for the dev teams but we have the requirement to always create a patch version no matter what.
The reason for that is, that server-side pre commit hooks are cumbersome to setup for >100 projects and relying on pre commit hooks on the client side is not reliable.

Therefore, to not bother with it too much, we would like to setup a default patch version for every commit. Similar discussions happened in the commit analyzer project .

Only default emojis shown on release notes

If I want to set a different set of emojis and use the default template it "works".. As in it generates the desired version, but the release notes are not generated as intended.

In our case we set several emojis as patch but only the :bug: is shown in the generated release notes.

Taking a quick look at the code, it seems it does not pass the releaseRules config when generating notes.

example config: .releaserc

{
  "branches": [
    "main"
  ],
  "plugins": [
    [
      "semantic-release-gitmoji",
      {
        "releaseRules": {
          "major": [
            "๐Ÿ’ฅ",
            ":boom:"
          ],
          "minor": [
            "โœจ",
            ":sparkles:"
          ],
          "patch": [
            "๐ŸŽจ",
            ":art:",
            "โšก๏ธ",
            ":zap:",
            "๐Ÿ”ฅ",
            ":fire:",
            "๐Ÿ›",
            ":bug:",
            "๐Ÿš‘๏ธ",
            ":ambulance:",
            "๐Ÿ“",
            ":memo:",
            "๐Ÿš€",
            ":rocket:",
            "๐Ÿ’„",
            ":lipstick:",
            "๐ŸŽ‰",
            ":tada:",
            "โœ…",
            ":white_check_mark:",
            "๐Ÿ”’๏ธ",
            ":lock:",
            "๐Ÿ”",
            ":closed_lock_with_key:",
            "๐Ÿ”–",
            ":bookmark:",
            "๐Ÿšจ",
            ":rotating_light:",
            "๐Ÿšง",
            ":construction:",
            "๐Ÿ’š",
            ":green_heart:",
            "โฌ‡๏ธ",
            ":arrow_down:",
            "โฌ†๏ธ",
            ":arrow_up:",
            "๐Ÿ“Œ",
            ":pushpin:",
            "๐Ÿ‘ท",
            ":construction_worker:",
            "๐Ÿ“ˆ",
            ":chart_with_upwards_trend:",
            "โ™ป๏ธ",
            ":recycle:",
            "โž•",
            ":heavy_plus_sign:",
            "โž–",
            ":heavy_minus_sign:",
            "๐Ÿ”ง",
            ":wrench:",
            "๐Ÿ”จ",
            ":hammer:",
            "๐ŸŒ",
            ":globe_with_meridians:",
            "โœ๏ธ",
            ":pencil2:",
            "๐Ÿ’ฉ",
            ":poop:",
            "โช๏ธ",
            ":rewind:",
            "๐Ÿ”€",
            ":twisted_rightwards_arrows:",
            "๐Ÿ“ฆ๏ธ",
            ":package:",
            "๐Ÿ‘ฝ๏ธ",
            ":alien:",
            "๐Ÿšš",
            ":truck:",
            "๐Ÿ“„",
            ":page_facing_up:",
            "๐Ÿฑ",
            ":bento:",
            "โ™ฟ๏ธ",
            ":wheelchair:",
            "๐Ÿ’ก",
            ":bulb:",
            "๐Ÿป",
            ":beers:",
            "๐Ÿ’ฌ",
            ":speech_balloon:",
            "๐Ÿ—ƒ๏ธ",
            ":card_file_box:",
            "๐Ÿ”Š",
            ":loud_sound:",
            "๐Ÿ”‡",
            ":mute:",
            "๐Ÿ‘ฅ",
            ":busts_in_silhouette:",
            "๐Ÿšธ",
            ":children_crossing:",
            "๐Ÿ—๏ธ",
            ":building_construction:",
            "๐Ÿ“ฑ",
            ":iphone:",
            "๐Ÿคก",
            ":clown_face:",
            "๐Ÿฅš",
            ":egg:",
            "๐Ÿ™ˆ",
            ":see_no_evil:",
            "๐Ÿ“ธ",
            ":camera_flash:",
            "โš—๏ธ",
            ":alembic:",
            "๐Ÿ”๏ธ",
            ":mag:",
            "๐Ÿท๏ธ",
            ":label:",
            "๐ŸŒฑ",
            ":seedling:",
            "๐Ÿšฉ",
            ":triangular_flag_on_post:",
            "๐Ÿฅ…",
            ":goal_net:",
            "๐Ÿ’ซ",
            ":dizzy:",
            "๐Ÿ—‘๏ธ",
            ":wastebasket:",
            "๐Ÿ›‚",
            ":passport_control:",
            "๐Ÿฉน",
            ":adhesive_bandage:",
            "๐Ÿง",
            ":monocle_face:",
            "โšฐ๏ธ",
            ":coffin:",
            "๐Ÿงช",
            ":test_tube:",
            "๐Ÿ‘”",
            ":necktie:",
            "๐Ÿฉบ",
            ":stethoscope:",
            "๐Ÿงฑ",
            ":bricks:",
            "๐Ÿง‘โ€๐Ÿ’ป",
            ":technologist:",
            "๐Ÿ’ธ",
            ":money_with_wings:",
            "๐Ÿงต",
            ":thread:"
          ]
        }
      }
    ]
  ]
}

The analyzeCommits plugin must return a valid semver release type. The valid values are: patch, minor, major.

EANALYZECOMMITSOUTPUT The analyzeCommits plugin returned an invalid value. It must return a valid semver release type.
The analyzeCommits plugin must return a valid semver release type. The valid values are: patch, minor, major.

The analyzeCommits function of the semantic-release-gitmoji returned prerelease instead.

We recommend to report the issue to the semantic-release-gitmoji authors, providing the following informations:

* The semantic-release version: 22.0.12
* The semantic-release logs from your CI job
* The value returned by the plugin: prerelease
* A link to the semantic-release plugin developer guide: https://github.com/semantic-release/semantic-release/blob/master/docs/developer-guide/plugin.md

Help: how to include a "Other changes" section in the hbs template

I am trying to modify the template to be able to identify any emoji that is not part of the defined sections, to be put in this "Other changes" section:

{{#if compareUrl}}
    # [v{{nextRelease.version}}]({{compareUrl}}) ({{datetime "UTC:yyyy-mm-dd"}})
{{else}}
    # v{{nextRelease.version}} ({{datetime "UTC:yyyy-mm-dd"}})
{{/if}}

{{#with commits}}
    {{#if sparkles}}
        ## โœจ New Features
        {{#each sparkles}}
            - {{> commitTemplate}}
        {{/each}}
    {{/if}}

    {{#if bug}}
        ## ๐Ÿ› Bug Fixes
        {{#each bug}}
            - {{> commitTemplate}}
        {{/each}}
    {{/if}}

    {{#if ambulance}}
        ## ๐Ÿš‘ Critical Hotfixes
        {{#each ambulance}}
            - {{> commitTemplate}}
        {{/each}}
    {{/if}}

    {{#if lock}}
        ## ๐Ÿ”’ Security Issues
        {{#each lock}}
            - {{> commitTemplate}}
        {{/each}}
    {{/if}}

    {{#if boom}}
        ## ๐Ÿ’ฅ Breaking Changes
        {{#each boom}}
            - {{> commitTemplate}}
        {{/each}}
    {{/if}}

    {{#unless (or (eq this 'boom') (eq this 'lock') (eq this 'sparkles') (eq this 'bug') (eq this 'ambulance'))}}
        ## Other Changes
    {{/unless}}

{{/with}}

But when I run the workflow I get the following error (I am a little new to hbs so this "Other section" I made was with help of an AI, hopefully someone can help me correct it and add the desired section properly):

Error: Missing helper: "eq"

Context attribute "compareUrl" is not working with bitbucket repository

@momocow I was using the tool with github, but now I am trying to setup everything on bitbucket too, I notice that this on my default handlebars template (which is the same from the example but with the emojis):

{{#if compareUrl}}
# ๐ŸŽ‰ [v{{nextRelease.version}}]({{compareUrl}}) ({{datetime "UTC:yyyy-mm-dd"}}) ๐Ÿ”–
{{else}}
# ๐ŸŽ‰ v{{nextRelease.version}} ({{datetime "UTC:yyyy-mm-dd"}}) ๐Ÿ”–
{{/if}}

works with github repository, but with bitbucket it is always entering the else, is there anyway to make it work with bitbucket too?

When I was using release-notes generator plugin I also had to do some tweaks for it to work with bitbucket like so:

[
      "@semantic-release/release-notes-generator",
      {
        "preset": "conventionalcommits",
        "presetConfig": {
          "commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commits/{{hash}}",
          "compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}..{{currentTag}}",
          "types": [
            {
              "type": "feat",
              "section": "New Feature(s) ๐Ÿš€"
            },
            {
              "type": "fix",
              "section": "Bug Fix(es) ๐Ÿ›๏ธ"
            }
          ]
        }
      }
    ]

Please let me know if I can do something like this to get the compare url working, the commit url was easy to fix on the commit template but the compare url not sure how to fix.

EDIT: I was reading again this https://github.com/momocow/semantic-release-gitmoji?tab=readme-ov-file#releasenotesoptions

you mention that github is currently the only repo supported but you also mention that it is possible to override the baseUrl and other values, can you please show example how to override them? Maybe this way it can work with bitbucket too

How to make the tag that is generated to not have the "v" for example v8.0.7 tag should be just 8.0.7

Hey @momocow hope you are doing well, could you please help me to configure the tool to make the tags be without the v prefix? The nextRelease.version environment variable that is calculated is good, if the next version is 8.0.7, then it remains like that on my project version which is in the pom.xml file, that is okay, but the tag that is released in bitbucket/github, it has the v prefix, so 8.0.7 is tag v8.0.7, is there a way to make the tag be just the number too?

Here is my releaserc.js config, I tried to add tagFormat property to it (as a suggestion from an AI) but with no success, im probably adding it the wrong way:

// load variables from .env file and shell of the process
require('dotenv').config();
const Handlebars = require('handlebars');
const path = require('path');
const { promisify } = require('util');
const dateFormat = require('dateformat');
const readFileAsync = promisify(require('fs').readFile);
// the *.hbs template and partials should be passed as strings of contents
const template = readFileAsync(path.join(__dirname, '/templates/default-template.hbs'));
const commitTemplate = readFileAsync(path.join(__dirname, '/templates/commit-template.hbs'));
tagFormat: "${version}";
module.exports = {
   branches: [
      "main",
      {
         name: 'beta',
         prerelease: true
      }
   ],
   plugins: [
      [
         'semantic-release-gitmoji', {
            releaseRules: {
               major: [':boom:'],
               minor: [':sparkles:'],
               patch: [
                  ':bug:',
                  ':ambulance:'
               ]
            },
            releaseNotes: {
               template,
               partials: {
                  commitTemplate
               },
               helpers: {
                  formatDate: function(date) {
                    return dateFormat(date, 'yyyy-mm-dd HH:MM:ss');
                  }
               }
            }
         }
      ],
      [
         "@semantic-release/exec",
         {
            "prepareCmd": "mvn versions:set -DnewVersion=\"${nextRelease.version}\" && mvn clean install"
         }
      ],
      [
         "@semantic-release/changelog",
         {
            "changelogFile": "docs/CHANGELOG.md",
            "changelogTitle": ['# Gitmoji Changelog', '\uD83C\uDF88'].join(' ')
         }
      ],
      [
         '@semantic-release/git',
         {
            assets: [
               "**/pom.xml",
               "docs/CHANGELOG.md"
            ],
            message: [
               ':bookmark: v${nextRelease.version} [skip ci]',
               '',
               '${nextRelease.notes}'
            ].join('\n')
         }
      ]
   ]
};

๐Ÿšง Implement WIP tracking

Gitmoji "๐Ÿšง" represents "work in progress" commit, which indicates that a new feature may be composed of several ๐Ÿšง commits and a final commit such as โœจ or ๐Ÿ› .

Those ๐Ÿšง commits and a final commit in a series can be considered as a task for a specific purpose.
Therefore, we can place a task identifier (e.g. wip#1, wip#new-feature) in the footer of a commit message to recognize which task a commit belongs to.

Finally, in the release notes, we can show the final commit as a main entry, and list the ๐Ÿšง commits of the same task following the main entry to fully describe how this feature or bug fix is made.


Definitions

wip#<unique_name>

<unique_name> should be:

  • an issue number.
  • a string of unique name, which contains only alphabets, numeric, hyphens and underlines.

Behaviors

  • If <unique_name> is a number, the task identifier can be resolved to an issue link.
  • If a ๐Ÿšง commit contains only one related issue w/o wip#<unique_name>, the issue is treated as the task identifier, i.e. wip#<issue_no>.

Question: How to "compare" the gitmoji or emoji value in a Helper function

Hi @momocow, this question is related to my attempt to do this "Other section" #87 while you implemente an enhacement, I was thinking of a workaround meanwhile, that if we could compare what is the value of the emoji maybe we could do some logic, but I do not know how to compare the value of the emoji, let me elaborate:

When you have the following in the default hbar template:

# ๐ŸŽ‰ [v{{nextRelease.version}}](https://{{source}}/{{owner}}/{{repo}}/compare/v{{lastRelease.version}}..v{{nextRelease.version}}) ({{datetime "UTC:yyyy-mm-dd"}}) ๐Ÿ”–

{{#with commits}}
{{#if sparkles}}
## โœจ New Features
{{#each sparkles}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if bug}}
## ๐Ÿ› Bug Fixes
{{#each bug}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{checkIfItsNotABug <what_would_go_in_here?>}}
## Other changes that are not a bug emoji

{{/with}}

I was imagining that maybe with a Helper function that could check what is the "value" of the emoji we could do some logic like so:

               helpers: {
                  checkIfItsNotABug: function(emoji) {
                    if(emoji === ':bug:'){
                   // it is a bug emoji
                   return false;
                    }
                    // not a bug emoji
                    return true;
                  }
               }

but it does not work ofcourse, I was wondering how could you check the value of the emoji? I tried different ways, but I guess it will not work checking the equality against a String, because the emoji is an object that I believe is one of this objects from node-emoji? So based on that I think that maybe we could do some logic, but first I would like to confirm is it is possible to do what im trying to explain, which would be to create a helper function that can tell if it is a bug emoji or sparkles or any type. How could you do it from the helper? Also notice in the template <what_would_go_in_here?> not sure what should I pass there to get the object, should it be this or how could it be done?

Hopefully you understood what I am trying to do, thank you

How does the tool handles or behaves with reverts?

Hi @momocow hope you are doing well, I did a test recently where I reverted a already merged pull request that generated a new tag, and I ran the semantic-release but it didnt do anything (no new tag or anything), I believe this is okay I guess, but I also think that it is possible that you can configure at the release rules an emoji you want to use for revert commit message, so that when running the semantic-release after the revert you get a new tag right, but im not sure, what do you think is the correct behaviour??

Update:

Wanted to explain a little further, in bitbucket you can revert already Merged pull requests, and this allows you to set a commit message for the revert. So if you wanted the tool to do something it would be enough to configure a rule for the emoji you are going to use in that commit message, for example it could be the emoji โฌ‡๏ธ for a patch, and you use this for any revert.

Help: how to get the description of each commit

I was trying to get the description of each commit but so far it has been not possible, I tried to check the docs here https://github.com/momocow/semantic-release-gitmoji?tab=readme-ov-file#commitcontext but the link to check the context inherited is broken, appreciate any help to print the description, here is my commit-template.hbs:

[`{{commit.short}}`](https://github.com/{{owner}}/{{repo}}/commit/{{commit.short}}) {{subject}} - desc: {{description}} {{this.description}} {{commit.description}} {{lookup this 'description'}} - author: {{this.author.name}} {{#if issues}}(Issues:{{#each issues}} [`{{text}}`]({{link}}){{/each}}){{/if}}

option deactivate github requirement

I was trying to use the plugin to replace commit-analyser and found that it pulls github dependencies:

[semantic-release] โ€บ โœ” Loaded plugin "verifyConditions" from "@semantic-release/github"
[semantic-release] โ€บ โœ” Loaded plugin "publish" from "@semantic-release/github"
[semantic-release] โ€บ โœ” Loaded plugin "addChannel" from "@semantic-release/github"
[semantic-release] โ€บ โœ” Loaded plugin "success" from "@semantic-release/github"
[semantic-release] โ€บ โœ” Loaded plugin "fail" from "@semantic-release/github"

The problem here is: we dont use github but rather gitlab. Therefore, the question: Are these dependencies required for the plugin to work at all? If not, is there a way to disable the dependency which allows us to make use of this plugin?

Question/help for understanding where the commit attributes come from to use on the handlebars templates

Hey @momocow thanks for your help recently, I have been trying to understand a lot of the "how it works" of all the ecosystem but it is a lot, just understanding handlerbars "logicless" syntax has been a challenge, there is something that is what is the most hard thing to understand so far and it is the "context" where do this commits and its attributes come from (ofcourse git but let me explain further)? Can not find were is that defined, I was using before your tool, this other tool with the semantic-release/commit-analyzer and also semantic-release/release-notes-generator, then I used a "preset" for the conventional-changelog called "conventional-changelog-conventionalcommits", and this preset also has some "options" or "configuration that you can do" specified here

my confussion comes when you see they have all those "substitutions" or "attributes" that they can use like for example {{commit.scope}}
in this file for example: https://github.com/conventional-changelog/conventional-changelog/blob/7ac186060b16ea66847c401d57ca78157329d778/packages/conventional-changelog-conventionalcommits/templates/template.hbs#L9

but then when I try to use that attribute {{commit.scope}} in the commit-template that we use here at semantic-release-gitmoji, it is not available, that is were I wonder why and how they have that attribute available? What is the config I am missing to be able to have those attributes, if you could clarify were is that config setup and if it is possible to configure that in the context I would really appreciate, that has been the most struggling point for me to understand what can I configure and what I cannot (ofcourse, it is not here in gitmoji because it is not configured to be in the context, but would it be possible to have it? If so how? And were in that project that it is available it was configured to be available?).

I tried using it here in the template like so (but I think it is not available):

{{#if commit.scope}}
    - Scope: {{commit.scope}}
{{/if}}

{{#if scope}}
    - Scope: {{scope}}
{{/if}}

{{#if this.scope}}
    - Scope: {{this.scope}}
{{/if}}

but that is what I want to understand why is it available over here: https://github.com/conventional-changelog/conventional-changelog/blob/7ac186060b16ea66847c401d57ca78157329d778/packages/conventional-changelog-conventionalcommits/templates/template.hbs#L9 were did they configure it to be in the "context"?

Not compatible with handlebars 4.7.0+

Hi,

first of, I love your project, it's awesome.

I had to install it to a new project yesterday, and it didn't generate template with the emojis.

For example, here is what was generated :

# v2.0.5 (2020-02-06)

And, that's it. I looked into the logs and found this :

Handlebars: Access has been denied to resolve the property "ambulance" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

With a downgrade of handlebars in my lockfile, it worked again.

Can you please upgrade the dependancy level and add the corrects flags in order for this to work again on new projects ? :)

Thanks again for your amazing tool =D

Generate tags with -SNAPSHOT on it from the Develop branch (when running semantic-release-gitmoji)

Hi @momocow hope you are doing well, I got a question again on how to do something that im not sure if the tool is able to do, it is easier to explain with the use case/example:

Imagine I have a feature branch and then I merge it to Develop branch, so I trigger semantic-release-gitmoji on Develop branch and when the tag is generated I want it to have this format x.y.z-SNAPSHOT, for example suppose the Merged feature generates the tag 18.0.1-SNAPSHOT, then when im done testing I merge Develop into Main and run semantic-release-gitmoji and get the tag 18.0.1

I do not think that is possible, I was thinking that maybe if you configure the Develop branch as a prerelease branch at the .releaserc.js and have a tagFormat like ${version}-SNAPSHOT (I do not think this will work as expected? it will probably do 18.0.1-SNAPSHOT-Develop.1 instead of the expected 18.0.1-SNAPSHOT), but then you would also need to use 2 different .releaserc.js files, so that the tagFormat of the semantic-release-gitmoji that is run on the Main branch is x.y.z (so this 2nd or 1st however you prefer .releaserc.js has that tagFormat), but again I think this is not gonna work as expected right, I will test this but I have no hope that it will work as expected, anyways if you know how to make it work like im describing here I appreciate any help :)

Note: I know prerelease branches work generating tags with the format x.y.z-branchname.n like 18.0.1-Develop.1, but wanna know if it is also possible to do it like I described.

[BUG] Crash if commit starts with '*'

Hi,

I tried to use semantic-release-gitmoji today and had this exception:
An error occurred while running semantic-release: SyntaxError: Invalid regular expression: /^*/: Nothing to repeat
After searching a bit, I found that this commit was the source of the exception:
*Merge branch 'main' of ssh://GIT_URL into main
The problem seems to be due to the emojiRegex. The regex returns "*" which lead to a bad regex for this line:
subject = subject.replace(new RegExp('^' + gitmoji), '')

Global workflow:
const matched = emojiRegex().exec(subject) subject = *Merge branch 'main' of ssh://GIT_URL into main
if (!matched || matched.index !== 0) return null
const gitmoji = matched[0] gitmoji = *
const semver = gitmojis.find(matchEmoji(gitmoji))?.semver || 'other'
subject = subject.replace(new RegExp('^' + gitmoji), '')

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.