Skip to content

Commit aa7924a

Browse files
authored
Merge pull request #35 from malikparvez/malikparvez-patch-10
Create branching.yml
2 parents 2dac00e + dc4b982 commit aa7924a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/branching.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Compare Versions
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
compare-versions:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Get tags from main branch
14+
id: get_tags
15+
run: |
16+
version=$(curl -sL https://api.github.com/repos/${GITHUB_REPOSITORY}/tags | jq -r '.[0].name')
17+
echo "::set-output name=version::$version"
18+
19+
- name: Compare versions
20+
id: compare_versions
21+
run: |
22+
version1="${{ steps.get_tags.outputs.version }}"
23+
version2="v2.3.1" # Manually provided version
24+
25+
major_version1=$(echo "$version1" | cut -d'.' -f1 | sed 's/[^0-9]//g')
26+
major_version2=$(echo "$version2" | cut -d'.' -f1 | sed 's/[^0-9]//g')
27+
28+
if [ "$major_version1" -lt "$major_version2" ]; then
29+
echo "::set-output name=major_version_upgrade::true"
30+
else
31+
echo "::set-output name=major_version_upgrade::false"
32+
fi
33+
34+
- name: Create branch if major version upgrade
35+
if: steps.compare_versions.outputs.major_version_upgrade == 'true'
36+
run: |
37+
git checkout -b new_branch
38+
git push origin new_branch

0 commit comments

Comments
 (0)