Sunday, July 21, 2024

How to Release Service – DEV Community

Programming LanguageHow to Release Service - DEV Community


In this post, I will explain how to release service using Semantic Versioning.

What is Service?

In making an application some components make the application run properly. For example in an e-commerce application, there is a login process (login service), after login, we can see the dashboard (dashboard service), and when we want to buy goods we will checkout and make payments (payment service).
Login, Dashboard, and Payment are what we call service.

What is Release?

Release is the process of releasing a service. Before releasing a service, the service must usually undergo a testing and validation process to determine whether the service is ready to use.

What is Semantic Versioning?

Semantic Versioning commonly abbreviated as SemVer is a way to give a version number to a service with the format [MAJOR].[MINOR].[PATCH]. example: 1.0.1
A full explanation can be read here.

Why use Semantic Versioning?

If there are many services in an application, SemVer will make it easier for us to manage dependencies or compatibility between services.

How to start

It’s quite simple to release a service using SemVer, we only need to do git tag X.X.X on our service repository.

However, I will not do that in this post. Instead, I will use the npm package called standard-version.

standard-version is a tool to create a version using SemVer and generate a CHANGELOG file supported by Conventional Commits. More details about the standard-version can be found here.

Step by Step

Before releasing using the standard-version, make sure the commit follows the Conventional Commit Message format.

Install standard-version

npm install -g standard-version
Enter fullscreen mode

Exit fullscreen mode

In the service repository, create 2 files. version.json and .versionrc and initialize the tag.

version.json file.

{
    "version": "0.1.0"
}
Enter fullscreen mode

Exit fullscreen mode

.versionrc

{
  "bumpFiles": [
    {
      "filename": "version.json",
      "type": "json"
    }
  ],
  "releaseCommitMessageFormat": "chore(release): release {{currentTag}}"
}
Enter fullscreen mode

Exit fullscreen mode

Tag initialization.

git tag v0.1.0
Enter fullscreen mode

Exit fullscreen mode

If so, test by committing. Example:

// Make changes to the service repository, then commit the changes.
git add . && git commit -m "feat: test update feature"

// Then update the service version.
standard-version

// Check if there are new tag and new commit.
git tag -l
git log --oneline
Enter fullscreen mode

Exit fullscreen mode

Done, we successfully released the service.

Check out our other content

Check out other tags:

Most Popular Articles