Skip to content

Commit

Permalink
Move upload to stores and release notes creation to separate Jenkinsfile
Browse files Browse the repository at this point in the history
Part of #6830

Co-authored-by: paw <paw-hub@users.noreply.github.com>
  • Loading branch information
hrb-hub and paw-hub committed Nov 14, 2024
1 parent 4d25b43 commit a750f3d
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 145 deletions.
28 changes: 16 additions & 12 deletions app-ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
default_platform(:ios)

platform :ios do
desc "Push a new prod release to AppStore"
lane :appstore_prod do |options|
desc "Build a new Mail prod release with AppStore configuration"
lane :build_mail_prod do |options|
match(
app_identifier: ["de.tutao.tutanota", "de.tutao.tutanota.TutanotaShareExtension", "de.tutao.tutanota.TutanotaNotificationExtension"],
type: "appstore",
Expand All @@ -37,18 +37,22 @@ platform :ios do
include_symbols: true,
verbose: true
)
if options[:submit]
upload_to_app_store(
skip_screenshots: true,
submit_for_review: false,
precheck_include_in_app_purchases: false,
# must use force as long as we don't automatically create html previews
force: true,
api_key_path: ENV["API_KEY_JSON_FILE_PATH"]
)
end
end

desc "Publish a Mail artifact to AppStore"
lane :publish_mail_prod do |options|
sh 'echo "Uploading mail artifact ' + options[:file] + '"'

upload_to_app_store(
skip_screenshots: true,
submit_for_review: false,
precheck_include_in_app_purchases: false,
# must use force as long as we don't automatically create html previews
force: true,
api_key_path: ENV["API_KEY_JSON_FILE_PATH"]
)
end

desc "Build a new prod release for ad-hoc"
lane :adhoc_prod do |options|
match(
Expand Down
65 changes: 0 additions & 65 deletions ci/Android.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pipeline {
PATH = "${env.NODE_PATH}:${env.PATH}:/home/jenkins/emsdk/upstream/bin/:/home/jenkins/emsdk/:/home/jenkins/emsdk/upstream/emscripten"
ANDROID_SDK_ROOT = "/opt/android-sdk-linux"
ANDROID_HOME = "/opt/android-sdk-linux"
GITHUB_RELEASE_PAGE = "https://github.com/tutao/tutanota/releases/tag/tutanota-android-release-${VERSION}"
}

agent {
Expand All @@ -23,11 +22,6 @@ pipeline {
"Uploads both to Nexus and creates a new release on google play, " +
"which must be manually published from play.google.com/console"
)
persistentText(
name: "releaseNotes",
defaultValue: "",
description: "release notes for this build"
)
}

stages {
Expand Down Expand Up @@ -124,26 +118,6 @@ pipeline {
assetFilePath: "${WORKSPACE}/build/app-android/tutanota-app-tutao-releaseTest-${VERSION}.apk",
fileExtension: 'apk'
)

catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS', message: 'Failed to upload android test app to Play Store') {
// This doesn't publish to the main app on play store,
// instead it gets published to the hidden "tutanota-test" app
// this happens because the AppId is set to de.tutao.tutanota.test by the android build
// and play store knows which app to publish just based on the id
androidApkUpload(
googleCredentialsId: 'android-app-publisher-credentials',
apkFilesPattern: "build/app-android/tutanota-app-tutao-releaseTest-${VERSION}.apk",
trackName: 'internal',
rolloutPercentage: '100%',
recentChangeList: [
[
language: "en-US",
text : "see: ${GITHUB_RELEASE_PAGE}"
]
]
) // androidApkUpload
} // catchError

}
}
} // stage testing
Expand All @@ -163,49 +137,10 @@ pipeline {
assetFilePath: "${WORKSPACE}/${filePath}",
fileExtension: 'apk'
)

androidApkUpload(
googleCredentialsId: 'android-app-publisher-credentials',
apkFilesPattern: "${filePath}",
trackName: 'production',
// Don't publish the app to users directly
// It will require manual intervention at play.google.com/console
rolloutPercentage: '0%',
recentChangeList: [
[
language: "en-US",
text : "see: ${GITHUB_RELEASE_PAGE}"
]
]
)
}
}
} // stage production
}
}
stage('Tag and publish release page') {
when {
expression { return params.RELEASE }
}
steps {
// Needed to upload it
unstash 'apk-production'

script {
def filePath = "build/app-android/tutanota-app-tutao-release-${VERSION}.apk"

writeFile file: "notes.txt", text: params.releaseNotes
catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS', message: 'Failed to create github release page for android') {
withCredentials([string(credentialsId: 'github-access-token', variable: 'GITHUB_TOKEN')]) {
sh """node buildSrc/createReleaseDraft.js --name '${VERSION} (Android)' \
--tag 'tutanota-android-release-${VERSION}' \
--uploadFile '${WORKSPACE}/${filePath}' \
--notes notes.txt"""
} // withCredentials
} // catchError
sh "rm notes.txt"
} // script
}
}
}
}
69 changes: 9 additions & 60 deletions ci/Ios.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pipeline {
environment {
NODE_MAC_PATH = "/usr/local/opt/node@20/bin/"
VERSION = sh(returnStdout: true, script: "${env.NODE_PATH}/node -p -e \"require('./package.json').version\" | tr -d \"\n\"")
RELEASE_NOTES_PATH = "app-ios/fastlane/metadata/default/release_notes.txt"
}

agent {
Expand All @@ -24,11 +23,6 @@ pipeline {
name: 'STAGING',
defaultValue: true
)
persistentText(
name: "releaseNotes",
defaultValue: "",
description: "release notes for this build"
)
}

stages {
Expand Down Expand Up @@ -99,10 +93,11 @@ pipeline {
generateXCodeProjects()
util.runFastlane("de.tutao.tutanota", "adhoc_prod")
if (params.RELEASE) {
writeReleaseNotesForAppStore()
util.runFastlane("de.tutao.tutanota", "appstore_prod submit:true")
util.runFastlane("de.tutao.tutanota", "build_mail_prod")
stash includes: "app-ios/releases/tutanota-${VERSION}.ipa", name: 'ipa-production'
} else {
stash includes: "app-ios/releases/tutanota-${VERSION}-adhoc.ipa", name: 'ipa-production'
}
stash includes: "app-ios/releases/tutanota-${VERSION}-adhoc.ipa", name: 'ipa-production'
}
}
}
Expand Down Expand Up @@ -131,42 +126,16 @@ pipeline {
if (params.PROD) {
unstash 'ipa-production'
catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS', message: 'There was an error when uploading to Nexus') {
publishToNexus("ios", "tutanota-${VERSION}-adhoc.ipa")
if (params.RELEASE) {
publishToNexus("ios", "tutanota-${VERSION}.ipa")
} else {
publishToNexus("ios", "tutanota-${VERSION}-adhoc.ipa")
}
}
}
}
}
}

stage('Tag and create github release page') {
environment {
PATH = "${env.NODE_PATH}:${env.PATH}"
}
when {
expression { return params.RELEASE }
}
agent {
label 'linux'
}
steps {
script {

catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS', message: 'Failed to create github release page for ios') {
def tag = "tutanota-ios-release-${VERSION}"
// need to run npm ci to install dependencies of releaseNotes.js
sh "npm ci"

writeFile file: "notes.txt", text: params.releaseNotes
withCredentials([string(credentialsId: 'github-access-token', variable: 'GITHUB_TOKEN')]) {
sh """node buildSrc/createReleaseDraft.js --name '${VERSION} (iOS)' \
--tag 'tutanota-ios-release-${VERSION}' \
--notes notes.txt"""
} // withCredentials
sh "rm notes.txt"
} // catchError
}
}
}
}
}

Expand Down Expand Up @@ -209,26 +178,6 @@ void generateCalendarProject() {
generateXCodeProject("app-ios", "calendar-project")
}


void writeReleaseNotesForAppStore() {
script {
catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS', message: 'Failed to create github release notes for ios') {
// need to run npm ci to install dependencies of releaseNotes.js
sh "npm ci"
writeFile file: "notes.txt", text: params.releaseNotes
withCredentials([string(credentialsId: 'github-access-token', variable: 'GITHUB_TOKEN')]) {
sh """node buildSrc/createReleaseDraft.js --name '${VERSION} (iOS)' \
--tag 'tutanota-ios-release-${VERSION}'\
--notes notes.txt \
--toFile ${RELEASE_NOTES_PATH}"""
}
sh "rm notes.txt"
}
}

sh "echo Created release notes for fastlane ${RELEASE_NOTES_PATH}"
}

void publishToNexus(String artifactId, String ipaFileName) {
def util = load "ci/jenkins-lib/util.groovy"
util.publishToNexus(groupId: "app",
Expand Down
4 changes: 2 additions & 2 deletions ci/Publish-CalendarMobileArtifacts.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ pipeline {
}
steps {
script {
catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS', message: 'Failed to upload android app to GitHub') {
catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS', message: 'Failed to upload iOS app to GitHub') {
writeReleaseNotes("ios", "iOS", "${env.VERSION}", "")
}
} // script
} // steps
} // stage Android App
} // stage iOS App
}
}
stage("Publishing Artifacts to Stores") {
Expand Down
Loading

0 comments on commit a750f3d

Please sign in to comment.