From c418ce0a9a8ded66d359f77fb10f9fcefab3010f Mon Sep 17 00:00:00 2001 From: systemsdt Date: Thu, 12 Sep 2024 15:05:20 +0530 Subject: [PATCH 1/4] added mech for tagging 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..32f6a66 --- /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 }} + 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 35a0d0c588892978daeceaf31e75f0a74b4b7e16 Mon Sep 17 00:00:00 2001 From: Kiran <155609672+kirandevtn@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:39:15 +0530 Subject: [PATCH 2/4] Update tag-patch-incre.yaml --- .github/workflows/tag-patch-incre.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag-patch-incre.yaml b/.github/workflows/tag-patch-incre.yaml index 32f6a66..97fc314 100644 --- a/.github/workflows/tag-patch-incre.yaml +++ b/.github/workflows/tag-patch-incre.yaml @@ -19,7 +19,7 @@ jobs: - name: Create new tag env: - TOKEN: ${{ secrets.TAG_CREATION_TOKEN }} + TOKEN: ${{ secrets.TAG_CREATION_TOKEN_PUBLIC }} run: | echo $TOKEN | gh auth login --with-token latest_tag=$(git tag --sort=refname | tail -n 1) @@ -33,4 +33,4 @@ jobs: 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 c2cea701f89f10841597da3e1945e07a02ff0886 Mon Sep 17 00:00:00 2001 From: Kiran <155609672+kirandevtn@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:28:29 +0530 Subject: [PATCH 3/4] Update tag-patch-incre.yaml --- .github/workflows/tag-patch-incre.yaml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tag-patch-incre.yaml b/.github/workflows/tag-patch-incre.yaml index 97fc314..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,12 +24,28 @@ 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 From d0ccafe75c185b89c4b4cc5796be113d7b645695 Mon Sep 17 00:00:00 2001 From: Kiran <155609672+kirandevtn@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:15:29 +0530 Subject: [PATCH 4/4] Update tag-patch-incre.yaml --- .github/workflows/tag-patch-incre.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tag-patch-incre.yaml b/.github/workflows/tag-patch-incre.yaml index 4886d59..6a81333 100644 --- a/.github/workflows/tag-patch-incre.yaml +++ b/.github/workflows/tag-patch-incre.yaml @@ -22,7 +22,7 @@ jobs: TOKEN: ${{ secrets.TAG_CREATION_TOKEN_PUBLIC }} run: | echo $TOKEN | gh auth login --with-token - latest_tag=$(git tag --sort=refname | tail -n 1) + latest_tag=$(git tag | sort -V | tail -n 1) echo "Latest tag: $latest_tag" # Extract major and minor versions