Enhance version validation in CI workflow to handle first release scenarios
CI and Release / format (pull_request) Successful in 2m21s
CI and Release / analyze (pull_request) Successful in 23s
CI and Release / test (pull_request) Successful in 27s
CI and Release / pana (pull_request) Successful in 1m22s
CI and Release / version-and-changelog (pull_request) Successful in 22s
CI and Release / publish (pull_request) Successful in 20s
CI and Release / format (pull_request) Successful in 2m21s
CI and Release / analyze (pull_request) Successful in 23s
CI and Release / test (pull_request) Successful in 27s
CI and Release / pana (pull_request) Successful in 1m22s
CI and Release / version-and-changelog (pull_request) Successful in 22s
CI and Release / publish (pull_request) Successful in 20s
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
+22
-3
@@ -108,10 +108,22 @@ jobs:
|
|||||||
git fetch origin "${GITHUB_BASE_REF}" --depth=1
|
git fetch origin "${GITHUB_BASE_REF}" --depth=1
|
||||||
|
|
||||||
PR_VERSION="$(sed -nE 's/^version:\s*([^[:space:]]+)\s*$/\1/p' pubspec.yaml | head -n1)"
|
PR_VERSION="$(sed -nE 's/^version:\s*([^[:space:]]+)\s*$/\1/p' pubspec.yaml | head -n1)"
|
||||||
BASE_VERSION="$(git show "origin/${GITHUB_BASE_REF}:pubspec.yaml" | sed -nE 's/^version:\s*([^[:space:]]+)\s*$/\1/p' | head -n1)"
|
BASE_HAS_PUBSPEC="false"
|
||||||
|
BASE_VERSION=""
|
||||||
|
|
||||||
if [ -z "$PR_VERSION" ] || [ -z "$BASE_VERSION" ]; then
|
if git cat-file -e "origin/${GITHUB_BASE_REF}:pubspec.yaml" 2>/dev/null; then
|
||||||
echo "Unable to read versions from pubspec.yaml."
|
BASE_HAS_PUBSPEC="true"
|
||||||
|
BASE_VERSION="$(git show "origin/${GITHUB_BASE_REF}:pubspec.yaml" | sed -nE 's/^version:\s*([^[:space:]]+)\s*$/\1/p' | head -n1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$PR_VERSION" ]; then
|
||||||
|
echo "Unable to read version from PR pubspec.yaml."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$BASE_HAS_PUBSPEC" = "true" ]; then
|
||||||
|
if [ -z "$BASE_VERSION" ]; then
|
||||||
|
echo "Unable to read version from base branch pubspec.yaml."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -156,6 +168,9 @@ jobs:
|
|||||||
echo "pubspec.yaml version must be at least 0.0.1 greater than base version ($BASE_VERSION -> $PR_VERSION)."
|
echo "pubspec.yaml version must be at least 0.0.1 greater than base version ($BASE_VERSION -> $PR_VERSION)."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "Base branch has no pubspec.yaml; treating this as first release."
|
||||||
|
fi
|
||||||
|
|
||||||
if git diff --quiet "origin/${GITHUB_BASE_REF}...HEAD" -- CHANGELOG.md; then
|
if git diff --quiet "origin/${GITHUB_BASE_REF}...HEAD" -- CHANGELOG.md; then
|
||||||
echo "CHANGELOG.md must be updated in the PR."
|
echo "CHANGELOG.md must be updated in the PR."
|
||||||
@@ -167,7 +182,11 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$BASE_HAS_PUBSPEC" = "true" ]; then
|
||||||
echo "Version/changelog gate passed: $BASE_VERSION -> $PR_VERSION"
|
echo "Version/changelog gate passed: $BASE_VERSION -> $PR_VERSION"
|
||||||
|
else
|
||||||
|
echo "Version/changelog gate passed for first release: $PR_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
name: publish
|
name: publish
|
||||||
|
|||||||
Reference in New Issue
Block a user