fix version in release build

This commit is contained in:
Roman Volosovskyi 2018-04-17 11:09:12 +01:00
parent 05379747da
commit 924d16dc64
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
4 changed files with 60 additions and 37 deletions

View File

@ -21,6 +21,7 @@ node ('macos1'){
def apkUrl = '' def apkUrl = ''
def ipaUrl = '' def ipaUrl = ''
def testPassed = true def testPassed = true
def version
load "$HOME/env.groovy" load "$HOME/env.groovy"
@ -29,6 +30,13 @@ node ('macos1'){
stage('Git & Dependencies') { stage('Git & Dependencies') {
slackSend color: 'good', message: BRANCH_NAME + ' build started. ' + env.BUILD_URL slackSend color: 'good', message: BRANCH_NAME + ' build started. ' + env.BUILD_URL
if (!BRANCH_NAME.startsWith("release/")){
error "Wrong branch name format: " + BRANCH_NAME + ", but it should be `release/version`"
}
version = BRANCH_NAME.substring(8)
sh 'echo "' + version + '" > .version'
checkout scm checkout scm
sh 'git fetch --tags' sh 'git fetch --tags'
@ -51,10 +59,13 @@ node ('macos1'){
} }
stage('Build (Android)') { stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease' sh 'cd android && ./gradlew assembleRelease -PreleaseVersion=' + version
} }
stage('Build (iOS)') { stage('Build (iOS)') {
def build_no = sh(returnStdout: true, script: 'git rev-list --count HEAD').trim()
sh ('plutil -replace CFBundleShortVersionString -string ' + version + ' ios/StatusIm/Info.plist')
sh ('plutil -replace CFBundleVersion -string ' + build_no + ' ios/StatusIm/Info.plist')
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive' sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist' sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
} }

View File

@ -35,6 +35,7 @@ node ('macos1'){
} }
version = BRANCH_NAME.substring(8) version = BRANCH_NAME.substring(8)
sh 'echo "' + version + '" > .version'
println version println version

View File

@ -19,6 +19,9 @@ hash git 2>/dev/null || { echo >&2 "Git required, not installed. Aborting build
# Run Script build phases that operate on product files of the target that defines them should use the value of this build setting [TARGET_BUILD_DIR]. But Run Script build phases that operate on product files of other targets should use ?BUILT_PRODUCTS_DIR? instead. # Run Script build phases that operate on product files of the target that defines them should use the value of this build setting [TARGET_BUILD_DIR]. But Run Script build phases that operate on product files of other targets should use ?BUILT_PRODUCTS_DIR? instead.
INFO_PLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" INFO_PLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
if [[ $(git ls-files -m "StatusIm/Info.plist") = *"Info.plist"* ]]; then
echo "version was set in Info.plist"
else
# Build version (closest-tag-or-branch "-" commits-since-tag "-" short-hash dirty-flag) # Build version (closest-tag-or-branch "-" commits-since-tag "-" short-hash dirty-flag)
BUILD_VERSION=$(git describe --tags --always --dirty=+) BUILD_VERSION=$(git describe --tags --always --dirty=+)
@ -56,3 +59,4 @@ echo "SHORT VERSION: $SHORT_VERSION"
/usr/libexec/PlistBuddy -c "Add :CFBundleBuildVersion string $BUILD_VERSION" "$INFO_PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :CFBundleBuildVersion $BUILD_VERSION" "$INFO_PLIST" /usr/libexec/PlistBuddy -c "Add :CFBundleBuildVersion string $BUILD_VERSION" "$INFO_PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :CFBundleBuildVersion $BUILD_VERSION" "$INFO_PLIST"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $SHORT_VERSION" "$INFO_PLIST" /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $SHORT_VERSION" "$INFO_PLIST"
fi

View File

@ -1,7 +1,8 @@
(ns status-im.utils.build (ns status-im.utils.build
(:require [cljs.analyzer :as analyzer] (:require [cljs.analyzer :as analyzer]
[clojure.string :as string] [clojure.string :as string]
[clojure.java.shell :as shell])) [clojure.java.shell :as shell]
[clojure.java.io :as io]))
;; Some warnings are unavoidable due to dependencies. For example, reagent 0.6.0 ;; Some warnings are unavoidable due to dependencies. For example, reagent 0.6.0
;; has a warning in its util.cljs namespace. Adjust this as is necessary and ;; has a warning in its util.cljs namespace. Adjust this as is necessary and
@ -21,4 +22,10 @@
(System/exit 1)))) (System/exit 1))))
(defmacro git-short-version [] (defmacro git-short-version []
(string/replace (:out (shell/sh "bash" "-c" "git describe --always")) "\n" "")) (let [version-file-path ".version"
version-file (io/file version-file-path)]
(if (.exists version-file)
(string/trim (slurp version-file-path))
(-> (shell/sh "bash" "-c" "git describe --always")
:out
(string/replace "\n" "")))))