From 99ab6c07f768eb8f050398a543f7a3734c1cbfc0 Mon Sep 17 00:00:00 2001 From: zypherift Date: Mon, 8 Jun 2026 20:19:35 +0200 Subject: [PATCH] update jenkins to that it only builds with developer keys for public access --- Jenkinsfile | 163 +++++++--------------------------------------------- 1 file changed, 20 insertions(+), 143 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 23ea750d..1479ec82 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,167 +1,44 @@ pipeline { - agent { - label 'ubuntu' - } + agent any environment { PATH = "/home/jenkins/development/flutter/bin:${env.PATH}" } stages { - stage('Pre-build Cleanup') { + stage('Clone Submodules') { steps { - script { - sh '''#!/bin/sh - set -x - fusermount -u secrets || true - ''' - } + sh 'git submodule update --init --recursive' } } - - stage('Decrypt main keys') { - when { - branch 'main' - } + stage('Flutter Doctor') { steps { - script { - def userInput = input( - id: 'signaturePassword', - message: 'Please enter the signing key password:', - parameters: [ - password( - defaultValue: '', - description: 'Enter the signing key password', - name: 'password' - ) - ] - ) - env.PASSWORD = userInput.toString() - } - sh '''#!/bin/sh - echo \$PASSWORD | gocryptfs $HOME/android_secrets secrets/ -nonempty - ''' + sh 'flutter doctor' } } - - stage('Clone submodules') { + stage('Dependencies') { steps { - script { - sh 'git submodule update --init --recursive' - } + sh 'cd firka && flutter pub get' } } - - stage('Build firka') { + stage('Codegen') { steps { - sh 'bash -c "./tools/linux/build_apk.sh ' + env.BRANCH_NAME + '"' + sh 'cd firka && dart run scripts/codegen.dart' } } - - stage('Rename Release APKs') { - when { - branch 'main' - } + stage('Build') { steps { - script { - sh '''#!/bin/sh - set -e - - APK_DIR="firka/build/app/outputs/flutter-apk" - - # Find all release APKs and rename them - for apk_file in $APK_DIR/app-*-release.apk; do - if [ -f "$apk_file" ]; then - # Extract ABI from filename (e.g., app-arm64-v8a-release.apk -> arm64-v8a) - basename_file=$(basename "$apk_file") - abi=$(echo "$basename_file" | sed 's/app-//; s/-release.apk//') - - # Create new filename - new_name="app.firka.naplo_${abi}.apk" - new_path="$APK_DIR/$new_name" - - echo "Renaming $apk_file to $new_path" - mv "$apk_file" "$new_path" - fi - done - - ls -la $APK_DIR/app.firka.naplo_*.apk || echo "APK files not found" - ''' - } + sh 'cd firka && flutter build apk --debug' } } - - stage('Calculate Version Code') { + stage('Archive') { 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=$((1300 + 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 debug artifacts') { - when { - not { - branch 'main' - } - } - steps { - archiveArtifacts artifacts: 'firka/build/app/outputs/flutter-apk/app-debug.apk', fingerprint: true - } - } - - stage('Publish release AABs artifacts') { - when { - branch 'main' - } - steps { - archiveArtifacts artifacts: 'firka/build/app/outputs/bundle/release/*.aab', fingerprint: true - sh 'rm firka/build/app/outputs/bundle/release/*.aab' - } - } - - stage('Publish release APKs artifacts') { - when { - branch 'main' - } - steps { - archiveArtifacts artifacts: 'firka/build/app/outputs/flutter-apk/app.firka.naplo_*.apk', fingerprint: true - sh 'rm firka/build/app/outputs/flutter-apk/app.firka.naplo_*.apk' - } - } - - stage('Post Cleanup') { - steps { - script { - sh ''' - rm firka/build/app/outputs/bundle/release/*.aab || true - 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 || true - git checkout -- firka/lib/helpers/firka_bundle.dart || true - ''' - } + archiveArtifacts artifacts: 'firka/build/app/outputs/flutter-apk/app-debug.apk', + fingerprint: true } } } -} + post { + always { + deleteDir() + } + } +} \ No newline at end of file