|
| 1 | +#!/usr/bin/env groovy |
| 2 | + |
| 3 | + |
| 4 | +/* Options section can't access functions in objects. */ |
| 5 | +def isPRBuild = utils.isPRBuild() |
| 6 | +def isNightlyBuild = utils.isNightlyBuild() |
| 7 | + |
| 8 | +pipeline { |
| 9 | + |
| 10 | + agent { label 'macos && arm64 && nix-2.24 && xcode-16.2' } |
| 11 | + |
| 12 | + parameters { |
| 13 | + booleanParam( |
| 14 | + name: 'RELEASE', |
| 15 | + description: 'Decides whether release credentials are used.', |
| 16 | + defaultValue: params.RELEASE ?: false |
| 17 | + ) |
| 18 | + choice( |
| 19 | + name: 'VERBOSE', |
| 20 | + description: 'Level of verbosity based on nimbus-build-system setup.', |
| 21 | + choices: ['0','1','2','3'] |
| 22 | + ) |
| 23 | + } |
| 24 | + |
| 25 | + options { |
| 26 | + timestamps() |
| 27 | + /* Prevent Jenkins jobs from running forever */ |
| 28 | + timeout(time: 45, unit: 'MINUTES') |
| 29 | + /* manage how many builds we keep */ |
| 30 | + buildDiscarder(logRotator( |
| 31 | + numToKeepStr: '10', |
| 32 | + daysToKeepStr: '30', |
| 33 | + artifactNumToKeepStr: '3', |
| 34 | + )) |
| 35 | + /* Allows combined build to copy */ |
| 36 | + copyArtifactPermission('/status-desktop/*') |
| 37 | + /* Abort old PR builds. */ |
| 38 | + disableConcurrentBuilds(abortPrevious: isPRBuild) |
| 39 | + disableRestartFromStage() |
| 40 | + } |
| 41 | + |
| 42 | + environment { |
| 43 | + GOCACHE = "${env.WORKSPACE_TMP}/go-cache" |
| 44 | + GOMODCACHE = "${env.WORKSPACE_TMP}/go-mod-cache" |
| 45 | + GOTMPDIR = "${env.WORKSPACE_TMP}" |
| 46 | + PLATFORM = "ios/${getArch()}" |
| 47 | + /* Improve make performance */ |
| 48 | + MAKEFLAGS = "-j4 V=${params.VERBOSE}" |
| 49 | + QT_VERSION="6.9.2" |
| 50 | + QMAKE = "/Users/admin/${QT_VERSION}/ios/bin/qmake" |
| 51 | + QT_HOST_PATH = "/Users/admin/${QT_VERSION}/macos" |
| 52 | + /* QMAKE = sh(script: "which qmake", returnStdout: true).trim() */ |
| 53 | + QTDIR = sh(script:"${env.QMAKE} -query QT_INSTALL_PREFIX", returnStdout: true).trim() |
| 54 | + /* Enforce Go version installed infra-role-golang. */ |
| 55 | + /* to fix missing rcc, since QT6 rcc is located at ${QTDIR}/libexec/rcc */ |
| 56 | + PATH = "${env.QTDIR}/bin:${env.QTDIR}/libexec:${env.HOME}/go/bin:/usr/local/go/bin:${env.PATH}" |
| 57 | + /* prevent sharing cache dir across different jobs */ |
| 58 | + GO_GENERATE_FAST_DIR = "${env.WORKSPACE_TMP}/go-generate-fast" |
| 59 | + XDG_CACHE_HOME = "${env.WORKSPACE_TMP}/.cache" |
| 60 | + /* sets App Version in Settings */ |
| 61 | + VERSION = sh(script: "./scripts/version.sh", returnStdout: true).trim() |
| 62 | + /* Control output the filename */ |
| 63 | + APP_TYPE = "${utils.getAppType()}" |
| 64 | + /* iOS build configuration */ |
| 65 | + IPHONE_SDK = "iphoneos" |
| 66 | + ARCH = "x86_64" |
| 67 | + /* iOS app paths */ |
| 68 | + STATUS_IOS_APP_ARTIFACT = "pkg/${utils.pkgFilename(ext: 'app.zip', arch: getArch(), version: env.VERSION, type: env.APP_TYPE)}" |
| 69 | + STATUS_IOS_APP = "${WORKSPACE}/mobile/bin/ios/qt6/Status-tablet.app" |
| 70 | + } |
| 71 | + |
| 72 | + stages { |
| 73 | + |
| 74 | + stage('Fetch submodules') { |
| 75 | + steps { |
| 76 | + sh 'git submodule update --init --recursive' |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + stage('status-go') { |
| 81 | + steps { |
| 82 | + sh 'make status-go' |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + stage('Build iOS App') { |
| 87 | + steps { |
| 88 | + sh 'make mobile-build' |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + stage('Package iOS App') { |
| 93 | + steps { |
| 94 | + sh 'mkdir -p pkg' |
| 95 | + sh "cd mobile/bin/ios/qt6 && zip -r ${env.WORKSPACE}/${env.STATUS_IOS_APP_ARTIFACT} Status-tablet.app" |
| 96 | + sh "ls -la ${env.STATUS_IOS_APP_ARTIFACT}" |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + stage('Parallel Upload') { |
| 101 | + parallel { |
| 102 | + stage('Upload') { |
| 103 | + steps { |
| 104 | + script { |
| 105 | + env.PKG_URL = s5cmd.upload(env.STATUS_IOS_APP_ARTIFACT) |
| 106 | + jenkins.setBuildDesc(APP: env.PKG_URL) |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + stage('Archive') { |
| 111 | + steps { |
| 112 | + archiveArtifacts env.STATUS_IOS_APP_ARTIFACT |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + post { |
| 120 | + success { script { github.notifyPR(true) } } |
| 121 | + failure { script { github.notifyPR(false) } } |
| 122 | + cleanup { sh './scripts/clean-git.sh' } |
| 123 | + } |
| 124 | +} |
| 125 | + |
| 126 | +def getArch() { |
| 127 | + def tokens = Thread.currentThread().getName().split('/') |
| 128 | + for (def arch in ['x86_64', 'aarch64']) { |
| 129 | + if (tokens.contains(arch)) { return arch } |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +/* We extract the name of the job from currentThread because |
| 134 | + * before an agent is picked env is not available. */ |
| 135 | +def getJobPathTokens() { |
| 136 | + return Thread.currentThread().getName().split('/') |
| 137 | +} |
0 commit comments