improve automated MapLibre Android release (#3497)
This commit is contained in:
41
.github/scripts/ensure-tag.sh
vendored
Executable file
41
.github/scripts/ensure-tag.sh
vendored
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
||||
echo "Usage: $0 <tag> [<commit-sha>]"
|
||||
echo " <tag> Git tag name to create or verify"
|
||||
echo " <commit-sha> Optional commit SHA to use (defaults to HEAD)"
|
||||
echo ""
|
||||
echo "This script will:"
|
||||
echo " - Check if the tag exists and matches the specified commit"
|
||||
echo " - Create and push the tag if it doesn't exist"
|
||||
echo " - Exit with error if tag exists but points to different commit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tag=$1
|
||||
commit_sha=${2:-$(git rev-parse HEAD)}
|
||||
|
||||
if [ -z "$(git config user.name)" ]; then
|
||||
git config user.name "MapLibre Team"
|
||||
fi
|
||||
|
||||
if [ -z "$(git config user.email)" ]; then
|
||||
git config user.email "team@maplibre.org"
|
||||
fi
|
||||
|
||||
if git rev-parse "$tag" >/dev/null 2>&1; then
|
||||
tag_sha=$(git rev-parse "$tag^{commit}")
|
||||
if [ "$tag_sha" = "$commit_sha" ]; then
|
||||
echo "✅ Tag $tag exists and matches specified commit SHA."
|
||||
exit 0
|
||||
else
|
||||
echo "::error::❌ Tag $tag exists but points to a different commit."
|
||||
echo " Expected: $commit_sha"
|
||||
echo " Actual: $tag_sha"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
git tag -a "$tag" -m "Publish $tag" "$commit_sha"
|
||||
# git push origin "$tag"
|
||||
echo "✅ Created tag $tag for commit $commit_sha."
|
||||
fi
|
||||
27
.github/scripts/validate-version.sh
vendored
27
.github/scripts/validate-version.sh
vendored
@@ -3,21 +3,40 @@
|
||||
validate_version() {
|
||||
local version="$1"
|
||||
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-pre.*)?$ ]]; then
|
||||
echo "::error::Invalid version '$version' in $(realpath VERSION). Expected: X.Y.Z or X.Y.Z-pre*"
|
||||
echo "::error::Invalid version '$version' in $(realpath "$version_file"). Expected: X.Y.Z or X.Y.Z-pre*"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
version=$(cat VERSION 2>/dev/null)
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <version-file>"
|
||||
echo ""
|
||||
echo "This script will:"
|
||||
echo " - Validate version format in specified file"
|
||||
echo " - Export version to GITHUB_ENV if in GitHub Actions"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version_file="$1"
|
||||
|
||||
if [ ! -f "$version_file" ]; then
|
||||
echo "::error::Version file not found: $(realpath "$version_file")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=$(cat "$version_file" 2>/dev/null)
|
||||
if [ -z "$version" ]; then
|
||||
echo "::error::No VERSION file found or empty in $PWD"
|
||||
echo "::error::Version file is empty: $(realpath "$version_file")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if validate_version "$version"; then
|
||||
echo "Version validation successful: $version"
|
||||
echo "✅ Version validation successful: $version"
|
||||
if [[ -n "${GITHUB_ENV:-}" ]]; then
|
||||
echo "version=$version" >> "$GITHUB_ENV"
|
||||
fi
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user