Close Menu
Soshace Digital Blog

    Subscribe to Updates

    Get The Latest News, Updates, And Amazing Offers

    What's Hot
    JavaScript

    How to Run API Tests Automatically Every Time Your App Is Deployed using Loadmill

    Wiki

    Заметка про распорядок дня

    Git

    Git – Recommendations for “Soshace” Team

    Important Pages:
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Today's Picks:
    • Scaling Success: Monitoring Indexation of Programmatic SEO Content
    • Leveraging Influencers: Key Drivers in New Product Launches
    • How Privacy-First Marketing Will Transform the Industry Landscape
    • The Impact of Social Proof on Thought Leadership Marketing
    • Balancing Value-Driven Content and Promotional Messaging Strategies
    • Top Influencer Marketing Platforms to Explore in 2025
    • Emerging Trends in Marketing Automation and AI Tools for 2023
    • Strategies to Mitigate Duplicate Content in Programmatic SEO
    Saturday, September 6
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Soshace Digital Blog
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Services
    • SaaS & Tech

      Maximizing Efficiency: How SaaS Lowers IT Infrastructure Costs

      August 27, 2025

      Navigating Tomorrow: Innovations Shaping the Future of SaaS

      August 27, 2025

      Maximizing Impact: Strategies for SaaS & Technology Marketing

      August 27, 2025
    • AI & Automation

      Enhancing Customer Feedback Analysis Through AI Innovations

      August 27, 2025

      Navigating the Impact of AI on SEO and Search Rankings

      August 27, 2025

      5 Automation Hacks Every Home Service Business Needs to Know

      May 3, 2025
    • Finance & Fintech

      Critical Missteps in Finance Marketing: What to Avoid

      August 27, 2025

      Analyzing Future Fintech Marketing Trends: Insights Ahead

      August 27, 2025

      Navigating the Complex Landscape of Finance and Fintech Marketing

      August 27, 2025
    • Legal & Compliance

      Exploring Thought Leadership’s Impact on Legal Marketing

      August 27, 2025

      Maximizing LinkedIn: Strategies for Legal and Compliance Marketing

      August 27, 2025

      Why Transparency Matters in Legal Advertising Practices

      August 27, 2025
    • Medical Marketing

      Enhancing Online Reputation Management in Hospitals: A Guide

      August 27, 2025

      Analyzing Emerging Trends in Health and Medical Marketing

      August 27, 2025

      Exploring Innovative Content Ideas for Wellness Blogs and Clinics

      August 27, 2025
    • E-commerce & Retail

      Strategic Seasonal Campaign Concepts for Online and Retail Markets

      August 27, 2025

      Emerging Trends in E-commerce and Retail Marketing Strategies

      August 27, 2025

      Maximizing Revenue: The Advantages of Affiliate Marketing for E-Commerce

      August 27, 2025
    • Influencer & Community

      Leveraging Influencers: Key Drivers in New Product Launches

      August 27, 2025

      Top Influencer Marketing Platforms to Explore in 2025

      August 27, 2025

      Key Strategies for Successful Influencer Partnership Negotiations

      August 27, 2025
    • Content & Leadership

      The Impact of Social Proof on Thought Leadership Marketing

      August 27, 2025

      Balancing Value-Driven Content and Promotional Messaging Strategies

      August 27, 2025

      Analyzing Storytelling’s Impact on Content Marketing Effectiveness

      August 27, 2025
    • SEO & Analytics

      Scaling Success: Monitoring Indexation of Programmatic SEO Content

      August 27, 2025

      Strategies to Mitigate Duplicate Content in Programmatic SEO

      August 27, 2025

      Effective Data Visualization Techniques for SEO Reporting

      August 27, 2025
    • Marketing Trends

      How Privacy-First Marketing Will Transform the Industry Landscape

      August 27, 2025

      Emerging Trends in Marketing Automation and AI Tools for 2023

      August 27, 2025

      Maximizing ROI: Key Trends in Paid Social Advertising

      August 27, 2025
    Soshace Digital Blog
    Blog / JavaScript / Node.js / Setting Up Automated Semantic Versioning For Your NodeJS Project
    JavaScript

    Setting Up Automated Semantic Versioning For Your NodeJS Project

    bradstarartBy bradstarartAugust 8, 2020No Comments8 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Setting Up Automated Semantic Versioning For Your NodeJS Project
    Setting Up Automated Semantic Versioning For Your NodeJS Project
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link
    Setting Up Automated Semantic Versioning For Your NodeJS Project
    Setting Up Automated Semantic Versioning For Your NodeJS Project

    Over the course of writing a piece of software, you will find it incredibly helpful to be able to track different fixed states your project is in. One of the largest problems this solves is dependency hell.

    Dependency hell can take many forms, but generally occurs when your project and a library in your project rely on different incompatible versions of the same dependency. If your system doesn’t allow more than one instance of the library to be installed, you’d have to either drop the library or rely on an old version of the dependency. In doing so, other projects that rely on the same dependency would have to be updated… and so on.

    That’s obviously not ideal.

    And the saddest part is no matter what kind of project you have, as long as it has more than a couple dozen dependencies, dependency hell is inevitable.

    The simplest and most common solution to this problem is semantic versioning.

    What is Semantic Versioning?

    Software versioning in general refers to assigning numbers or codenames to certain fixed states of your software. This version number is usually incremental depending on the kinds of changes introduced into the software.

    Semantic versioning (semver) refers to a system of versioning software where releases of your software can be grouped as either major, minor or patch. This is represented using numbers in the format X.Y.Z.

    • Bug fixes that don’t change the API increment the patch version. eg. 0.1.1 -> 0.1.2
    • Additions that don’t change the API but add new functionality increment the minor number. eg. 0.1.1 -> 0.2.1
    • API-breaking changes increment the major number, eg. 0.1.1 -> 1.1.1

    While this is incredibly useful on its own for keeping track of changes in our code, the benefits of using semantic versioning in our project don’t end there. Some features you will find incredibly helpful as a result include:

    • Generating a changelog.
    • Making your commit messages more readable.
    • Automatically bumping the package version and uploading it to npm.

    In order to track the changes to our API in an automated way, we need a formal introduction to another popular spec: conventional commits.

    An introduction to conventional commits

    Conventional commits refers to a way of writing commit messages so that each can be tracked as a patch, a fix or a breaking change. If you’ve ever explored the Angular Commit Guide, the rules behind it are the same.

    • A patch is indicated using the prefix fix: eg. fix: corrects typo.
    • A minor change is indicated using the prefix feat: eg. feat: introduces login functionality
    • A major change is indicated using the text BREAKING CHANGE anywhere inside the commit, ie. a major change can be of any type.
    • An optional scope can be provided with every commit message, eg. fix(Login): fixes bug where users have to login twice
    • More prefixes are allowed by the spec, eg, refactor, patch, chore, docs, perf, test… etc, that may or may not trigger a new release.

    With these tools in our arsenal, we have enough weaponry to tackle this problem head-on.

    Automated semantic versioning with semantic-release

    The semantic versioning spec is incredibly useful for documenting changes in your code. However, a major bottleneck that still exists is the attachment of human emotion to the process of versioning the software. In other words, a developer might succumb to the temptation of not incrementing their version numbers for some reason, or, more likely, they might just forget.

    Read More:  This Is How I Created a Simple App Using React Routing

    Semantic-release is a NodeJS library built to tackle that exact problem. Rather than letting the developer manually bump the package version, this library (with the help of plugins) analyzes your commits and automatically increments the relevant package version for you with every new release.

    This project relies on express-starter, which sets our initial project version to 0.0.0.

    Let’s kick it off with our initial commit:

    git add . 
    git commit -m "feat(): initial commit"

    Next, install semantic-release

    npm install --save-dev semantic-release

    Then create a <code.releaserc and add the following settings

    module.exports = {
        repositoryUrl: 'https://github.com/Bradleykingz/semantic-release-tutorial',
        branches: ['master'],
    }

    Before we’re ready to set up our first release, we need to create a Github token with the following permissions:

    Github access tokens permissions
    Github access tokens permissions

    Then export it in your command line

    export GH_TOKEN=<your github token>

    If we commit the configuration file and run npx semantic-release

    git add . 
    git commit -m "chore(): adds semantic release config"
    npx semantic-release

    We get the following output:

    Console output
    Console output

    Notice that:

    feat triggered an incremental major release.
    chore doesn’t trigger a release, ie, the package version is not incremented.
    This doesn’t actually have an effect on our package.json because semantic release runs  a dry run by default. In order to actually work, we need to set a CI environment.

    To see semantic release in action, let’s set up a dummy project with Github Actions.

    Create a ‘.github/workflows/release.yml’ file with the following input

    name: Hello World
    
    on:
      push:
        branches: [ master ]
    
    jobs:
      Test:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout source code
            uses: actions/checkout@v2
          - name: Use NodeJS v12.16
            uses: actions/setup-node@v1
            with:
              node-version: 12.16
          - name: Install dependencies
            run: npm ci
          - name: Run tests
            run: npm run test
          - name: Create new release
            env:
              GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
            run: npx semantic-release

    All this does is checkout our source code, run tests and trigger a release. Notice that these steps will only be run when a new branch is pushed against master

    In this workflows, pushing directly to master is restricted except when merging. Basically, a new release will only be created when merging to master.

    For the purposes of this test, we’re going to create a dummy test using mocha and chai-http.

    npm install mocha chai-http -D
    git commit -m "chore(): adds test dependencies"

    Since our release will only be triggered on merge, we also need to checkout a new branch.

    git checkout -b feat/add-tests

    Then create a new test/dummy.js test file.

    let chai = require("chai");
    let chaiHttp = require("chai-http");
    let server=require("../app");
    let should = chai.should();
    chai.use(chaiHttp);
    
    describe("Root", function(){
      describe ("Get /", function(){
        it("should return a 200 code", done=>{
          chai.request(server)
              .get("/")
              .send({})
              .end((err,res)=>{
                res.should.have.status(200);
                res.body.should.be.deep.equals({message: "You did it!"})
                done()
              })
        })
    
      })
    })
    

    This queries our dummy server and ensures the message it returns is the same as what we expect.

    Of course, don’t forget to commit that:

    git commit -m "test(): adds new test"

    And push it

    git push origin feat/add-tests

    So that when we eventually merge to master, a v1.0.0 is created

    Read More:  Daily Schedule Post

    Bonus: creating pre-releases

    A pre-release is a ‘release that comes before the actual release’. To understand it, we have to change our workflow a bit.

    Before, we only had the master branch and additional branches named in the format ‘feat/*’. These latter were for working on individual features that are then merged into master. Pushing to master directly is restricted, and new code is checked out from the master branch.

    We need an additional branch – beta. Pushing directly to master is still forbidden. However, so is pushing directly to beta. Additionally, we can no longer merge our code to master directly. All code must first be merged into beta and only then can it end up on beta. This allows us to carry out integration tests and respond to feedback before our code ends up on the production branch.

    Let’s go ahead and create it:

    # from the master branch
    git checkout -b beta
    git push origin beta

    And slightly modify our .releaserc.js to add the following content:

    module.exports = {
      plugins: [
        "@semantic-release/commit-analyzer", 
        "@semantic-release/github",
        ["@semantic-release/npm", {
          npmPublish: false
        }],
        ["@semantic-release/release-notes-generator"],
        ["@semantic-release/git", {
          "assets": ["package.json"],
          "message": "chore(release): ${nextRelease.version} [skip ci]nn${nextRelease.notes}"
        }]
      ],
      branches: ['master'],
      preset: 'angular'
    }
    
    

    These are going to run in the order they are listed here. A rough overview of what happens is:

    1. It goes through your commits and decides whether the changes made should lead to the creation of a new release.
    2. It pings github using your GH_TOKEN to find out what the latest releases on your project are (you can, naturally, use a git provider of your choice. We use Github.)
    3. It bumps your package.json version (and doesn’t publish to npm)
    4. It scans through your commits and creates release notes.
    5. It commits your recently-changed package.json file with a message.

    Now, any branch with the matching the pattern feat/* will be recognized and released in the alpha distribution channel. In this case, our release should be v1.0.0-alpha.1 since we have never made a release before.

    Once we merge onto the beta branch, a new pre-release will be created as well, and published on the beta distribution channel. The version number will be v1.0.0-beta.1.

    And, finally, we can create the v1.1.0 release by merging the beta branch to master.

    The code can be found at: https://github.com/Bradleykingz/semantic-release-tutorial. Be sure to head over to the ‘actions’ tab to see the logs in action.

    Note: The project might have a few more releases than v1.1.0 because of various bug fixes that had to be made.

    Conclusion

    This article served as an introduction to Semantic Versioning and Conventional Commits. However, it just scratches the surface of all the amazing things semantic-release can do for you. In a more advanced setup, you will probably want to have:

    • A semantic-release plugin to ensure every commit corresponds to the Conventional Commits spec.
    • A semantic-release plugin to automatically create changelogs.
    • A plugin to publish your library to a registry like npm or Github Releases.
    • A Github plugin to ensure pull request is made with a conforming message.
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    bradstarart

      Related Posts

      Streamlining Resource Allocation for Enhanced Project Success

      December 18, 2024

      Conducting Effective Post-Project Evaluations: A Guide

      December 16, 2024

      Strategies for Keeping Projects on Track and Meeting Deadlines

      December 10, 2024
      Leave A Reply Cancel Reply

      You must be logged in to post a comment.

      Stay In Touch
      • Facebook
      • Twitter
      • Pinterest
      • Instagram
      • YouTube
      • Vimeo
      Don't Miss
      JavaScript November 16, 2020

      Getting started with Next.js

      Next.js is a React framework that allows you to build both client and server-side apps. It ships with handy features such as routing, static exporting, server rendering, internationalization.

      Analyzing Leadership Styles and Their Influence on Project Success

      November 25, 2024

      Автоматическое добавление в задачи ссылок на коммиты

      June 25, 2016

      6 Reasons to Integrate AI into Software Testing

      September 3, 2019

      Categories

      • AI & Automation
      • Angular
      • ASP.NET
      • AWS
      • B2B Leads
      • Beginners
      • Blogs
      • Business Growth
      • Case Studies
      • Comics
      • Consultation
      • Content & Leadership
      • CSS
      • Development
      • Django
      • E-commerce & Retail
      • Entrepreneurs
      • Entrepreneurship
      • Events
      • Express.js
      • Facebook Ads
      • Finance & Fintech
      • Flask
      • Flutter
      • Franchising
      • Funnel Strategy
      • Git
      • GraphQL
      • Home Services Marketing
      • Influencer & Community
      • Interview
      • Java
      • Java Spring
      • JavaScript
      • Job
      • Laravel
      • Lead Generation
      • Legal & Compliance
      • LinkedIn
      • Machine Learning
      • Marketing Trends
      • Medical Marketing
      • MSP Lead Generation
      • MSP Marketing
      • NestJS
      • Next.js
      • Node.js
      • Node.js Lessons
      • Paid Advertising
      • PHP
      • Podcasts
      • POS Tutorial
      • Programming
      • Programming
      • Python
      • React
      • React Lessons
      • React Native
      • React Native Lessons
      • Recruitment
      • Remote Job
      • SaaS & Tech
      • SEO & Analytics
      • Soshace
      • Startups
      • Swarm Intelligence
      • Tips
      • Trends
      • Vue
      • Wiki
      • WordPress
      Top Posts

      Best Udemy Online Courses to Learn JavaScript, React, Angular, and Node [Only Those Updated in 2019]

      JavaScript June 4, 2019

      Effective Strategies for Generating B2B Leads via Podcasting

      B2B Leads December 6, 2024

      С днем программиста!

      Programming September 12, 2016

      Interview with Alexander Troshchenko

      Interview March 28, 2018

      Subscribe to Updates

      Get The Latest News, Updates, And Amazing Offers

      About Us
      About Us

      Soshace Digital delivers comprehensive web design and development solutions tailored to your business objectives. Your website will be meticulously designed and developed by our team of seasoned professionals, who combine creative expertise with technical excellence to transform your vision into a high-impact, user-centric digital experience that elevates your brand and drives measurable results.

      7901 4th St N, Suite 28690
      Saint Petersburg, FL 33702-4305
      Phone: 1(877)SOSHACE

      Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
      Our Picks
      JavaScript

      Create simple POS with React, Node and MongoDB #5: Setup ReCaptcha and define CORS

      JavaScript

      Error Handling in JavaScript: A Guide to Try/Catch, Throw, and Custom Error Classes

      JavaScript

      Responsible Web Scraping: Gathering Data Ethically and Legally

      Most Popular

      Build Real-World React Native App #3: Home Screen With React Native Paper

      JavaScript

      Egestas Egestas Fringilla Phasellus Faucibus Scelerisque

      JavaScript

      Create a Simple POS with React, Node and MongoDB #0: Initial Setup Frontend and Backend

      JavaScript
      © 2025 Soshace Digital.
      • Home
      • About
      • Services
      • Contact Us
      • Privacy Policy
      • Terms & Conditions

      Type above and press Enter to search. Press Esc to cancel.