Skip to content

Commit

Permalink
Merge pull request #219 from crossroads/master
Browse files Browse the repository at this point in the history
#December2018Release1
  • Loading branch information
namrataukirde authored Dec 6, 2018
2 parents d6d4ae9 + 1f81575 commit bebcb6f
Show file tree
Hide file tree
Showing 10 changed files with 643 additions and 609 deletions.
45 changes: 31 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ jobs:

tests:
<<: *defaults
docker:
- image: circleci/node:6-browsers
environment:
JOBS: 1
steps:
- restore-cache: *restore-repo-cache
- restore-cache: *restore-yarn-cache
Expand Down Expand Up @@ -191,10 +195,10 @@ jobs:
name: Setup Environment variables
command: |
echo 'export PATH=$PATH:`yarn bin`' >> $BASH_ENV
echo 'export ENVIRONMENT=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo production; else echo staging; fi)' >> $BASH_ENV
echo 'export PROVISIONING_PROFILE=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo $PROD_PROVISIONING_PROFILE; else echo $STAGING_PROVISIONING_PROFILE; fi)' >> $BASH_ENV
echo 'export CERTIFICATE=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo $PROD_CERT; else echo $STAGING_CERT; fi)' >> $BASH_ENV
echo 'export STAGING=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo false; else echo true; fi)' >> $BASH_ENV
echo 'export ENVIRONMENT=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo production; else echo staging; fi)' >> $BASH_ENV
echo 'export PROVISIONING_PROFILE=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo 'GoodCity_App.mobileprovision'; else echo 'GoodCity_App_Staging.mobileprovision'; fi)' >> $BASH_ENV
echo 'export CERTIFICATE=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo 'Goodcity_2019.p12'; else echo 'GoodCity_2018_Development.p12'; fi)' >> $BASH_ENV
- run:
command: |
npm rebuild node-sass
Expand Down Expand Up @@ -224,13 +228,13 @@ jobs:
working_directory: ~/code
- run: pod setup
- run:
name: install cordova-update-config globally
name: Install cordova-update-config globally
command: npm i -g cordova-update-config
- run:
name: install cordova globally
name: Install cordova globally
command: npm i -g [email protected]
- run:
name: create keychain and import certificates
name: Create keychain and import p12 certificate
command: bundle exec fastlane ios prepare_certificates cert:$CERTIFICATE
working_directory: ~/code
- run:
Expand All @@ -240,7 +244,7 @@ jobs:
- store_artifacts:
path: cordova/platforms/ios/build/device
- run:
name: release ios build
name: Release ios build
command: bundle exec fastlane ios ${ENVIRONMENT}
working_directory: ~/code

Expand Down Expand Up @@ -275,17 +279,30 @@ jobs:
- restore-cache: *restore-bundler-cache
- run: bundle check --path=vendor/bundle || bundle install --deployment --jobs=4 --retry=3
- save-cache: *save-bundler-cache
- run:
name: Setup Environment variables
command: |
echo 'export ASSET_HOST_URL=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo "https://app.goodcity.hk/assets"; else echo "https://app-staging.goodcity.hk/assets"; fi)' >> $BASH_ENV
echo 'export APP_VERSION=$(jq -r ".version" package.json)' >> $BASH_ENV
- attach_workspace:
at: ~/code
- run: mv dist-www/ dist
- run:
name: Get source map url with grep
command: echo 'export SOURCE_MAP_WITH_VARIABLE_NAME=$(grep sourceMappingURL dist/assets/goodcity-*.js)' >> $BASH_ENV
- run: echo $SOURCE_MAP_WITH_VARIABLE_NAME
- run:
name: Remove unnecessary characters form source map
command: echo 'export SOURCE_MAP=$(eval echo $SOURCE_MAP_WITH_VARIABLE_NAME | cut -c22-100)' >> $BASH_ENV
- run: echo $SOURCE_MAP
- run:
name: Setup Environment
command: echo 'export ENVIRONMENT=$(if [ "$CIRCLE_BRANCH" == "live" ]; then echo production; else echo staging; fi)' >> $BASH_ENV
- run: bundle exec cap $ENVIRONMENT deploy:upload
- run:
name: Upload Source Map to Rollbar
command: |
curl https://api.rollbar.com/api/1/sourcemap/download -F access_token="${ROLLBAR_ACCESS_TOKEN}" -F version="${APP_VERSION}" -F minified_url=https://app-staging.goodcity.hk/assets/goodcity.js
curl https://api.rollbar.com/api/1/sourcemap/download -F access_token="${ROLLBAR_KEY}" -F version="${APP_VERSION}" -F minified_url=$ASSET_HOST_URL/$SOURCE_MAP
workflows:
version: 2
Expand Down Expand Up @@ -328,10 +345,10 @@ workflows:
filters:
branches:
only: /^(master|live)$/
# - ios_build_and_deploy:
# requires:
# - tests
# filters:
# branches:
# only: /^(master|live)$/
- ios_build_and_deploy:
requires:
- tests
filters:
branches:
only: /^(live)$/

3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ gem "capistrano", "3.4.0"
gem "rake"
gem "fastlane"
gem "cocoapods"
gem "credentials_manager"
gem "nokogiri" # for CircleCI v2 deployment to extract version number
gem "plist"
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ GEM
cocoapods-try (1.1.0)
colored (1.2)
colored2 (3.1.2)
commander (4.4.6)
highline (~> 1.7.2)
commander-fastlane (4.4.6)
highline (~> 1.7.2)
concurrent-ruby (1.0.5)
credentials_manager (1.0.0)
colored
commander (>= 4.3.5)
fastlane (>= 2.0.0, < 3.0.0)
highline (>= 1.7.1)
security
declarative (0.0.10)
declarative-option (0.1.0)
domain_name (0.5.20180417)
Expand Down Expand Up @@ -140,6 +148,7 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mini_magick (4.5.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
molinillo (0.6.6)
msgpack (1.2.4)
Expand All @@ -153,6 +162,8 @@ GEM
net-ssh (>= 2.6.5)
net-ssh (5.0.2)
netrc (0.11.0)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
os (1.0.0)
plist (3.4.0)
public_suffix (2.0.5)
Expand Down Expand Up @@ -211,7 +222,10 @@ PLATFORMS
DEPENDENCIES
capistrano (= 3.4.0)
cocoapods
credentials_manager
fastlane
nokogiri
plist
rake

BUNDLED WITH
Expand Down
66 changes: 42 additions & 24 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
require "json"
require "fileutils"
require "rake/clean"
require 'plist'

ROOT_PATH = File.dirname(__FILE__)
CORDOVA_PATH = "#{ROOT_PATH}/cordova"
Expand All @@ -48,17 +49,6 @@ TESTFAIRY_PLUGIN_NAME = "com.testfairy.cordova-plugin"
SPLUNKMINT_PLUGIN_URL = "https://github.com/crossroads/cordova-plugin-splunkmint.git"
KEYSTORE_FILE = "#{CORDOVA_PATH}/goodcity.keystore"
BUILD_JSON_FILE = "#{CORDOVA_PATH}/build.json"
IOS_SIGNING_STYLE = false
IOS_DEBUGMODE_BUILDCONF = {
code_signing: "\'iPhone Developer\'",
package_type: 'development',
icloud_container_environment: 'Development'
}.freeze
IOS_RELEASEMODE_BUILDCONF = {
code_signing: "\'iPhone Distribution\'",
package_type: 'app-store',
icloud_container_environment: 'Production'
}.freeze

# Default task
task default: %w(app:build)
Expand Down Expand Up @@ -113,6 +103,12 @@ namespace :cordova do
desc "Cordova build {platform}"
task build: :prepare do
Dir.chdir(CORDOVA_PATH) do
#Temporary fix for phonegap-plugin-push
if platform == 'android'
sh %{ cordova plugin add [email protected] }
else
sh %{ cordova plugin add [email protected] --variable SENDER_ID="XXXXXXX" }
end
build = (environment == "staging" && platform == 'android') ? "debug" : "release"
extra_params = (platform === "android") ? '' : ios_build_config
system({"ENVIRONMENT" => environment}, "cordova compile #{platform} --#{build} --device #{extra_params}")
Expand Down Expand Up @@ -188,23 +184,45 @@ def platform
end
end

def ios_build_config
signing_style = IOS_SIGNING_STYLE
team_id = ENV['IOS_DEVELOPMENT_TEAM_ID']
def mobile_provisioning_file
prefix = ['~', 'Library', 'MobileDevice', 'Provisioning\ Profiles']
file = if production_env?
"GoodCity_App.mobileprovision"
else
"GoodCity_App_Staging.mobileprovision"
end
File.join(prefix, file)
end

if(environment === 'production')
provisioning_profile = ENV['PROVISIONING_PROFILE_PROD']
code_signing = IOS_RELEASEMODE_BUILDCONF[:code_signing]
package_type = IOS_RELEASEMODE_BUILDCONF[:package_type]
icloud_container_environment = IOS_RELEASEMODE_BUILDCONF[:icloud_container_environment]
def mobile_provisioning_plist
@mobile_provisioning_plist ||= begin
profile = `openssl smime -inform der -verify -noverify -in #{mobile_provisioning_file}`
Plist.parse_xml(profile)
end
end

def ios_build_config
opts = {}
opts["developmentTeam"] = mobile_provisioning_plist["TeamIdentifier"].first
opts["automaticProvisionin"] = false
opts["provisioningProfile"] = mobile_provisioning_plist["UUID"]
if production_env?
opts["codeSignIdentity"] = "\'iPhone Distribution\'"
opts["packageType"] = "app-store"
opts["icloud_container_environment"] = "Production"
else
provisioning_profile = ENV['PROVISIONING_PROFILE_STAGING']
code_signing = IOS_DEBUGMODE_BUILDCONF[:code_signing]
package_type = IOS_DEBUGMODE_BUILDCONF[:package_type]
icloud_container_environment = IOS_DEBUGMODE_BUILDCONF[:icloud_container_environment]
opts["codeSignIdentity"] = "\'iPhone Developer\'"
opts["packageType"] = 'development'
opts["icloud_container_environment"] = "Development"
end
opts.map do |key, value|
"--#{key}=#{value}"
end.join(" ")
#" --codeSignIdentity=#{code_signing} --developmentTeam=#{team_id} --packageType=#{package_type} --provisioningProfile=\'#{provisioning_profile}\' --automaticProvisionin=#{signing_style} --icloud_container_environment=#{icloud_container_environment}"
end

" --codeSignIdentity=#{code_signing} --developmentTeam=#{team_id} --packageType=#{package_type} --provisioningProfile=\'#{provisioning_profile}\' --automaticProvisionin=#{signing_style} --icloud_container_environment=#{icloud_container_environment}"
def production_env?
environment == 'production'
end

def env?(env)
Expand Down
1 change: 0 additions & 1 deletion cordova/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
<engine name="ios" spec="https://github.com/apache/cordova-ios.git#4.5.5" />
<engine name="android" spec="~6.3.0"/>
<engine name="windows" spec="~4.3.1"/>
<plugin name="phonegap-plugin-push" spec="~2.1.2"/>
<plugin name="cordova-plugin-statusbar" spec="~2.1.1"/>
<plugin name="cordova-plugin-device" spec="~1.1.1"/>
<plugin name="cordova-plugin-whitelist" spec="~1.2.1"/>
Expand Down
2 changes: 1 addition & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function(defaults) {
}
},
fingerprint: {
extensions: ['css', 'png', 'jpg', 'gif', 'map'],
extensions: ['js','css', 'png', 'jpg', 'gif', 'map'],
enabled: webRelease
},
gzip: {
Expand Down
4 changes: 2 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ platform :ios do
desc "Generate staging build (just upload to TestFairy)"
lane :staging do
raise_if_no_env_var(["FL_TESTFAIRY_API_KEY"])
testfairy
testfairy(auto_update: 'on')
end

desc "Upload to TestFlight"
Expand Down Expand Up @@ -74,7 +74,7 @@ platform :android do
desc "Generate staging build (just upload to TestFairy)"
lane :staging do
raise_if_no_env_var(["FL_TESTFAIRY_API_KEY"])
testfairy
testfairy(auto_update: 'on')
end

desc "Upload to GooglePlay beta track"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "goodcity",
"version": "0.15.0",
"version": "0.16.1",
"description": "Small description for goodcity goes here",
"license": "MIT",
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
"test_page": "tests/index.html?hidepassed",
"disable_watching": true,
"launch_in_ci": [
"PhantomJS"
"Chrome"
],
"launch_in_dev": [
"PhantomJS",
Expand Down
Loading

0 comments on commit bebcb6f

Please sign in to comment.