Skip to content

Commit 2538ac1

Browse files
authored
Validate version android-ci and android-release workflow (maplibre#3479)
1 parent 30f3231 commit 2538ac1

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
validate_version() {
4+
local version="$1"
5+
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-pre.*)?$ ]]; then
6+
echo "::error::Invalid version format in VERSION file. Expected: X.Y.Z or X.Y.Z-pre*"
7+
return 1
8+
fi
9+
return 0
10+
}
11+
12+
version=$(cat VERSION 2>/dev/null)
13+
if [ -z "$version" ]; then
14+
echo "::error::VERSION file not found or empty"
15+
exit 1
16+
fi
17+
18+
if validate_version "$version"; then
19+
echo "Version validation successful: $version"
20+
if [[ -n "${GITHUB_ENV:-}" ]]; then
21+
echo "version=$version" >> "$GITHUB_ENV"
22+
fi
23+
fi

.github/workflows/android-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ jobs:
6666
submodules: recursive
6767
fetch-depth: 0
6868

69+
- name: Validate VERSION
70+
run: ../../.github/scripts/validate-version.sh
71+
working-directory: platform/android
72+
6973
- run: echo "cmake.dir=$(dirname "$(dirname "$(command -v cmake)")")" >> local.properties
7074

7175
- uses: actions/setup-java@v4

.github/workflows/android-release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ jobs:
4242
- name: Android nitpick
4343
run: make run-android-nitpick
4444

45-
- name: Set version name
45+
- name: Validate and set version
46+
working-directory: platform/android
4647
run: |
47-
echo version="$(cat VERSION)" > "$GITHUB_ENV"
48+
../../.github/scripts/validate-version.sh
4849
4950
- name: Build package
5051
run: |

0 commit comments

Comments
 (0)