Coder Social home page Coder Social logo

commitizen_example's Introduction

This repo will use to showcase the commitizen CI configuration

Among the automated versioning tools, ‘commitizen’ came out as the most suitable option for our requirements since it is not limited to a specific technology stack like Java or React. It can be used globally for any project and can automate the process if the project is in a proper CI environment.

Here's how to integrate commitizen into the Github actions of any project.

  1. Create two files named .cz.yaml and Changelog in the root directory of the project.
  2. Add the following content into the .cz.yaml file.
    ---
    commitizen:
      name: cz_conventional_commits
      tag_format: $version
      version: 3.0.0
  1. Create a personal access token. Follow the instructions here. And copy the generated key (you can use any among the fine-grained or classic personal access tokens).

  2. Add the read-and-write access to the content permission of the token by clicking edit right next to the token.

  3. Create a secret called PERSONAL_ACCESS_TOKEN, with the copied key, by going to your project repository and then Settings -> Secrets and variables -> New repository secret -> Add new secret.

  4. In your project create a new file .github/workflows/bumpversion.yml and add the below content.

name: Bump version

on:
  push:
    branches:
      - main

permissions:
  contents: write

jobs:
  bump-version:
    if: "!startsWith(github.event.head_commit.message, 'bump:')"
    runs-on: ubuntu-latest
    name: "Bump version and create changelog with commitizen"
    steps:
      - name: Checkout Latest Commit
        uses: actions/checkout@v2
        with:
          token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
          fetch-depth: 0
      - name: Create bump and changelog
        uses: commitizen-tools/commitizen-action@master
        with:
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          changelog_increment_filename: body.md
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          body_path: "body.md"
          tag_name: ${{ env.REVISION }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Update version in pom.xml
        run: |
          mvn -B versions:set -DnewVersion=${{ env.REVISION }} -DgenerateBackupPoms=false
          mvn versions:commit
      - name: Commit files
        uses: test-room-7/action-update-file@v1
        with:
          file-path: pom.xml
          commit-msg: bump:update pom
          github-token: ${{ secrets.GITHUB_TOKEN }}
  1. Push this file and that’s it!

commitizen_example's People

Contributors

tharindubsfdv avatar github-actions[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.