Skip to content

change head with main #26

change head with main

change head with main #26

Workflow file for this run

name: Version Verification
on:
push:
branches:
- '**'
jobs:
verify-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get previous version
id: previous_version
run: |
commit_sha=$(git log --pretty=format:%H -n 1)
previous_version=$(git show $commit_sha:.github/workflows/publish.yml | awk '/tags/{print $2}' | sed 's/,$//')
echo "previous_version=$previous_version" >> $GITHUB_ENV
- name: Get main version
id: version
run: |
version=$(git show main:.github/workflows/publish.yml | awk '/tags/{print $2}' | sed 's/,$//')
echo "version=$version" >> $GITHUB_ENV
- name: Use Output
id: output
run: |
echo "Output is $version"
echo "Output is $previous_version"
- name: Compare versions
id: compare_versions
run: |
IFS='.' read -ra version_parts <<< "$version"
IFS='.' read -ra previous_version_parts <<< "$previous_version"
for i in "${!version_parts[@]}"; do
if [ "${version_parts[i]}" -lt "${previous_version_parts[i]}" ]; then
echo "$version is less than $previous_version"
exit 0
elif [ "${version_parts[i]}" -gt "${previous_version_parts[i]}" ]; then
echo "$version is greater than $previous_version"
exit 0
fi
done
if [ "${version_parts[@]}" != "${previous_version_parts[@]}" ]; then
echo "Error: $previous_version is greater than $version"
exit 1
fi
echo "Please update the version. Current version: $version is equal to previous version: $previous_version"
exit 1