2018-11-08 10:13:40 +00:00
|
|
|
import groovy.json.JsonBuilder
|
|
|
|
|
2019-05-10 15:33:54 +00:00
|
|
|
/* Libraries -----------------------------------------------------------------*/
|
|
|
|
|
2019-02-05 09:35:14 +00:00
|
|
|
ci = load 'ci/jenkins.groovy'
|
2019-05-10 15:33:54 +00:00
|
|
|
nix = load 'ci/nix.groovy'
|
2019-02-05 09:35:14 +00:00
|
|
|
utils = load 'ci/utils.groovy'
|
2018-12-13 13:22:36 +00:00
|
|
|
|
2019-02-05 09:35:14 +00:00
|
|
|
/* Small Helpers -------------------------------------------------------------*/
|
2018-12-11 14:27:21 +00:00
|
|
|
|
|
|
|
def pkgUrl(build) {
|
2019-02-05 09:35:14 +00:00
|
|
|
return utils.getEnv(build, 'PKG_URL')
|
2018-10-02 20:40:36 +00:00
|
|
|
}
|
|
|
|
|
2019-02-22 20:35:22 +00:00
|
|
|
def updateBucketJSON(urls, fileName) {
|
2018-12-11 14:27:21 +00:00
|
|
|
/* latest.json has slightly different key names */
|
2019-02-22 20:35:22 +00:00
|
|
|
def content = [
|
|
|
|
DIAWI: urls.Diawi,
|
2018-12-11 14:27:21 +00:00
|
|
|
APK: urls.Apk, IOS: urls.iOS,
|
|
|
|
APP: urls.App, MAC: urls.Mac,
|
|
|
|
WIN: urls.Win, SHA: urls.SHA
|
|
|
|
]
|
2019-02-22 20:35:22 +00:00
|
|
|
def filePath = "${pwd()}/pkg/${fileName}"
|
2018-11-08 10:13:40 +00:00
|
|
|
/* it might not exist */
|
|
|
|
sh 'mkdir -p pkg'
|
2019-02-22 20:35:22 +00:00
|
|
|
def contentJson = new JsonBuilder(content).toPrettyString()
|
|
|
|
println "${fileName}:\n${contentJson}"
|
|
|
|
new File(filePath).write(contentJson)
|
2019-10-16 06:23:53 +00:00
|
|
|
return uploadArtifact(filePath)
|
2018-09-25 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
2019-03-22 13:24:58 +00:00
|
|
|
def prep(type = 'nightly') {
|
2019-04-11 11:29:37 +00:00
|
|
|
/* build/downloads all nix deps in advance */
|
2019-05-10 15:33:54 +00:00
|
|
|
nix.prepEnv()
|
2019-04-11 11:29:37 +00:00
|
|
|
/* rebase unless this is a release build */
|
2019-03-22 13:24:58 +00:00
|
|
|
utils.doGitRebase()
|
|
|
|
/* ensure that we start from a known state */
|
|
|
|
sh 'make clean'
|
2019-06-04 16:50:29 +00:00
|
|
|
/* Disable git hooks in CI, it's not useful, takes time and creates weird errors at times
|
|
|
|
(e.g. bin/sh: 2: /etc/ssl/certs/ca-certificates.crt: Permission denied) */
|
|
|
|
sh 'make disable-githooks'
|
|
|
|
|
2019-04-11 11:29:37 +00:00
|
|
|
/* pick right .env and update from params */
|
|
|
|
utils.updateEnv(type)
|
|
|
|
|
2019-11-29 10:20:08 +00:00
|
|
|
if (['android', 'ios'].contains(env.TARGET)) {
|
2019-03-22 13:24:58 +00:00
|
|
|
/* Run at start to void mismatched numbers */
|
|
|
|
utils.genBuildNumber()
|
2019-04-03 20:12:31 +00:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:20:08 +00:00
|
|
|
nix.shell('watchman watch-del-all', attr: 'shells.watchman')
|
2019-06-04 16:50:29 +00:00
|
|
|
|
2019-11-29 10:20:08 +00:00
|
|
|
if (env.TARGET == 'ios') {
|
2019-03-22 13:24:58 +00:00
|
|
|
/* install ruby dependencies */
|
2019-06-04 16:50:29 +00:00
|
|
|
nix.shell(
|
|
|
|
'bundle install --gemfile=fastlane/Gemfile --quiet',
|
2019-11-29 10:20:08 +00:00
|
|
|
attr: 'shells.fastlane')
|
2019-03-22 13:24:58 +00:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:20:08 +00:00
|
|
|
if (['macos', 'linux', 'windows'].contains(env.TARGET)) {
|
2019-06-04 16:50:29 +00:00
|
|
|
/* node deps, pods, and status-go download */
|
2019-10-09 15:37:58 +00:00
|
|
|
nix.shell('scripts/prepare-for-desktop-platform.sh', pure: false)
|
2019-03-22 13:24:58 +00:00
|
|
|
}
|
2019-11-29 10:20:08 +00:00
|
|
|
/* run script in the nix shell so that node_modules gets instantiated before attempting the copies */
|
|
|
|
nix.shell('scripts/copy-translations.sh chmod', attr: "shells.${env.TARGET}")
|
2019-03-22 13:24:58 +00:00
|
|
|
}
|
|
|
|
|
2019-10-16 06:23:53 +00:00
|
|
|
def uploadArtifact(path) {
|
|
|
|
/* defaults for upload */
|
|
|
|
def domain = 'ams3.digitaloceanspaces.com'
|
|
|
|
def bucket = 'status-im'
|
|
|
|
/* There's so many PR builds we need a separate bucket */
|
|
|
|
if (utils.getBuildType() == 'pr') {
|
|
|
|
bucket = 'status-im-prs'
|
|
|
|
}
|
|
|
|
/* WARNING: s3cmd can't guess APK MIME content-type */
|
|
|
|
def customOpts = ''
|
|
|
|
if (path.endsWith('apk')) {
|
|
|
|
customOpts += "--mime-type='application/vnd.android.package-archive'"
|
|
|
|
}
|
|
|
|
/* We also need credentials for the upload */
|
|
|
|
withCredentials([usernamePassword(
|
|
|
|
credentialsId: 'digital-ocean-access-keys',
|
|
|
|
usernameVariable: 'DO_ACCESS_KEY',
|
|
|
|
passwordVariable: 'DO_SECRET_KEY'
|
|
|
|
)]) {
|
2019-10-18 09:10:44 +00:00
|
|
|
sh("""
|
2019-10-09 15:37:58 +00:00
|
|
|
s3cmd ${customOpts} \\
|
|
|
|
--acl-public \\
|
2019-10-16 06:23:53 +00:00
|
|
|
--host="${domain}" \\
|
|
|
|
--host-bucket="%(bucket)s.${domain}" \\
|
|
|
|
--access_key=${DO_ACCESS_KEY} \\
|
|
|
|
--secret_key=${DO_SECRET_KEY} \\
|
|
|
|
put ${path} s3://${bucket}/
|
2019-10-09 15:37:58 +00:00
|
|
|
""")
|
2019-10-16 06:23:53 +00:00
|
|
|
}
|
|
|
|
return "https://${bucket}.${domain}/${utils.getFilename(path)}"
|
|
|
|
}
|
|
|
|
|
2018-08-14 18:09:52 +00:00
|
|
|
return this
|