Logo

dev-resources.site

for different kinds of informations.

Part 3 : Initialize and configure semantic release with releaserc

Published at
11/28/2024
Categories
semanticrelease
semanticreleaseado
pipeline
cicd
Author
shashank-mishra-dev
Author
19 person written this
shashank-mishra-dev
open
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! 🚀

pipeline Article's
30 articles in total
Favicon
Using TeeChart in Vector Magnetics’ RivCross Software for Precise Directional Drilling
Favicon
Pipeline Analytics: Unlocking the Power of Data to Enhance Software Development
Favicon
MongoDB Aggregation Pipeline
Favicon
The Importance of CI/CD in Modern Software Development
Favicon
Continuous Feedback? That’s right! And we’re not talking about people management!
Favicon
Setting Up CodeArtifact from the CLI
Favicon
Navigating Kubernetes CI/CD Best Practices for Effortless Deployment
Favicon
Why Your .NET Application Works in an IDE but Fails in CI/CD or Terminal: Understanding Asynchronous Execution
Favicon
Part 3 : Initialize and configure semantic release with releaserc
Favicon
Setting up a Self-Hosted Runner on GitHub Actions
Favicon
AWS CodePipeline V2 type pipelines supports to automatically retry a stage if there is a failure in the stage.
Favicon
Como o CI/CD pode transformar o ciclo de vida de desenvolvimento
Favicon
How to Build and Configure a Release Pipeline in Azure DevOps
Favicon
How to Run PowerShell Script in Jenkins Pipeline
Favicon
Understanding CI/CD in Azure DevOps: A Comprehensive Guide
Favicon
How to Integrate Automated Tests in Azure DevOps Pipeline
Favicon
Implementing Continuous Testing in a CI/CD Pipeline: A Comprehensive Guide
Favicon
🤖 End to end LLMOps Pipeline-Part 6-Kubernetes 🤖
Favicon
Steps to industry-leading query speed: evolution of the Apache Doris execution engine
Favicon
Running pyspark jobs on Google Cloud Dataproc
Favicon
What is Aggregation pipeline? how to write it? Learn with example
Favicon
How I contributed my first data pipeline to the open source.
Favicon
On Orchestrators: You Are All Right, But You Are All Wrong Too
Favicon
Query
Favicon
How Can I Create a DevOps Pipeline That Automatically Resolves All Conflicts and Bugs Without Human Intervention?
Favicon
GitLab CI/CD Pipelines: Best Practices for Monorepos
Favicon
5 Simple Steps to Get Your Test Suite Running in Heroku CI
Favicon
Simplifying SDMX Data Integration with Python
Favicon
Sending GitHub Secrets to Docker Apps on VMs Using adnanh/webhooks
Favicon
Melhorando Pipelines no Bitbucket: Cache, Reutilização de Steps e Execução Paralela

Featured ones: