forked from tutao/tutanota
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Webapp.Jenkinsfile
101 lines (96 loc) · 2.98 KB
/
Webapp.Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
pipeline {
environment {
PATH="/opt/node-v16.3.0-linux-x64/bin:${env.PATH}"
VERSION = sh(returnStdout: true, script: "${NODE_PATH}/node -p -e \"require('./package.json').version\" | tr -d \"\n\"")
}
options {
preserveStashes()
}
parameters {
booleanParam(
name: 'RELEASE',
defaultValue: false,
description: "Prepare a release version (doesn't publish to production, this is done manually). Also publishes NPM modules"
)
}
agent {
label 'master'
}
stages {
stage('Build') {
agent {
label 'linux'
}
steps {
sh 'npm ci'
sh 'npm run build-packages'
sh 'node webapp.js release'
// excluding web-specific and mobile specific parts which we don't need in desktop
stash includes: 'build/dist/**', excludes: '**/app.html, **/desktop.html, **/index-app.js, **/index-desktop.js', name: 'webapp_built'
// Bundle size stats
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build',
reportFiles: 'stats.html',
reportName: 'bundle stats'
]
// Bundle dependencies graph
sh 'dot -Tsvg build/bundles.dot > build/bundles.svg'
sh """echo '<!doctype html><html><body><img src="./bundles.svg" /></body></html>' > build/bundles.html"""
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build',
reportFiles: 'bundles.html',
reportName: 'bundle dependencies'
]
}
}
stage('Publish') {
environment {
VERSION = sh(returnStdout: true, script: "${NODE_PATH}/node -p -e \"require('./package.json').version\" | tr -d \"\n\"")
}
when {
expression { params.RELEASE }
}
agent {
label 'linux'
}
steps {
sh 'echo Publishing version $VERSION'
sh 'npm ci'
sh 'rm -rf ./build/*'
unstash 'webapp_built'
sh 'node buildSrc/publish.js webapp'
catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS', message: 'Failed to create github release page') {
withCredentials([string(credentialsId: 'github-access-token', variable: 'GITHUB_TOKEN')]) {
sh '''node buildSrc/releaseNotes.js --releaseName ${VERSION} \
--milestone ${VERSION} \
--tag tutanota-release-${VERSION} \
--platform all'''
}
}
}
}
stage('Publish npm modules') {
when {
expression { params.RELEASE }
}
agent {
label 'linux'
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "npm ci && npm run build-packages"
// .npmrc expects $NPM_TOKEN
withCredentials([string(credentialsId: 'npm-token',variable: 'NPM_TOKEN')]) {
sh "npm --workspaces publish --access public"
}
}
}
}
}
}