-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
semih.cavdar
committed
Mar 20, 2024
1 parent
d49097c
commit 6a8b7e9
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Version Check | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
verify-version: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get version | ||
id: version | ||
run: | | ||
version=$(git show HEAD:.github/workflows/publish.yml | awk '/tags/{print $2}' | sed 's/,$//') | ||
echo "version=$version" >> $GITHUB_ENV | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: main | ||
|
||
- name: Get main version | ||
id: main_version | ||
run: | | ||
main_version=$(git show HEAD:.github/workflows/publish.yml | awk '/tags/{print $2}' | sed 's/,$//') | ||
echo "main_version=$main_version" >> $GITHUB_ENV | ||
- name: Use Output | ||
id: output | ||
run: | | ||
echo "current_version : $version" | ||
echo "main_version : $main_version" | ||
- name: Compare versions | ||
id: compare_versions | ||
run: | | ||
IFS='.' read -ra version_parts <<< "$version" | ||
IFS='.' read -ra main_version_parts <<< "$main_version" | ||
for i in "${!version_parts[@]}"; do | ||
if [ "${version_parts[i]}" -lt "${main_version_parts[i]}" ]; then | ||
echo "$version is less than $main_version" | ||
exit 1 | ||
elif [ "${version_parts[i]}" -gt "${main_version_parts[i]}" ]; then | ||
echo "$version is greater than $main_version" | ||
exit 0 | ||
fi | ||
done | ||
if [ "${version_parts[@]}" != "${main_version_parts[@]}" ]; then | ||
echo "Error: $main_version is greater than $version" | ||
exit 1 | ||
fi | ||
echo "Please update the version. Current version: $version is equal to previous version: $main_version" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters