DEV Community

Shashank Mishra
Shashank Mishra

Posted on

2 1 1 1 1

Part 3 : Initialize and configure semantic release with releaserc

In this part, I’ll walk you through initializing and configuring semantic release using .releaserc configuration file. This will help in analyzing your Git commit history and following the Conventional Commits specification, it determines the next semantic version (major, minor, or patch) for your project. It also generates release notes, publishes the package, and creates Git tags automatically.

By the end of this guide, you’ll have a fully functioning semantic release workflow that will also create a variable in your azure pipeline for holding the value next release version based on commit message history.

Step 1: Install semantic-release and required Plugins

1.a Install semantic-release and semantic-release plugins as a dev dependency:
npm install --save-dev semantic-release

npm install --save-dev @semantic-release/changelog @semantic-release/git @semantic-release/release-notes-generator @semantic-release/github semantic-release-ado

1.b Create a .releaserc file in your project’s root directory
Here’s an example configuration:

{
  "branches": [
    {
      "name": "main",
      "prerelease": false
    }
  ],
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "conventionalcommits"
      }
    ],
    [
      "@semantic-release/release-notes-generator",
      {
        "preset": "conventionalcommits"
      }
    ],
    [
      "@semantic-release/changelog",
      {
        "changelogFile": "docs/CHANGELOG.md"
      }
    ],
    [
      "@semantic-release/git",
      {
        "assets": [
          "dist/**/*.{js,css}",
          "docs",
          "package.json"
        ],
        "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ],
    "@semantic-release/github",
    "semantic-release-ado"
  ]
}

Enter fullscreen mode Exit fullscreen mode

1.c Add Semantic Release Script
Add a script to your package.json:
"release:semantic-release": "npx semantic-release"

Summary of Plugin Functions

  • @semantic-release/commit-analyzer: Analyzes commit messages to determine the next version (major, minor, patch).
  • @semantic-release/release-notes-generator: Generates release notes based on commits.
  • @semantic-release/changelog: Updates the CHANGELOG.md file.
  • @semantic-release/github: Creates a GitHub release with changelogs and assets.
  • @semantic-release/git: Commits updated files (like CHANGELOG.md and package.json).
  • @semantic-release-ado: Generates version number that will be stored on a variable available to downstream steps on the job. By default this variable is named nextRelease, but the name can be configured in the plugin options. Read more

Conclusion

By following these steps, you’ve successfully configured sementic release in order to determine the next semantic version (major, minor, or patch) for your project. It also generates release notes, publishes the package, and creates Git tags automatically.

Stay tuned for more guides to help you optimize your pipelines and development practices. Happy coding! 🚀

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay