Skip to content

Modify SubmitAndMonitorMultipleJobs to collect job failures and report instead of exiting early #211

Modify SubmitAndMonitorMultipleJobs to collect job failures and report instead of exiting early

Modify SubmitAndMonitorMultipleJobs to collect job failures and report instead of exiting early #211

name: Check Version Bump in PR
on:
pull_request:
branches:
- main
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v3
with:
fetch-depth: 2 # Ensure we get both base and head commits
- name: Check for VERSION file changes and content
run: |
echo "Checking if VERSION.txt was changed..."
# Get the list of changed files
git fetch origin ${{ github.base_ref }} --depth=1
changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
echo "Changed files:"
echo "$changed_files"
if echo "$changed_files" | grep -q "^VERSION.txt$"; then
echo "✅ VERSION.txt was changed."
else
echo "❌ VERSION.txt was NOT changed. Please update it when making a release-worthy change."
exit 1
fi
echo "Checking contents of VERSION.txt..."
# Check that VERSION.txt has at least two non-empty lines
line_count=$(grep -cve '^\s*$' VERSION.txt)
if [ "$line_count" -lt 2 ]; then
echo "❌ VERSION.txt must contain both a version and release notes (at least 2 non-empty lines)."
exit 1
else
echo "✅ VERSION.txt has a version and release notes."
fi
echo "Comparing version numbers..."
# Extract the previous version from base branch
git show origin/${{ github.base_ref }}:VERSION.txt > old_version.txt
old_version=$(head -n 1 old_version.txt | tr -d '[:space:]')
new_version=$(head -n 1 VERSION.txt | tr -d '[:space:]')
echo "Old version: $old_version"
echo "New version: $new_version"
# Function to convert version to a sortable number (e.g., 4.1.5 -> 004001005)
version_to_number() {
IFS='.' read -r major minor patch <<< "$1"
printf "%03d%03d%03d\n" "$major" "$minor" "$patch"
}
old_ver_num=$(version_to_number "$old_version")
new_ver_num=$(version_to_number "$new_version")
if [ "$new_ver_num" -le "$old_ver_num" ]; then
echo "❌ VERSION.txt version must be incremented (new version must be greater than old version)."
exit 1
else
echo "✅ Version was incremented."
fi