ci: add version consistency check and fully automate release pipeline
- New tools/check_versions.sh: verifies version.txt, version.h, SylDaVersions.kt match - release.yml: 'Verify version consistency' step after build, aborts release if mismatch - ci.yml: same check after debug APK build - scripts/release.sh: now runs full pipeline (pio run -> copy firmware -> gradle -> check) and refuses dirty working tree - Untrack version.h, SylDaVersions.kt, release/ — always regenerated fresh from version.txt Prevents the v1.1 bug where stale generated files caused version mismatch and infinite re-flash loop.
This commit is contained in:
parent
1d94f088fd
commit
6a07505d02
14 changed files with 123 additions and 20 deletions
|
|
@ -3,9 +3,11 @@ set -euo pipefail
|
|||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
log() { echo -e "${GREEN}[release]${NC} $1"; }
|
||||
warn() { echo -e "${YELLOW}[release]${NC} $1"; }
|
||||
err() { echo -e "${RED}[release]${NC} $1" >&2; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
|
@ -14,6 +16,8 @@ ANDROID_DIR="$PROJECT_DIR/android"
|
|||
APP_BUILD_GRADLE="$ANDROID_DIR/app/build.gradle"
|
||||
SIGNING_PROPS="$ANDROID_DIR/signing.properties"
|
||||
FORGEJO_URL="https://git.eddydevink.nl/api/v1/repos/eddy/Project_SylDa"
|
||||
CHECK_VERSIONS="$PROJECT_DIR/tools/check_versions.sh"
|
||||
COPY_FIRMWARE="$PROJECT_DIR/tools/copy_firmware.sh"
|
||||
FIRMWARE_DIR="$ANDROID_DIR/app/src/main/assets/firmware"
|
||||
|
||||
VERSION=$(grep -oP 'versionName\s+"\K[^"]+' "$APP_BUILD_GRADLE")
|
||||
|
|
@ -21,20 +25,43 @@ TAG="v$VERSION"
|
|||
RELEASE_DIR="$PROJECT_DIR/release/$TAG"
|
||||
|
||||
log "Release v$VERSION (tag $TAG)"
|
||||
log "========================================="
|
||||
|
||||
if [ ! -f "$SIGNING_PROPS" ]; then
|
||||
err "signing.properties niet gevonden op $SIGNING_PROPS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Clean..."
|
||||
# ── Build firmware ────────────────────────────────────────────
|
||||
log "Build firmware (pio run)..."
|
||||
cd "$PROJECT_DIR"
|
||||
pio run
|
||||
log "Firmware built."
|
||||
|
||||
log "Copy firmware to Android assets..."
|
||||
bash "$COPY_FIRMWARE"
|
||||
log "Firmware copied."
|
||||
|
||||
# ── Build Android ─────────────────────────────────────────────
|
||||
log "Clean Gradle..."
|
||||
cd "$ANDROID_DIR"
|
||||
./gradlew clean
|
||||
|
||||
log "Build APK + AAB..."
|
||||
log "Build release APK + AAB..."
|
||||
./gradlew assembleRelease bundleRelease
|
||||
log "Android built."
|
||||
|
||||
# ── Verify version consistency ────────────────────────────────
|
||||
log "Verify version consistency..."
|
||||
if ! bash "$CHECK_VERSIONS"; then
|
||||
err "Version mismatch detected — aborting release."
|
||||
err "version.txt is source of truth. Both version.h and SylDaVersions.kt are regenerated above."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── Gather artifacts ──────────────────────────────────────────
|
||||
log "Verzamel artefacten in $RELEASE_DIR"
|
||||
rm -rf "$RELEASE_DIR"
|
||||
mkdir -p "$RELEASE_DIR"
|
||||
|
||||
cp "$ANDROID_DIR/app/build/outputs/apk/release/app-release.apk" "$RELEASE_DIR/"
|
||||
|
|
@ -49,7 +76,17 @@ cd "$RELEASE_DIR"
|
|||
sha256sum * > checksums.txt
|
||||
cat checksums.txt
|
||||
|
||||
# ── Git tag ───────────────────────────────────────────────────
|
||||
cd "$PROJECT_DIR"
|
||||
if git diff --quiet && git diff --cached --quiet; then
|
||||
log "Working tree clean."
|
||||
else
|
||||
warn "Working tree has uncommitted changes. Commit before releasing."
|
||||
warn "Uncommitted files:"
|
||||
git status --short
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||
log "Tag $TAG bestaat al, skip git tag."
|
||||
else
|
||||
|
|
@ -58,6 +95,7 @@ else
|
|||
git push origin "$TAG"
|
||||
fi
|
||||
|
||||
# ── Create Forgejo release ────────────────────────────────────
|
||||
log "Forgejo release aanmaken..."
|
||||
TOKEN_FILE="$HOME/.config/sylda/forgejo-token"
|
||||
if [ ! -f "$TOKEN_FILE" ]; then
|
||||
|
|
@ -91,4 +129,6 @@ for f in *; do
|
|||
--data-binary "@$f" > /dev/null
|
||||
done
|
||||
|
||||
log "========================================="
|
||||
log "Klaar! Release $TAG staat op Forgejo."
|
||||
log " $FORGEJO_URL/releases/tag/$TAG" | sed 's|/api/v1/repos/||'
|
||||
Loading…
Reference in a new issue