Automating Versioning and Releases Using Semantic Release

Moving away from a manual (semi-automated), repetitive, error-prone process.

  • Did we pick the right version number for our new release?
  • Did we git tag correctly? Hopefully, using the same version number.
  • Did we write a correct changelog? and so on…
  • Calculate the new version number based on the commit messages
  • Create git tags for every release
  • Publish a release to GitHub releases & NuGet (package manager for .NET)
  • Create release notes & changelogs automatically
  • Notify maintainers and users of new releases

Semantic Versioning & Conventional Commits

  1. Semantic Versioning
  2. Conventional Commits

Semantic Versioning

  1. MAJOR version is incremented when you make any breaking change
  2. MINOR version is incremented when you add a new feature/functionality
  3. PATCH version is incremented when you make bug fixes

To sum up what Semantic versioning does in one line-

Conventional Commits

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing or correcting existing tests
  • chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
feat(logging): added logs for failed signups
fix(homepage): fixed image gallery
test(homepage): updated tests
docs(readme): added new logging table information

Semantic Release

semantic-release uses the commit messages to determine the type of changes in the codebase. Following formalized conventions for commit messages, semantic-release automatically determines the next semantic version number, generates a changelog and publishes the release.

  • If the body contains the text “BREAKING CHANGE” then MAJOR version is incremented.
  • If the type contains feat/feature, then MINOR version is incremented.
  • If the type contains fix, then PATCH version is incremented.
  • And finally, if the type contains refactor/style/perf/doc/test/chore, then nothing is increment and no release is made.

Configuring Semantic Release with GitHub actions.

publish:
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
with:
extra_plugins: |
@semantic-release/git
@semantic-release/exec
@semantic-release/changelog
module.exports = {
branches: ['main'],
"verifyConditions": ["@semantic-release/github"],
"prepare": // INSERT-CUSTOM-COMMANDS-HERE-TO-RUN-ON-PREPARE,
"publish": // INSERT-CUSTOM-COMMANDS-HERE-TO-RUN-ON-PUBLISH,
"notify": // INSERT-CUSTOM-COMMANDS-HERE-TO-RUN-ON-NOTIFY
}

Revisiting our checklist

Summary

References

Join the team

careersatagoda.com

--

--

Learn about how products are developed at Agoda, what is being done under the hood, from engineering to design, to provide users a seamless experience at agoda.com.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yasser Shaikh

Lead @ Agoda.com — Full stack Engineering. Gamer, Footballer, Bollywood Buff, Software Engineer, and @stackoverflow contributor. Mumbaikar.