Skip to content

Commit

Permalink
Change checker #2
Browse files Browse the repository at this point in the history
  • Loading branch information
gtroitsk committed Jul 14, 2024
1 parent 563154a commit 8979fb7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/project.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Quarkus QE Test Framework
release:
current-version: 1.5.0
next-version: 1.5.1
current-version: 1.5.1.Beta1
next-version: 1.5.2
48 changes: 32 additions & 16 deletions .github/workflows/check-release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,41 @@ jobs:
if [[ "$GITHUB_BASE_REF" == "main" ]]; then
latest_prerelease=$(echo "$releases" | jq -r '.[] | select(.prerelease) | .tag_name' | head -n 1)
latest_prerelease_beta_number=$(echo "$latest_prerelease" | cut -d"." -f4,4 | grep -o '[0-9]\+' || true)
next_prerelease=$(grep -E 'current-version:\s*' .github/project.yml | awk '{print $2}')
next_prerelease_minor_version=$(echo "$next_prerelease" | cut -d"." -f2,2)
next_prerelease_patch_version=$(echo "$next_prerelease" | cut -d"." -f3,3)
next_prerelease_beta_number=$(echo "$next_prerelease" | cut -d"." -f4,4 | grep -o '[0-9]\+' || true)
prerelease_minor_version_bump=false
current_release=$(curl -sSL "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq -r .tag_name)
current_release_minor_version=$(echo "$current_release" | cut -d"." -f2,2)
echo "=============================================="
echo "Latest release: " $current_release
echo "Latest prerelease: " $latest_prerelease
echo "[main] " $latest_prerelease "->" $next_prerelease
echo "=============================================="
# Check if can change minor version after creating new branch
if [[ $current_release_minor_version == $next_prerelease_minor_version ]]; then
echo "Error: next LTS release branch is out, bump version to 1."$((next_prerelease_minor_version+1))".0.Beta1"
exit 1;
else
prerelease_minor_version_bump=true
fi
if [[ $(("$current_release_minor_version" + 1)) != $next_prerelease_minor_version ]]; then
echo "Error: pre-releases should have minor version one upper than last release"
exit 1;
fi
if [[ $next_prerelease_patch_version != 0 ]]; then
echo "Error: micro-releases are not allowed in development branch, use .Beta\D+ qualifier"
echo "Error: new releases are not allowed from development branch, use .Beta\D+ qualifier"
exit 1;
fi
if [[ $next_prerelease_beta_number != $(("$latest_prerelease_beta_number" + 1)) ]]; then
if [[ !($prerelease_minor_version_bump) && ($next_prerelease_beta_number != $(("$latest_prerelease_beta_number" + 1))) ]]; then
echo "Error: pre-release version should go one by one as sequence"
correct_version=$(echo "$latest_prerelease" | cut -d"." -f1,2,3)
correct_prerelease_number=$(($latest_prerelease_beta_number + 1))
Expand All @@ -58,16 +61,10 @@ jobs:
fi
else
expected_release_version=$(echo "$GITHUB_BASE_REF" | sed 's/z/0/')
first_release_tag_exists=$(echo "$releases" | jq -r '.[] | .tag_name' | grep "^$expected_release_version$" || true)
next_release=$(grep -E 'current-version:\s*' .github/project.yml | awk '{print $2}')
echo "=============================================="
echo "Expected_release_version: " $expected_release_version
echo "First 1.x.0 tag exists: " $first_release_tag_exists
echo "[" $GITHUB_BASE_REF "]" Project.yaml version: $next_release
echo "=============================================="
if [ -z "$first_release_tag_exists" ]; then
if [[ "$next_release" != "$expected_release_version" ]]; then
echo "Error: wrong tag name for the first release in new branch"
Expand All @@ -76,16 +73,35 @@ jobs:
exit 0;
fi
fi
branch_version=$(echo "$GITHUB_BASE_REF" | cut -d. -f1,2)
latest_branch_tag_patch_version=$(echo "$releases" | jq -r --arg version "$branch_version" '
.[]
| select(.tag_name | contains($version))
| .tag_name' | grep -v "Beta" | head -1 | cut -d. -f3)
branch_minor_version=$(echo "$GITHUB_BASE_REF" | cut -d. -f2,2)
next_release_minor_version=$(echo "$next_release" | cut -d"." -f2,2)
next_release_patch_version=$(echo "$next_release" | cut -d"." -f3,3)
beta_tag_exists=$(echo "$next_release" | cut -d"." -f4,4 || true)
echo "=============================================="
echo "[" $GITHUB_BASE_REF "]" project.yaml - current-version: $next_release
echo "=============================================="
if [ -n $beta_tag_exists ]; then
echo "Releases cannot consist any qualifier after version"
exit 1;
fi
echo "=============================================="
current_release=$(curl -sSL "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq -r .tag_name)
echo "Latest release: " $current_release
echo "First 1.x.0 tag exists: " $first_release_tag_exists
echo "[" $GITHUB_BASE_REF "]" $current_release "->" $next_release
echo "=============================================="

if [[ $branch_minor_version != $next_release_minor_version ]]; then
echo "Error: minor versions cannot be changed"
Expand Down

0 comments on commit 8979fb7

Please sign in to comment.