File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments