diff --git a/.github/workflows/tag-patch-incre.yml b/.github/workflows/tag-patch-incre.yml new file mode 100644 index 000000000..6a8133328 --- /dev/null +++ b/.github/workflows/tag-patch-incre.yml @@ -0,0 +1,52 @@ +name: Increment tag for patch or minor + +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 -V | tail -n 1) + echo "Latest tag: $latest_tag" + + # Extract major and minor versions + version=$(echo $latest_tag | cut -d. -f1-2) + # Extract patch version + patch=$(echo $latest_tag | cut -d. -f3) + # 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 diff --git a/package-lock.json b/package-lock.json index 5061cdddc..9ee6c28a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8163,9 +8163,9 @@ } }, "node_modules/path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.9.0.tgz", + "integrity": "sha512-xIp7/apCFJuUHdDLWe8O1HIkb0kQrOMb/0u6FXQjemHn/ii5LrIzU6bdECnsiTF/GjZkMEKg1xdiZwNqDYlZ6g==", "peer": true, "dependencies": { "isarray": "0.0.1"