DEV Community

Cover image for Automatic Application Versioning
Joshua Amaju
Joshua Amaju

Posted on • Updated on

Automatic Application Versioning

Learn how to setup versioning with in your CI/CD workflow


  • Easy rollback to last working release
  • Automatic release workflow


npm install @changesets/cli && npx changeset init
Enter fullscreen mode Exit fullscreen mode

Make sure your package.json includes the version field i.e version: "0.0.0" and private: true.

Then set privatePackages to { version: true, tag: true } in your .changesets/config.json

To create a version bump

npx changeset
Enter fullscreen mode Exit fullscreen mode

which should prompt you to specify the type of change

  • patch - when you fix issues with an exiting release
  • minor - when you modify features that do not impact application function
  • major - when you've made changes that add new features or change exiting application functionality

See here for more information on semantic versioning

You'll then be prompted to provide a message for the change.

To create a new version

npx changeset version
Enter fullscreen mode Exit fullscreen mode

To publish the new version

npx changeset publish
Enter fullscreen mode Exit fullscreen mode

Release setup

We'll use the changeset github action. I'll be using firebase for hosting in this example.

Github action

name: Release to Firebase
      - master
    runs-on: ubuntu-latest
      - uses: actions/checkout@v3

      - name: Install dependencies
        uses: ./.github/actions/setup

      # run tests before release
      - run: pnpm test

      - name: create release pull request
        id: changesets
        uses: changesets/action@v1
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # This step can be replace with your build script i.e `npm run build`, then push to your hosting provider
      - uses: FirebaseExtended/action-hosting-deploy@v0
        # only create a release to firebase if we have changes
        if: steps.changesets.outputs.hasChangesets == 'true'
          FIREBASE_CLI_EXPERIMENTS: webframeworks
          repoToken: "${{ secrets.GITHUB_TOKEN }}"
          firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
          channelId: live
          projectId: <project-id>

Enter fullscreen mode Exit fullscreen mode

This step does the following:

  • triggers your github action when you merge to master
  • creates a release PR based on your changesets, which when merged pushes to your desired hosting provider
  • then creates a tag that's pushed to github.

cover image by Roman Synkevych on Unsplash

Top comments (0)