chore(release.yaml): update workflow to set Flutter app version from Git tag
All checks were successful
Build and Release to F-Droid / build-and-deploy (push) Successful in 12m0s

- Adds script to parse Git tag, calculate semantic version and numeric build code
- Updates `pubspec.yaml` with version and build code during release
This commit is contained in:
2026-03-17 09:39:50 +01:00
parent d220dbe5ce
commit fa778a238a

View File

@@ -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: