Skip to content

Commit e1c62b8

Browse files
committed
Resolve release version from lv_bindings tag when syncing.
Fix tag step failing on newer LVGL (lv_version.h); pass LV_BINDINGS_REF from sync CI so v9.2.0 maps to lv_cpython_mod v0.2.0 on TestPyPI.
1 parent 2c10f50 commit e1c62b8

4 files changed

Lines changed: 128 additions & 61 deletions

File tree

‎.github/workflows/sync-and-release.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ jobs:
7070
7171
- name: Create and push release tag
7272
if: inputs.skip_publish != true && steps.commit.outputs.changed == 'true'
73+
env:
74+
LV_BINDINGS_REF: ${{ steps.lv_bindings_ref.outputs.ref }}
7375
run: |
7476
set -euo pipefail
7577
git fetch --tags origin

‎PUBLISHING.md‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ lv_cpython_mod: Publish TestPyPI (on tag push v*.*.*)
2424

2525
## Version numbers
2626

27-
Tags and PyPI versions use **`0.<lvgl_minor>.<binding_release>`** while testing on TestPyPI:
27+
Tags and PyPI versions follow the same scheme as [lv_bindings](https://github.com/PyDevices/lv_bindings): **`X.Y.Z`** where **X.Y** is the LVGL API line and **Z** is the binding release on that line (see `regenerate_all.sh` there).
2828

29-
| Part | Source |
30-
|------|--------|
31-
| `0` | TestPyPI override (use `LVCPYTHON_USE_REAL_LVGL_MAJOR=1` for real LVGL major, e.g. `9.1.N`) |
32-
| `<lvgl_minor>` | `LVGL_VERSION_MINOR` in `lvgl/lvgl.h` |
33-
| `<binding_release>` | Auto-incremented from existing `v0.<minor>.*` tags |
29+
When **Sync and release** runs with an `lv_bindings` commit that has a release tag (e.g. `v9.2.0`), **lv_cpython_mod uses that tag for versioning** — no need to parse `lvgl.h` / `lv_version.h`.
30+
31+
| Mode | Example lv_bindings tag | lv_cpython_mod tag |
32+
|------|-------------------------|-------------------|
33+
| TestPyPI (default) | `v9.2.0` | `v0.2.0` (major forced to **0**) |
34+
| Real LVGL major | `v9.2.0` | `v9.2.0` (`LVCPYTHON_USE_REAL_LVGL_MAJOR=1`) |
35+
36+
If `LV_BINDINGS_REF` has no release tag, the script falls back to the local `lvgl` submodule headers and auto-increments the patch from existing tags in this repo.
3437

3538
Preview the next version:
3639

‎scripts/next_release_version.sh‎

Lines changed: 114 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
#!/usr/bin/env bash
22
# Compute the next lvgl-cpython release version: <major>.<lvgl_minor>.<binding_release>
33
#
4-
# major — 0 while testing on TestPyPI (override); LVGL_VERSION_MAJOR when
5-
# LVCPYTHON_USE_REAL_LVGL_MAJOR=1
6-
# lvgl_minor — from lvgl/lvgl.h (LVGL_VERSION_MINOR)
7-
# binding_release — one greater than the highest existing v<major>.<minor>.* tag
4+
# Preferred: resolve X.Y.Z from the lv_bindings tag at LV_BINDINGS_REF (same scheme as
5+
# lv_bindings regenerate_all.sh: LVGL major.minor + binding patch).
86
#
9-
# Usage (from repo root or anywhere):
7+
# Fallback: read LVGL version from lvgl/lv_version.h or lvgl/lvgl.h and increment the
8+
# highest existing v<major>.<minor>.* tag in this repo.
9+
#
10+
# Usage:
1011
# ./scripts/next_release_version.sh
1112
# ./scripts/next_release_version.sh --verbose
13+
# LV_BINDINGS_REF=a1971cd ./scripts/next_release_version.sh --verbose
1214
#
1315
# Environment:
14-
# LVCPYTHON_USE_REAL_LVGL_MAJOR=1 Use LVGL major from lvgl.h instead of test major 0
16+
# LV_BINDINGS_REF lv_bindings commit, tag, or branch (from sync CI)
17+
# LV_BINDINGS_REPO default https://github.com/PyDevices/lv_bindings.git
18+
# LVCPYTHON_USE_REAL_LVGL_MAJOR=1 Use LVGL major from version (else 0 for TestPyPI)
1519

1620
set -euo pipefail
1721

1822
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1923
SOURCE_REPO="$(cd "$SCRIPT_DIR/.." && pwd)"
24+
LV_BINDINGS_REPO="${LV_BINDINGS_REPO:-https://github.com/PyDevices/lv_bindings.git}"
2025

2126
VERBOSE=0
2227
while [[ $# -gt 0 ]]; do
@@ -26,7 +31,7 @@ while [[ $# -gt 0 ]]; do
2631
shift
2732
;;
2833
--help | -h)
29-
sed -n '2,18p' "$0" | sed 's/^# \?//'
34+
sed -n '2,22p' "$0" | sed 's/^# \?//'
3035
exit 0
3136
;;
3237
*)
@@ -36,64 +41,120 @@ while [[ $# -gt 0 ]]; do
3641
esac
3742
done
3843

39-
LVGL_H="$SOURCE_REPO/lvgl/lvgl.h"
40-
if [[ ! -f "$LVGL_H" ]]; then
41-
echo "Error: $LVGL_H not found (run: git submodule update --init lvgl)." >&2
42-
exit 1
43-
fi
44-
45-
read_lvgl_define() {
46-
local name=$1
47-
sed -n "s/^#define ${name}[[:space:]]\\+\\([0-9]\\+\\).*/\\1/p" "$LVGL_H" | head -1
44+
read_lvgl_version_from_tree() {
45+
local major minor patch version_file
46+
for version_file in "$SOURCE_REPO/lvgl/lv_version.h" "$SOURCE_REPO/lvgl/lvgl.h"; do
47+
if [[ ! -f "$version_file" ]]; then
48+
continue
49+
fi
50+
major=$(grep -E '^#define LVGL_VERSION_MAJOR' "$version_file" | awk '{print $3}')
51+
minor=$(grep -E '^#define LVGL_VERSION_MINOR' "$version_file" | awk '{print $3}')
52+
patch=$(grep -E '^#define LVGL_VERSION_PATCH' "$version_file" | awk '{print $3}')
53+
if [[ -n "$major" && -n "$minor" && -n "$patch" ]]; then
54+
LVGL_MAJOR=$major
55+
LVGL_MINOR=$minor
56+
LVGL_PATCH=$patch
57+
return 0
58+
fi
59+
done
60+
return 1
4861
}
4962

50-
LVGL_MAJOR=$(read_lvgl_define LVGL_VERSION_MAJOR)
51-
LVGL_MINOR=$(read_lvgl_define LVGL_VERSION_MINOR)
52-
LVGL_PATCH=$(read_lvgl_define LVGL_VERSION_PATCH)
63+
# Echo X.Y.Z when ref is or resolves to an lv_bindings release tag.
64+
resolve_lv_bindings_tag_version() {
65+
local ref="${LV_BINDINGS_REF:-}"
66+
[[ -z "$ref" ]] && return 1
5367

54-
if [[ -z "$LVGL_MAJOR" || -z "$LVGL_MINOR" ]]; then
55-
echo "Error: could not parse LVGL version from $LVGL_H" >&2
56-
exit 1
57-
fi
68+
ref="${ref#v}"
69+
if [[ "$ref" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
70+
echo "$ref"
71+
return 0
72+
fi
5873

59-
if [[ "${LVCPYTHON_USE_REAL_LVGL_MAJOR:-0}" == "1" ]]; then
60-
VERSION_MAJOR=$LVGL_MAJOR
61-
else
62-
VERSION_MAJOR=0
63-
fi
64-
VERSION_MINOR=$LVGL_MINOR
74+
local obj refname tag tag_sha
75+
while read -r obj refname; do
76+
[[ "$refname" != *'^{}' ]] && continue
77+
tag="${refname#refs/tags/}"
78+
tag="${tag%\^{}}"
79+
tag="${tag#v}"
80+
if [[ ! "$tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
81+
continue
82+
fi
83+
tag_sha="$obj"
84+
if [[ "$tag_sha" == "$ref" ]]; then
85+
echo "$tag"
86+
return 0
87+
fi
88+
done < <(git ls-remote --tags "$LV_BINDINGS_REPO")
89+
return 1
90+
}
91+
92+
apply_major_override() {
93+
local major=$1 minor=$2 patch=$3
94+
if [[ "${LVCPYTHON_USE_REAL_LVGL_MAJOR:-0}" == "1" ]]; then
95+
echo "${major}.${minor}.${patch}"
96+
else
97+
echo "0.${minor}.${patch}"
98+
fi
99+
}
65100

66-
cd "$SOURCE_REPO"
101+
VERSION_SOURCE=""
102+
BINDINGS_TAG_VERSION=""
103+
if BINDINGS_TAG_VERSION=$(resolve_lv_bindings_tag_version); then
104+
VERSION_SOURCE="lv_bindings tag v${BINDINGS_TAG_VERSION}"
105+
IFS=. read -r TAG_MAJOR TAG_MINOR TAG_PATCH <<< "$BINDINGS_TAG_VERSION"
106+
VERSION=$(apply_major_override "$TAG_MAJOR" "$TAG_MINOR" "$TAG_PATCH")
107+
read_lvgl_version_from_tree || true
108+
else
109+
if ! read_lvgl_version_from_tree; then
110+
echo "Error: could not read LVGL version from lvgl/lv_version.h or lvgl/lvgl.h" >&2
111+
echo "Set LV_BINDINGS_REF to an lv_bindings release tag (e.g. v9.2.0)." >&2
112+
exit 1
113+
fi
114+
VERSION_SOURCE="lvgl tree (${LVGL_MAJOR}.${LVGL_MINOR}.${LVGL_PATCH})"
115+
if [[ "${LVCPYTHON_USE_REAL_LVGL_MAJOR:-0}" == "1" ]]; then
116+
VERSION_MAJOR=$LVGL_MAJOR
117+
else
118+
VERSION_MAJOR=0
119+
fi
120+
VERSION_MINOR=$LVGL_MINOR
67121

68-
LAST_BINDING=-1
69-
while IFS= read -r tag; do
70-
[[ -z "$tag" ]] && continue
71-
tag="${tag#v}"
72-
if [[ "$tag" =~ ^${VERSION_MAJOR}\.${VERSION_MINOR}\.([0-9]+)$ ]]; then
73-
patch="${BASH_REMATCH[1]}"
74-
if (( patch > LAST_BINDING )); then
75-
LAST_BINDING=$patch
122+
cd "$SOURCE_REPO"
123+
LAST_BINDING=-1
124+
while IFS= read -r tag; do
125+
[[ -z "$tag" ]] && continue
126+
tag="${tag#v}"
127+
if [[ "$tag" =~ ^${VERSION_MAJOR}\.${VERSION_MINOR}\.([0-9]+)$ ]]; then
128+
patch="${BASH_REMATCH[1]}"
129+
if (( patch > LAST_BINDING )); then
130+
LAST_BINDING=$patch
131+
fi
76132
fi
77-
fi
78-
done < <(git tag -l "v${VERSION_MAJOR}.${VERSION_MINOR}.*")
133+
done < <(git tag -l "v${VERSION_MAJOR}.${VERSION_MINOR}.*")
79134

80-
NEXT_BINDING=$((LAST_BINDING + 1))
81-
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${NEXT_BINDING}"
135+
NEXT_BINDING=$((LAST_BINDING + 1))
136+
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${NEXT_BINDING}"
137+
fi
82138

83139
if [[ "$VERBOSE" -eq 1 ]]; then
84-
echo "LVGL source: ${LVGL_MAJOR}.${LVGL_MINOR}.${LVGL_PATCH} ($LVGL_H)"
85-
if [[ "$VERSION_MAJOR" == "$LVGL_MAJOR" ]]; then
86-
echo "Published major: ${VERSION_MAJOR} (from LVGL)"
87-
else
88-
echo "Published major: ${VERSION_MAJOR} (TestPyPI test override; LVGL major is ${LVGL_MAJOR})"
89-
fi
90-
echo "Published minor: ${VERSION_MINOR} (LVGL minor)"
91-
if (( LAST_BINDING >= 0 )); then
92-
echo "Last binding release: v${VERSION_MAJOR}.${VERSION_MINOR}.${LAST_BINDING}"
140+
echo "Version source: ${VERSION_SOURCE}"
141+
if [[ -n "${BINDINGS_TAG_VERSION:-}" ]]; then
142+
echo "lv_bindings release: v${BINDINGS_TAG_VERSION}"
143+
if [[ "${LVCPYTHON_USE_REAL_LVGL_MAJOR:-0}" == "1" ]]; then
144+
echo "Published version: ${VERSION} (LVGL major from lv_bindings tag)"
145+
else
146+
echo "Published version: ${VERSION} (major 0 TestPyPI override; lv_bindings v${BINDINGS_TAG_VERSION})"
147+
fi
93148
else
94-
echo "Last binding release: (none for v${VERSION_MAJOR}.${VERSION_MINOR}.*)"
149+
echo "LVGL source: ${LVGL_MAJOR}.${LVGL_MINOR}.${LVGL_PATCH}"
150+
if [[ "${LVCPYTHON_USE_REAL_LVGL_MAJOR:-0}" == "1" ]]; then
151+
echo "Published major: ${VERSION_MAJOR} (from LVGL)"
152+
else
153+
echo "Published major: 0 (TestPyPI test override; LVGL major is ${LVGL_MAJOR})"
154+
fi
155+
echo "Published minor: ${VERSION_MINOR} (LVGL minor)"
156+
echo "Next binding release: ${VERSION##*.}"
95157
fi
96-
echo "Next binding release: ${NEXT_BINDING}"
97158
echo "Next version: ${VERSION}"
98159
else
99160
echo "$VERSION"

‎scripts/publish_release_tag.sh‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ Create an annotated git tag for the next auto-computed release version:
2222
2323
<major>.<lvgl_minor>.<binding_release>
2424
25-
lvgl_minor — read from lv_bindings/lvgl/lvgl.h
26-
binding_release — highest existing v<major>.<minor>.* tag + 1 (0 if none)
25+
lvgl_minor — from the lv_bindings release tag when LV_BINDINGS_REF is set,
26+
else from lvgl/lv_version.h or lvgl/lvgl.h
27+
binding_release — patch from the lv_bindings tag, or highest v<major>.<minor>.* + 1
2728
major — 0 for TestPyPI testing (set LVCPYTHON_USE_REAL_LVGL_MAJOR=1
2829
to use LVGL_VERSION_MAJOR when ready for real releases)
2930

0 commit comments

Comments
 (0)