From 590a91d4f82c28715cd1f3f9acfa4b4dadc50e8c Mon Sep 17 00:00:00 2001 From: systemsdt Date: Thu, 12 Sep 2024 15:57:56 +0530 Subject: [PATCH 1/3] added mech for tagging of hotfixes --- .github/workflows/tag-patch-incre.yaml | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/tag-patch-incre.yaml diff --git a/.github/workflows/tag-patch-incre.yaml b/.github/workflows/tag-patch-incre.yaml new file mode 100644 index 0000000..a98e41a --- /dev/null +++ b/.github/workflows/tag-patch-incre.yaml @@ -0,0 +1,36 @@ +name: Increment tag for patch + +on: + pull_request: + branches: + - main + types: + - closed # Trigger only when a PR is closed (merged or not) + +jobs: + tag: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Create new tag + env: + TOKEN: ${{ secrets.TAG_CREATION_TOKEN_PUBLIC }} + run: | + echo $TOKEN | gh auth login --with-token + latest_tag=$(git tag --sort=refname | tail -n 1) + echo "Latest tag: $latest_tag" + # Extract major and minor versions + version=$(echo $latest_tag | cut -d. -f1-2) + # Extract patch version and increment it + patch=$(echo $latest_tag | cut -d. -f3) + new_tag="$version.$((patch+1))" + echo "New tag will be: $new_tag" + git config --global user.email "devops@devtron.ai" + git config --global user.name "systemsdt" + git tag $new_tag + git push origin $new_tag \ No newline at end of file From aebaa2c1e7c20973678ae83cd48ffad72109e1c1 Mon Sep 17 00:00:00 2001 From: Kiran <155609672+kirandevtn@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:26:58 +0530 Subject: [PATCH 2/3] Update tag-patch-incre.yaml --- .github/workflows/tag-patch-incre.yaml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tag-patch-incre.yaml b/.github/workflows/tag-patch-incre.yaml index a98e41a..4886d59 100644 --- a/.github/workflows/tag-patch-incre.yaml +++ b/.github/workflows/tag-patch-incre.yaml @@ -1,4 +1,4 @@ -name: Increment tag for patch +name: Increment tag for patch or minor on: pull_request: @@ -24,13 +24,29 @@ jobs: echo $TOKEN | gh auth login --with-token latest_tag=$(git tag --sort=refname | tail -n 1) echo "Latest tag: $latest_tag" + # Extract major and minor versions version=$(echo $latest_tag | cut -d. -f1-2) - # Extract patch version and increment it + # Extract patch version patch=$(echo $latest_tag | cut -d. -f3) - new_tag="$version.$((patch+1))" - echo "New tag will be: $new_tag" + # Extract minor version + minor=$(echo $latest_tag | cut -d. -f2) + major=$(echo $latest_tag | cut -d. -f1) + + # Check if the incoming branch starts with 'release-candidate-' + incoming_branch="${{ github.head_ref }}" + if [[ "$incoming_branch" == release-candidate-* ]]; then + # Increment minor version and reset patch + new_minor=$((minor+1)) + new_tag="$major.$new_minor.0" + echo "New tag will be (minor increment): $new_tag" + else + # Increment patch version + new_tag="$version.$((patch+1))" + echo "New tag will be (patch increment): $new_tag" + fi + git config --global user.email "devops@devtron.ai" git config --global user.name "systemsdt" git tag $new_tag - git push origin $new_tag \ No newline at end of file + git push origin $new_tag From 672c9c75d7c03c86c29bec388a9a5edfe7a61e7d Mon Sep 17 00:00:00 2001 From: Kiran <155609672+kirandevtn@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:13:31 +0530 Subject: [PATCH 3/3] Update tag-patch-incre.yaml --- .github/workflows/tag-patch-incre.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tag-patch-incre.yaml b/.github/workflows/tag-patch-incre.yaml index 4886d59..3eda4e4 100644 --- a/.github/workflows/tag-patch-incre.yaml +++ b/.github/workflows/tag-patch-incre.yaml @@ -50,3 +50,4 @@ jobs: git config --global user.name "systemsdt" git tag $new_tag git push origin $new_tag +