From b151f7fffd7c6d5f43115dc8d8459de62267774a Mon Sep 17 00:00:00 2001 From: 4831c0 <4831c0@noreply.localhost> Date: Tue, 26 Aug 2025 11:52:50 +0200 Subject: [PATCH] Jenkinsfile: Update f-droid version code --- Jenkinsfile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 8cfa643..8d840be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -84,6 +84,34 @@ pipeline { } } } + stage('Calculate Version Code') { + steps { + script { + sh '''#!/bin/sh + set -e + cd firka + + # Calculate version code based on git commits (same logic as build script) + COMMIT_COUNT=$(git rev-list --count HEAD) + BASE_BUILD_NUMBER=$((1000 + COMMIT_COUNT)) + + if [ "$BRANCH_NAME" = "main" ]; then + # For main branch, highest version code is BASE + 3000 (x64 build) + VERSION_CODE=$((BASE_BUILD_NUMBER + 3000)) + else + # For debug builds, version code is BASE + 0 + VERSION_CODE=$BASE_BUILD_NUMBER + fi + + echo "Calculated version code: $VERSION_CODE" + echo "$VERSION_CODE" > ../version_code.txt + ''' + + env.VERSION_CODE = readFile('version_code.txt').trim() + echo "Setting VERSION_CODE environment variable to: ${env.VERSION_CODE}" + } + } + } stage('Publish release artifacts') { when { branch 'main' @@ -116,6 +144,12 @@ pipeline { sshpass -e scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ "$SOURCE_FILE" "$SSH_USER@10.0.0.21:$REMOTE_PATH" + + # Update version code in F-Droid metadata + sshpass -e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + "$SSH_USER@10.0.0.21" \ + "sed -i 's/^CurrentVersionCode: .*/CurrentVersionCode: $VERSION_CODE/' /home/fdroid/firka-fdroid/metadata/app.firka.naplo.debug.yml" + sshpass -e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ "$SSH_USER@10.0.0.21" \ "cd /home/fdroid/firka-fdroid && /run/current-system/sw/bin/fdroid update" @@ -147,6 +181,11 @@ pipeline { fi done + # Update version code in F-Droid metadata for release + sshpass -e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + "$SSH_USER@10.0.0.21" \ + "sed -i 's/^CurrentVersionCode: .*/CurrentVersionCode: $VERSION_CODE/' /home/fdroid/firka-fdroid/metadata/app.firka.naplo.yml" + # Update F-Droid repository sshpass -e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ "$SSH_USER@10.0.0.21" \ @@ -162,6 +201,7 @@ pipeline { sh ''' rm firka/build/app/outputs/flutter-apk/app.firka.naplo_*.apk || true rm firka/build/app/outputs/flutter-apk/app-debug.apk || true + rm version_code.txt || true git checkout -- firka/pubspec.yaml ''' }