From fa778a238a1e386e2ab5f2ef63bc8a0a031c0175 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Tue, 17 Mar 2026 09:39:50 +0100 Subject: [PATCH] chore(release.yaml): update workflow to set Flutter app version from Git tag - Adds script to parse Git tag, calculate semantic version and numeric build code - Updates `pubspec.yaml` with version and build code during release --- .gitea/workflows/release.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 9eba674..d09cd52 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -86,6 +86,30 @@ jobs: - name: Install dependencies run: flutter pub get + - name: Set version from git tag + run: | + set -e + RAW_TAG="${GITHUB_REF_NAME:-${GITHUB_REF##*/}}" + + # Strip leading 'v' if present (v1.2.3 -> 1.2.3) + VERSION="${RAW_TAG#v}" + + # Extract a numeric build number for versionCode. + # Converts semver x.y.z into a single integer: x*10000 + y*100 + z + # e.g. 1.1.1 -> 10101, 2.3.15 -> 20315 + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f2) + PATCH=$(echo "$VERSION" | cut -d. -f3) + MAJOR=${MAJOR:-0}; MINOR=${MINOR:-0}; PATCH=${PATCH:-0} + VERSION_CODE=$(( MAJOR * 10000 + MINOR * 100 + PATCH )) + + echo "Version: $VERSION, VersionCode: $VERSION_CODE" + + # Update pubspec.yaml: replace the version line + sed -i "s/^version: .*/version: ${VERSION}+${VERSION_CODE}/" pubspec.yaml + + grep '^version:' pubspec.yaml + # ADD THIS NEW STEP - name: Setup Android Keystore env: