GitHub action to analyze conventional commits in a mono-repo and suggest next semantic version and tag
We use the following subset of conventional commit rules to decide when to bump the semantic version:
-
All rules are based on the commit short message and not the body
-
MAJOR: When the commit message (after prefix:) contains either
BREAKING CHANGE
orBREAKING CHANGES
-
MINOR: When the commit message prefix is
feat:
-
PATCH: When the commit message prefix is
fix:
orperf:
orrefactor:
The semantic analysis looks at all semantic commits meeting the previous rules that ocurred after the latest semantic tag for the given package
Our semantic tags have this fixed format: PACKAGE-vSEMVER
This action was created to tackle Yarn2 mono-repos where individual workspace releases are required. It can also be used with regular repos in the basic format below.
Make sure both package
and directory
input arguments are the name of the repo
name: ci-cd
on: [push]
jobs:
cd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: analyze
uses: rotorsoft/semrel-analyze@v1
with:
package: "chatbot"
directory: "chatbot"
- name: analysis
run: |
echo "last-tag: ${{ steps.analyze.outputs.last-tag }}"
echo "next-tag: ${{ steps.analyze.outputs.next-tag }}"
echo "next-version: ${{ steps.analyze.outputs.next-version }}"
echo "${{ steps.analyze.outputs.change-log }}"
name: ci-cd
on: [push]
jobs:
cd:
runs-on: ubuntu-latest
strategy:
matrix:
workspace:
- lib1
- lib2
- service
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: analyze
uses: rotorsoft/semrel-analyze@v1
with:
package: "@scope/${{ matrix.workspace }}"
directory: "workspace/${{ matrix.workspace }}"
- name: analysis
run: |
echo "last-tag: ${{ steps.analyze.outputs.last-tag }}"
echo "next-tag: ${{ steps.analyze.outputs.next-tag }}"
echo "next-version: ${{ steps.analyze.outputs.next-version }}"
echo "${{ steps.analyze.outputs.change-log }}"
Tag the new version and push it to the remote repo
git tag -a v1.1.0 -m "Release v1.1.0"
git push origin v1.1.0