forked from Ivasoft/mattermost-mobile
RN-545: Builds, uploads to S3, notififes channel. (#1330)
* RN-545: Builds, uploads to S3, notififes channel. * RN-545: Awesomeified the bot post. * RN-545: Adds logos to qa builds. Uses env variable for mattermost() invocation to get exceptions via webhook. * RN-545: Fix typo.
This commit is contained in:
committed by
Harrison Healey
parent
1f7b209ffc
commit
38d0c57466
4
Makefile
4
Makefile
@@ -166,7 +166,7 @@ run-android: | check-device-android pre-run prepare-android-build ## Runs the ap
|
||||
fi; \
|
||||
fi
|
||||
|
||||
build-ios: | pre-run check-style
|
||||
build-ios: | pre-run check-style ## Creates an iOS build
|
||||
ifneq ($(IOS_APP_GROUP),)
|
||||
@mkdir -p assets/override
|
||||
@echo "{\n\t\"AppGroupId\": \"$$IOS_APP_GROUP\"\n}" > assets/override/config.json
|
||||
@@ -180,7 +180,7 @@ endif
|
||||
@ps -e | grep -i "cli.js start" | grep -iv grep | awk '{print $$1}' | xargs kill -9
|
||||
@rm -rf assets/override
|
||||
|
||||
build-android: | pre-run check-style prepare-android-build
|
||||
build-android: | pre-run check-style prepare-android-build ## Creates an Android build
|
||||
@if [ $(shell ps -e | grep -i "cli.js start" | grep -civ grep) -eq 0 ]; then \
|
||||
echo Starting React Native packager server; \
|
||||
node ./node_modules/react-native/local-cli/cli.js start & echo; \
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
fastlane_version '2.71.0'
|
||||
|
||||
require 'aws-sdk-s3'
|
||||
require 'erb'
|
||||
|
||||
skip_docs
|
||||
|
||||
platform :ios do
|
||||
@@ -50,6 +54,31 @@ platform :ios do
|
||||
replace_ios_assets()
|
||||
end
|
||||
|
||||
lane :build_qa do
|
||||
match(type: 'adhoc')
|
||||
build_ios
|
||||
|
||||
current_build_number = get_build_number(xcodeproj: './ios/Mattermost.xcodeproj').to_i
|
||||
plist_template = File.read('plist.erb')
|
||||
abbreviated_commit_hash = `git rev-parse --short head`
|
||||
abbreviated_commit_hash.strip!
|
||||
plist_body = ERB.new(plist_template).result(binding)
|
||||
|
||||
s3 = Aws::S3::Resource.new(region: ENV['AWS_REGION'])
|
||||
plist_obj = s3.bucket(ENV['AWS_BUCKET_NAME']).object("ios/#{abbreviated_commit_hash}.plist")
|
||||
plist_obj.put(body: plist_body)
|
||||
|
||||
ipa_obj = s3.bucket(ENV['AWS_BUCKET_NAME']).object("ios/#{abbreviated_commit_hash}.ipa")
|
||||
ipa_obj.upload_file('../Mattermost.ipa')
|
||||
|
||||
ios_install_url = "itms-services://?action=download-manifest&url=https://s3.#{ENV['AWS_REGION']}.amazonaws.com/#{ENV['AWS_BUCKET_NAME']}/ios/#{abbreviated_commit_hash}.plist"
|
||||
|
||||
if ENV['MATTERMOST_WEBHOOK_URL']
|
||||
msg = "QA build [#{abbreviated_commit_hash}](https://github.com/mattermost/mattermost-mobile/commit/#{abbreviated_commit_hash}) — iOS: #{ios_install_url}"
|
||||
mattermost(message: msg, username: 'Fastlane', icon_url: 'https://support.apple.com/library/content/dam/edam/applecare/images/en_US/iOS/move-to-ios-icon.png')
|
||||
end
|
||||
end
|
||||
|
||||
error do |lane, exception|
|
||||
if ENV['MATTERMOST_WEBHOOK_URL']
|
||||
send_message_for_ios('', 'Unsuccessful Build', exception.message, [:lane], false)
|
||||
@@ -160,7 +189,7 @@ platform :ios do
|
||||
payload: {},
|
||||
attachment_properties: {
|
||||
title: title,
|
||||
thumb_url: 'https://lh3.googleusercontent.com/Nkbo3QohCOU8bGqSYtwB88o03XxUwRAxRHNdXPB9zFvYFzTwD7naYa-GYJaelBp-OIc=w300',
|
||||
thumb_url: 'https://support.apple.com/library/content/dam/edam/applecare/images/en_US/iOS/move-to-ios-icon.png',
|
||||
fields: [{
|
||||
title: 'Version',
|
||||
value: version,
|
||||
@@ -240,6 +269,26 @@ platform :android do
|
||||
)
|
||||
end
|
||||
|
||||
lane :build_qa do
|
||||
prepare_release
|
||||
|
||||
build_android
|
||||
|
||||
abbreviated_commit_hash = last_git_commit[:abbreviated_commit_hash]
|
||||
|
||||
s3 = Aws::S3::Resource.new(region: ENV['AWS_REGION'])
|
||||
|
||||
apk_obj = s3.bucket(ENV['AWS_BUCKET_NAME']).object("android/#{abbreviated_commit_hash}.apk")
|
||||
apk_obj.upload_file("#{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]}")
|
||||
|
||||
android_install_path = "https://s3.#{ENV['AWS_REGION']}.amazonaws.com/#{ENV['AWS_BUCKET_NAME']}/android/#{abbreviated_commit_hash}.apk"
|
||||
|
||||
if ENV['MATTERMOST_WEBHOOK_URL']
|
||||
msg = "QA build [#{abbreviated_commit_hash}](https://github.com/mattermost/mattermost-mobile/commit/#{abbreviated_commit_hash}) — Android: #{android_install_path}"
|
||||
mattermost(message: msg, username: 'Fastlane', icon_url: 'https://lh3.ggpht.com/XL0CrI8skkxnboGct-duyg-bZ_MxJDTrjczyjdU8OP2PM1dmj7SP4jL1K8JQeMIB3AM=w300')
|
||||
end
|
||||
end
|
||||
|
||||
error do |lane, exception|
|
||||
if ENV['MATTERMOST_WEBHOOK_URL']
|
||||
send_message_for_android('', 'Unsuccessful Build', exception.message, [:lane], false)
|
||||
@@ -410,7 +459,7 @@ platform :android do
|
||||
payload: {},
|
||||
attachment_properties: {
|
||||
title: title,
|
||||
thumb_url: 'http://www.concretesolutions.com.br/blog/wp-content/uploads/2015/04/Android1.png',
|
||||
thumb_url: 'https://lh3.ggpht.com/XL0CrI8skkxnboGct-duyg-bZ_MxJDTrjczyjdU8OP2PM1dmj7SP4jL1K8JQeMIB3AM=w300',
|
||||
fields: [{
|
||||
title: 'Version',
|
||||
value: version_name,
|
||||
|
||||
@@ -2,6 +2,7 @@ source "https://rubygems.org"
|
||||
|
||||
gem "fastlane"
|
||||
gem "nokogiri"
|
||||
gem "aws-sdk-s3"
|
||||
|
||||
plugins_path = File.join(File.dirname(__FILE__), '.', 'Pluginfile')
|
||||
eval(File.read(plugins_path), binding) if File.exist?(plugins_path)
|
||||
|
||||
@@ -4,6 +4,19 @@ GEM
|
||||
CFPropertyList (2.3.6)
|
||||
addressable (2.5.2)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
aws-partitions (1.45.0)
|
||||
aws-sdk-core (3.11.0)
|
||||
aws-partitions (~> 1.0)
|
||||
aws-sigv4 (~> 1.0)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-kms (1.3.0)
|
||||
aws-sdk-core (~> 3)
|
||||
aws-sigv4 (~> 1.0)
|
||||
aws-sdk-s3 (1.8.0)
|
||||
aws-sdk-core (~> 3)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.0)
|
||||
aws-sigv4 (1.0.2)
|
||||
babosa (1.0.2)
|
||||
claide (1.0.2)
|
||||
colored (1.2)
|
||||
@@ -24,7 +37,7 @@ GEM
|
||||
faraday_middleware (0.12.2)
|
||||
faraday (>= 0.7.4, < 1.0)
|
||||
fastimage (2.1.1)
|
||||
fastlane (2.71.0)
|
||||
fastlane (2.72.0)
|
||||
CFPropertyList (>= 2.3, < 3.0.0)
|
||||
addressable (>= 2.3, < 3.0.0)
|
||||
babosa (>= 1.0.2, < 2.0.0)
|
||||
@@ -52,7 +65,8 @@ GEM
|
||||
slack-notifier (>= 1.3, < 2.0.0)
|
||||
terminal-notifier (>= 1.6.2, < 2.0.0)
|
||||
terminal-table (>= 1.4.5, < 2.0.0)
|
||||
tty-screen (~> 0.6.3)
|
||||
tty-screen (>= 0.6.3, < 1.0.0)
|
||||
tty-spinner (>= 0.7.0, < 1.0.0)
|
||||
word_wrap (~> 1.0.0)
|
||||
xcodeproj (>= 1.5.2, < 2.0.0)
|
||||
xcpretty (>= 0.2.4, < 1.0.0)
|
||||
@@ -81,6 +95,7 @@ GEM
|
||||
http-cookie (1.0.3)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.8.3)
|
||||
jmespath (1.3.1)
|
||||
json (2.1.0)
|
||||
jwt (2.1.0)
|
||||
little-plugger (1.1.4)
|
||||
@@ -119,7 +134,10 @@ GEM
|
||||
terminal-notifier (1.8.0)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
tty-cursor (0.5.0)
|
||||
tty-screen (0.6.4)
|
||||
tty-spinner (0.7.0)
|
||||
tty-cursor (>= 0.5.0)
|
||||
uber (0.1.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
@@ -140,6 +158,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
aws-sdk-s3
|
||||
fastlane
|
||||
fastlane-plugin-android_change_package_identifier
|
||||
fastlane-plugin-android_change_string_app_name
|
||||
@@ -147,4 +166,4 @@ DEPENDENCIES
|
||||
nokogiri
|
||||
|
||||
BUNDLED WITH
|
||||
1.13.7
|
||||
1.16.1
|
||||
|
||||
@@ -149,3 +149,15 @@ export GITHUB_PULL_REQUEST_API_TOKEN=
|
||||
|
||||
# The GitHub repo to submit the Pull Request against.
|
||||
export GITHUB_PULL_REQUEST_REPO=mattermost/mattermost-mobile
|
||||
|
||||
|
||||
############ WEBHOOK ############
|
||||
export MATTERMOST_WEBHOOK_URL=
|
||||
export MATTERMOST_URL=$MATTERMOST_WEBHOOK_URL
|
||||
|
||||
|
||||
############ AWS ############
|
||||
export AWS_ACCESS_KEY_ID=
|
||||
export AWS_SECRET_ACCESS_KEY=
|
||||
export AWS_BUCKET_NAME=
|
||||
export AWS_REGION=
|
||||
39
fastlane/plist.erb
Normal file
39
fastlane/plist.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>items</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>assets</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>kind</key>
|
||||
<string>software-package</string>
|
||||
<key>url</key>
|
||||
<string>https://s3.<%= ENV['AWS_REGION'] %>.amazonaws.com/<%= ENV['AWS_BUCKET_NAME'] %>/ios/<%= abbreviated_commit_hash %>.ipa</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>kind</key>
|
||||
<string>display-image</string>
|
||||
<key>needs-shine</key>
|
||||
<true/>
|
||||
<key>url</key>
|
||||
<string>https://s3.<%= ENV['AWS_REGION'] %>.amazonaws.com/<%= ENV['AWS_BUCKET_NAME'] %>/beta-logo.png</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>metadata</key>
|
||||
<dict>
|
||||
<key>bundle-identifier</key>
|
||||
<string><%= ENV['IOS_MAIN_APP_IDENTIFIER'] %></string>
|
||||
<key>bundle-version</key>
|
||||
<string><%= current_build_number %></string>
|
||||
<key>kind</key>
|
||||
<string>software</string>
|
||||
<key>title</key>
|
||||
<string>Mattermost Beta</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user