-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathweblate-version-map.sh
More file actions
38 lines (33 loc) · 1.11 KB
/
weblate-version-map.sh
File metadata and controls
38 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# SPDX-FileCopyrightText: 2026 William Jin <AuraMindNest@outlook.com>
#
# SPDX-License-Identifier: BSL-1.0
#
# Map PyPI Weblate calver releases to fixed Docker Hub tags (YEAR.MONTH.PATCH.BUILD).
# See https://docs.weblate.org/en/latest/contributing/release.html
# shellcheck shell=bash
pypi_to_docker_fixed() {
local v="$1"
local year month patch
IFS=. read -r year month patch <<< "$v"
patch="${patch:-0}"
echo "${year}.${month}.${patch}.0"
}
parse_pypi_weblate_version() {
local file="${1:-pyproject.toml}"
grep -E '^[[:space:]]*"Weblate\[all\]==[0-9][0-9.]+"' "$file" \
| head -n1 \
| sed -E 's/.*Weblate\[all\]==([0-9][0-9.]+).*/\1/'
}
parse_docker_weblate_tag() {
local file="${1:-docker/Dockerfile.weblate-plugin}"
grep -E '^FROM weblate/weblate:[0-9][0-9.]+' "$file" \
| head -n1 \
| sed -E 's/^FROM weblate\/weblate:([0-9][0-9.]+).*/\1/'
}
docker_weblate_tag_exists() {
local tag="$1"
local code
code="$(curl -sS --connect-timeout 10 --max-time 30 -o /dev/null -w '%{http_code}' \
"https://hub.docker.com/v2/repositories/weblate/weblate/tags/${tag}/")"
[[ "$code" == "200" ]]
}