From 4ae1caa1a8777f248f56e1b5c44758f1ed975956 Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 4 Jan 2018 12:49:19 -0300 Subject: [PATCH] Make fastlane generic (#1328) * Make fastlane generic * Move release assets to dist folder for easier white labeling * Remove at in help command --- Makefile | 234 ++++---- README.md | 90 +--- .../icons/android/mipmap-hdpi/ic_launcher.png | Bin .../icons/android/mipmap-mdpi/ic_launcher.png | Bin .../android/mipmap-xhdpi/ic_launcher.png | Bin .../android/mipmap-xxhdpi/ic_launcher.png | Bin .../android/mipmap-xxxhdpi/ic_launcher.png | Bin assets/{ => base}/release/icons/ios/20.png | Bin .../{ => base}/release/icons/ios/20@2x-1.png | Bin assets/{ => base}/release/icons/ios/20@2x.png | Bin assets/{ => base}/release/icons/ios/20@3x.png | Bin assets/{ => base}/release/icons/ios/29.png | Bin .../{ => base}/release/icons/ios/29@2x-1.png | Bin assets/{ => base}/release/icons/ios/29@2x.png | Bin assets/{ => base}/release/icons/ios/29@3x.png | Bin assets/{ => base}/release/icons/ios/40.png | Bin .../{ => base}/release/icons/ios/40@2x-1.png | Bin assets/{ => base}/release/icons/ios/40@2x.png | Bin assets/{ => base}/release/icons/ios/40@3x.png | Bin assets/{ => base}/release/icons/ios/76.png | Bin assets/{ => base}/release/icons/ios/76@2x.png | Bin .../{ => base}/release/icons/ios/83.5@2x.png | Bin .../{ => base}/release/icons/ios/Icon-60.png | Bin .../release/icons/ios/Icon-60@2x.png | Bin .../release/icons/ios/Icon-60@3x.png | Bin .../{ => base}/release/icons/ios/Icon-72.png | Bin .../release/icons/ios/Icon-72@2x.png | Bin .../release/icons/ios/Icon-Small-50.png | Bin .../release/icons/ios/Icon-Small-50@2x.png | Bin assets/{ => base}/release/icons/ios/Icon.png | Bin .../{ => base}/release/icons/ios/Icon@2x.png | Bin .../release/icons/ios/iTunesArtwork@2x.png | Bin fastlane/Fastfile | 510 ++++++++---------- fastlane/Gemfile.lock | 14 +- fastlane/Matchfile | 4 +- fastlane/env_vars_example | 151 ++++++ 36 files changed, 491 insertions(+), 512 deletions(-) rename assets/{ => base}/release/icons/android/mipmap-hdpi/ic_launcher.png (100%) rename assets/{ => base}/release/icons/android/mipmap-mdpi/ic_launcher.png (100%) rename assets/{ => base}/release/icons/android/mipmap-xhdpi/ic_launcher.png (100%) rename assets/{ => base}/release/icons/android/mipmap-xxhdpi/ic_launcher.png (100%) rename assets/{ => base}/release/icons/android/mipmap-xxxhdpi/ic_launcher.png (100%) rename assets/{ => base}/release/icons/ios/20.png (100%) rename assets/{ => base}/release/icons/ios/20@2x-1.png (100%) rename assets/{ => base}/release/icons/ios/20@2x.png (100%) rename assets/{ => base}/release/icons/ios/20@3x.png (100%) rename assets/{ => base}/release/icons/ios/29.png (100%) rename assets/{ => base}/release/icons/ios/29@2x-1.png (100%) rename assets/{ => base}/release/icons/ios/29@2x.png (100%) rename assets/{ => base}/release/icons/ios/29@3x.png (100%) rename assets/{ => base}/release/icons/ios/40.png (100%) rename assets/{ => base}/release/icons/ios/40@2x-1.png (100%) rename assets/{ => base}/release/icons/ios/40@2x.png (100%) rename assets/{ => base}/release/icons/ios/40@3x.png (100%) rename assets/{ => base}/release/icons/ios/76.png (100%) rename assets/{ => base}/release/icons/ios/76@2x.png (100%) rename assets/{ => base}/release/icons/ios/83.5@2x.png (100%) rename assets/{ => base}/release/icons/ios/Icon-60.png (100%) rename assets/{ => base}/release/icons/ios/Icon-60@2x.png (100%) rename assets/{ => base}/release/icons/ios/Icon-60@3x.png (100%) rename assets/{ => base}/release/icons/ios/Icon-72.png (100%) rename assets/{ => base}/release/icons/ios/Icon-72@2x.png (100%) rename assets/{ => base}/release/icons/ios/Icon-Small-50.png (100%) rename assets/{ => base}/release/icons/ios/Icon-Small-50@2x.png (100%) rename assets/{ => base}/release/icons/ios/Icon.png (100%) rename assets/{ => base}/release/icons/ios/Icon@2x.png (100%) rename assets/{ => base}/release/icons/ios/iTunesArtwork@2x.png (100%) create mode 100644 fastlane/env_vars_example diff --git a/Makefile b/Makefile index 7e9d62c8c..0cd5021a5 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ -.PHONY: run run-ios run-android check-style test clean post-install start stop -.PHONY: check-ios-target build-ios -.PHONY: check-android-target prepare-android-build build-android -.PHONY: start-packager stop-packager -.PHONY: help +.PHONY: pre-run clean +.PHONY: check-style +.PHONY: start stop +.PHONY: run run-ios run-android +.PHONY: build-ios build-android unsigned-ios unsigned-android +.PHONY: test help -ios_target := $(filter-out build-ios,$(MAKECMDGOALS)) -android_target := $(filter-out build-android,$(MAKECMDGOALS)) POD := $(shell command -v pod 2> /dev/null) OS := $(shell sh -c 'uname -s 2>/dev/null') +BASE_ASSETS = $(shell find assets/base -type d) $(shell find assets/base -type f -name '*') +OVERRIDE_ASSETS = $(shell find assets/override -type d 2> /dev/null) $(shell find assets/override -type f -name '*' 2> /dev/null) .yarninstall: package.json @if ! [ $(shell command -v yarn 2> /dev/null) ]; then \ @@ -32,10 +33,7 @@ endif endif @touch $@ -BASE_ASSETS = $(shell find assets/base -type d) $(shell find assets/base -type f -name '*') -OVERRIDE_ASSETS = $(shell find assets/override -type d 2> /dev/null) $(shell find assets/override -type f -name '*' 2> /dev/null) dist/assets: $(BASE_ASSETS) $(OVERRIDE_ASSETS) - @mkdir -p dist @if [ -e dist/assets ] ; then \ @@ -45,60 +43,14 @@ dist/assets: $(BASE_ASSETS) $(OVERRIDE_ASSETS) @echo "Generating app assets" @node scripts/make-dist-assets.js -pre-run: | .yarninstall .podinstall dist/assets ## Does some yarn and cocoapod updates/installs - -run: run-ios ## Pretty much the same as react-native run-ios - -start: | pre-run start-packager ## Starts the package server - -stop: stop-packager ## Stops the package server; alias for 'stop-packager' - -check-device-ios: - @if ! [ $(shell command -v xcodebuild) ]; then \ - @echo "xcode is not installed"; \ - @exit 1; \ - fi - @if ! [ $(shell command -v watchman) ]; then \ - @echo "watchman is not installed"; \ - @exit 1; \ - fi - -run-ios: | check-device-ios start-build-packager ## Runs the app on an iOS emulator or dev device - @echo Running iOS app in development - @react-native run-ios --simulator="${SIMULATOR}" - -check-device-android: - @if ! [ $(ANDROID_HOME) ]; then \ - @echo "ANDROID_HOME is not set"; \ - @exit 1; \ - fi - @if ! [ $(shell command -v adb 2> /dev/null) ]; then \ - @echo "adb is not installed"; \ - @exit 1; \ - fi -ifneq ($(shell adb get-state),device) - @echo "no android device or emulator is running" - @exit 1; -endif - @if ! [ $(shell command -v watchman 2> /dev/null) ]; then \ - @echo "watchman is not installed"; \ - @exit 1; \ - fi - -run-android: | check-device-android start-build-packager prepare-android-build ## Runs the app on an Android emulator or dev device - @echo Running Android app in development - @react-native run-android --no-packager - -test: | pre-run check-style ## Runs tests and eslinting - @yarn test +pre-run: | .yarninstall .podinstall dist/assets ## Installs dependencies and assets check-style: .yarninstall ## Runs eslint @echo Checking for style guide compliance @node_modules/.bin/eslint --ext \".js\" --ignore-pattern node_modules --quiet . -clean: ## Removes temp files +clean: ## Cleans dependencies, previous builds and temp files @echo Cleaning started - @yarn cache clean @rm -rf node_modules @rm -f .yarninstall @@ -107,7 +59,6 @@ clean: ## Removes temp files @rm -rf ios/build @rm -rf ios/Pods @rm -rf android/app/build - @echo Cleanup finished post-install: @@ -132,105 +83,144 @@ post-install: @cd ./node_modules/react-native-svg/ios && rm -rf PerformanceBezier QuartzBookPack && yarn run postinstall @cd ./node_modules/mattermost-redux && yarn run build -start-packager: ## Starts the package server +start: | pre-run ## Starts the React Native packager server @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; \ else \ echo React Native packager server already running; \ - ps -e | grep -i "cli.js start" | grep -v grep | awk '{print $$1}' > server.PID; \ + ps -e | grep -i "cli.js start" | grep -iv grep | awk '{print $$1}' > server.PID; \ fi -start-build-packager: ## Starts the package server with --reset-cache flag - @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 --reset-cache & echo $$! > server.PID; \ - else \ - echo React Native packager server already running; \ - ps -e | grep -i "cli.js start" | grep -v grep | awk '{print $$1}' > server.PID; \ - fi - -stop-packager: ## Stops the package server +stop: ## Stops the React Native packager server @echo Stopping React Native packager server - @if [ -e "server.PID" ] ; then \ - kill -9 `cat server.PID` && rm server.PID; \ + @if [ $(shell ps -e | grep -i "cli.js start" | grep -civ grep) -eq 1 ]; then \ + ps -e | grep -i "cli.js start" | grep -iv grep | awk '{print $$1}' | xargs kill -9; \ echo React Native packager server stopped; \ else \ echo No React Native packager server running; \ fi -check-ios-target: -ifeq ($(ios_target), ) - @echo No target set to build iOS app - @echo "Try running make build-ios TARGET where TARGET is one of dev, beta or release" - @exit 1 -endif -ifneq ($(ios_target), $(filter $(ios_target),dev beta release)) - @echo Invalid target set to build iOS app - @echo "Try running make build-ios TARGET where TARGET is one of dev, beta or release" - @exit 1 -endif +check-device-ios: + @if ! [ $(shell command -v xcodebuild) ]; then \ + echo "xcode is not installed"; \ + exit 1; \ + fi + @if ! [ $(shell command -v watchman) ]; then \ + echo "watchman is not installed"; \ + exit 1; \ + fi -do-build-ios: - @echo "Building ios $(ios_target) app" - @cd fastlane && BABEL_ENV=production NODE_ENV=production bundle exec fastlane ios $(ios_target) +check-device-android: + @if ! [ $(ANDROID_HOME) ]; then \ + @echo "ANDROID_HOME is not set"; \ + @exit 1; \ + fi + @if ! [ $(shell command -v adb 2> /dev/null) ]; then \ + @echo "adb is not installed"; \ + @exit 1; \ + fi + @echo "Connect your Android device or open the emulator" + @adb wait-for-device -build-ios: | check-ios-target pre-run check-style start-build-packager do-build-ios stop-packager - -check-android-target: -ifeq ($(android_target), ) - @echo No target set to build Android app - @echo "Try running make build-android TARGET where TARGET is one of dev, beta or release" - @exit 1 -endif -ifneq ($(android_target), $(filter $(android_target),dev alpha release)) - @echo Invalid target set to build Android app - @echo "Try running make build-android TARGET where TARGET is one of dev, beta or release" - @exit 1 -endif + @if ! [ $(shell command -v watchman 2> /dev/null) ]; then \ + @echo "watchman is not installed"; \ + @exit 1; \ + fi prepare-android-build: @rm -rf ./node_modules/react-native/local-cli/templates/HelloWorld @rm -rf ./node_modules/react-native-linear-gradient/Examples/ @rm -rf ./node_modules/react-native-orientation/demo/ -do-build-android: - @echo "Building android $(android_target) app" - @cd fastlane && BABEL_ENV=production NODE_ENV=production bundle exec fastlane android $(android_target) +run: run-ios ## alias for run-ios -build-android: | check-android-target pre-run check-style start-build-packager prepare-android-build do-build-android stop-packager +run-ios: | check-device-ios pre-run ## Runs the app on an iOS simulator + @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 Running iOS app in development; \ + react-native run-ios --simulator="${SIMULATOR}"; \ + wait; \ + else \ + echo Running iOS app in development; \ + react-native run-ios --simulator="${SIMULATOR}"; \ + fi -do-unsigned-ios: +run-android: | check-device-android pre-run prepare-android-build ## Runs the app on an Android emulator or dev device + @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 echo Running Android app in development; \ + if [ ! -z ${VARIANT} ]; then \ + react-native run-android --no-packager --variant=${VARIANT}; \ + else \ + react-native run-android --no-packager; \ + fi; \ + wait; \ + else \ + echo Running Android app in development; \ + if [ ! -z ${VARIANT} ]; then \ + react-native run-android --no-packager --variant=${VARIANT}; \ + else \ + react-native run-android --no-packager; \ + fi; \ + fi + +build-ios: | pre-run check-style +ifneq ($(IOS_APP_GROUP),) + @mkdir -p assets/override + @echo "{\n\t\"AppGroupId\": \"$$IOS_APP_GROUP\"\n}" > assets/override/config.json +endif + @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; \ + fi + @echo "Building iOS app" + @cd fastlane && BABEL_ENV=production NODE_ENV=production bundle exec fastlane ios build + @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 + @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; \ + fi + @echo "Building Android app" + @cd fastlane && BABEL_ENV=production NODE_ENV=production bundle exec fastlane android build + @ps -e | grep -i "cli.js start" | grep -iv grep | awk '{print $$1}' | xargs kill -9 + +unsigned-ios: pre-run check-style + @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; \ + fi @echo "Building unsigned iOS app" +ifneq ($(IOS_APP_GROUP),) + @mkdir -p assets/override + @echo "{\n\t\"AppGroupId\": \"$$IOS_APP_GROUP\"\n}" > assets/override/config.json +endif @cd fastlane && NODE_ENV=production bundle exec fastlane ios unsigned @mkdir -p build-ios @cd ios/ && xcodebuild -workspace Mattermost.xcworkspace/ -scheme Mattermost -sdk iphoneos -configuration Relase -parallelizeTargets -resultBundlePath ../build-ios/result -derivedDataPath ../build-ios/ CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO @cd build-ios/ && mkdir -p Payload && cp -R Build/Products/Release-iphoneos/Mattermost.app Payload/ && zip -r Mattermost-unsigned.ipa Payload/ @mv build-ios/Mattermost-unsigned.ipa . @rm -rf build-ios/ + @rm -rf assets/override + @ps -e | grep -i "cli.js start" | grep -iv grep | awk '{print $$1}' | xargs kill -9 -do-unsigned-android: +unsigned-android: pre-run check-style prepare-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; \ + fi @echo "Building unsigned Android app" @cd fastlane && NODE_ENV=production bundle exec fastlane android unsigned @mv android/app/build/outputs/apk/app-unsigned-unsigned.apk ./Mattermost-unsigned.apk + @ps -e | grep -i "cli.js start" | grep -iv grep | awk '{print $$1}' | xargs kill -9 -unsigned-android: pre-run check-style start-build-packager do-unsigned-android stop-packager +test: | pre-run check-style ## Runs tests + @yarn test -unsigned-ios: pre-run check-style start-build-packager do-unsigned-ios stop-packager - -alpha: - @: - -dev: - @: - -beta: - @: - -release: - @: - -## Help documentatin à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +## Help documentation https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/README.md b/README.md index d1184c7da..7be7c57b6 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ **Supported iOS versions:** 9.3+ **Supported Android versions:** 5.0+ -Mattermost is an open source Slack-alternative used by thousands of companies around the world in 11 languages. Learn more at https://mattermost.com. +Mattermost is an open source Slack-alternative used by thousands of companies around the world in 11 languages. Learn more at [https://about.mattermost.com](https://about.mattermost.com). -You can download our apps from the [App Store](https://about.mattermost.com/mattermost-ios-app/) or [Google Play Store](https://about.mattermost.com/mattermost-android-app/), or package them yourself. +You can download our apps from the [App Store](https://about.mattermost.com/mattermost-ios-app/) or [Google Play Store](https://about.mattermost.com/mattermost-android-app/), or build them yourself. We plan on releasing monthly updates with new features - check the [changelog](https://github.com/mattermost/mattermost-mobile/blob/master/CHANGELOG.md) for what features are currently supported! @@ -36,85 +36,7 @@ To help with testing app updates before they're released, you can: 3. Follow [these instructions](https://docs.mattermost.com/developer/mobile-developer-setup.html) to set up your developer environment 4. Join the [Native Mobile Apps channel](https://pre-release.mattermost.com/core/channels/native-mobile-apps) on our team site to ask questions -# Installing Dependencies -Follow the [React Native Getting Started Guide](https://facebook.github.io/react-native/docs/getting-started.html) for detailed instructions on setting up your local machine for development. - -# Detailed configuration: - -## Mac - -- General requirements - - - XCode 8.3 - - Install required packages using homebrew: - ```bash - $ brew install watchman - $ brew install yarn - ``` - -- Clone repository and configure: - ```bash - $ git clone git@github.com:mattermost/mattermost-mobile.git - $ cd mattermost-mobile - $ npm install - $ npm install -g react-native-cli - ``` - -- Run application - ```bash - $ make run - ``` - -- Stop the packager server - ```bash - $ make stop - ``` -## Linux: - -- General requiriments: - - - JDK 7 or greater - - Android SDK - - Virtualbox - - An Android emulator: Genymotion or Android emulator. If using genymotion ensure that it uses existing adb tools (Settings: "Use custom Android SDK Tools") - - Install watchman (do this globally): - ```bash - $ git clone https://github.com/facebook/watchman.git - $ cd watchman - $ git checkout master - $ ./autogen.sh - $ ./configure - $ make - $ sudo make install - ``` - Configure your kernel to accept a lot of file watches, using a command like: - ```bash - $ sudo sysctl -w fs.inotify.max_user_watches=1048576 - ``` - -- Clone repository and configure: - ```bash - $ git clone git@github.com:mattermost/mattermost-mobile.git - $ cd mattermost-mobile - $ npm install - $ npm install -g react-native-cli - ``` - - - You can create a file named `assets/override/config.json` and add the url to the Mattermost server that you will use to develop: - `{ - "DefaultServerUrl": "https://pre-release.mattermost.com" - }` - - To use a local Mattermost server you will need to configure the "DefaultServerUrl" depending on the emulator you will use: - * IOs: "DefaultServerUrl": "http://localhost:8065" - * Android: "DefaultServerUrl": "http://10.0.2.2:3000" - * Genymotion: "DefaultServerUrl": "http://10.0.3.2:8065" - -- Run application - - Start emulator - - Start react packager: `$ react-native start` - - Run in emulator: `$ react-native run-android` # Frequently Asked Questions @@ -149,11 +71,3 @@ If your app is working properly, you should see a grey “Connecting…” bar t If you are seeing this message all the time, and your internet connection seems fine: Ask your server administrator if the server uses NGINX or another webserver as a reverse proxy. If so, they should check that it is configured correctly for [supporting the websocket connection for APIv4 endpoints](https://docs.mattermost.com/install/install-ubuntu-1604.html#configuring-nginx-as-a-proxy-for-mattermost-server). - -# Issues building app for own device using make build-* - -That command is an internal pipeline command for mattermost mobile to publish the mobile apps to ````Apple App Store```` and ````Google Play Store````. All ````make build-*```` commands should be avoided for this reason. - -To build the modified react native client use the instructions for [Running on Device](http://facebook.github.io/react-native/docs/running-on-device.html) from the [React Native Guide](https://facebook.github.io/react-native/docs/getting-started.html). - - diff --git a/assets/release/icons/android/mipmap-hdpi/ic_launcher.png b/assets/base/release/icons/android/mipmap-hdpi/ic_launcher.png similarity index 100% rename from assets/release/icons/android/mipmap-hdpi/ic_launcher.png rename to assets/base/release/icons/android/mipmap-hdpi/ic_launcher.png diff --git a/assets/release/icons/android/mipmap-mdpi/ic_launcher.png b/assets/base/release/icons/android/mipmap-mdpi/ic_launcher.png similarity index 100% rename from assets/release/icons/android/mipmap-mdpi/ic_launcher.png rename to assets/base/release/icons/android/mipmap-mdpi/ic_launcher.png diff --git a/assets/release/icons/android/mipmap-xhdpi/ic_launcher.png b/assets/base/release/icons/android/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from assets/release/icons/android/mipmap-xhdpi/ic_launcher.png rename to assets/base/release/icons/android/mipmap-xhdpi/ic_launcher.png diff --git a/assets/release/icons/android/mipmap-xxhdpi/ic_launcher.png b/assets/base/release/icons/android/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from assets/release/icons/android/mipmap-xxhdpi/ic_launcher.png rename to assets/base/release/icons/android/mipmap-xxhdpi/ic_launcher.png diff --git a/assets/release/icons/android/mipmap-xxxhdpi/ic_launcher.png b/assets/base/release/icons/android/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from assets/release/icons/android/mipmap-xxxhdpi/ic_launcher.png rename to assets/base/release/icons/android/mipmap-xxxhdpi/ic_launcher.png diff --git a/assets/release/icons/ios/20.png b/assets/base/release/icons/ios/20.png similarity index 100% rename from assets/release/icons/ios/20.png rename to assets/base/release/icons/ios/20.png diff --git a/assets/release/icons/ios/20@2x-1.png b/assets/base/release/icons/ios/20@2x-1.png similarity index 100% rename from assets/release/icons/ios/20@2x-1.png rename to assets/base/release/icons/ios/20@2x-1.png diff --git a/assets/release/icons/ios/20@2x.png b/assets/base/release/icons/ios/20@2x.png similarity index 100% rename from assets/release/icons/ios/20@2x.png rename to assets/base/release/icons/ios/20@2x.png diff --git a/assets/release/icons/ios/20@3x.png b/assets/base/release/icons/ios/20@3x.png similarity index 100% rename from assets/release/icons/ios/20@3x.png rename to assets/base/release/icons/ios/20@3x.png diff --git a/assets/release/icons/ios/29.png b/assets/base/release/icons/ios/29.png similarity index 100% rename from assets/release/icons/ios/29.png rename to assets/base/release/icons/ios/29.png diff --git a/assets/release/icons/ios/29@2x-1.png b/assets/base/release/icons/ios/29@2x-1.png similarity index 100% rename from assets/release/icons/ios/29@2x-1.png rename to assets/base/release/icons/ios/29@2x-1.png diff --git a/assets/release/icons/ios/29@2x.png b/assets/base/release/icons/ios/29@2x.png similarity index 100% rename from assets/release/icons/ios/29@2x.png rename to assets/base/release/icons/ios/29@2x.png diff --git a/assets/release/icons/ios/29@3x.png b/assets/base/release/icons/ios/29@3x.png similarity index 100% rename from assets/release/icons/ios/29@3x.png rename to assets/base/release/icons/ios/29@3x.png diff --git a/assets/release/icons/ios/40.png b/assets/base/release/icons/ios/40.png similarity index 100% rename from assets/release/icons/ios/40.png rename to assets/base/release/icons/ios/40.png diff --git a/assets/release/icons/ios/40@2x-1.png b/assets/base/release/icons/ios/40@2x-1.png similarity index 100% rename from assets/release/icons/ios/40@2x-1.png rename to assets/base/release/icons/ios/40@2x-1.png diff --git a/assets/release/icons/ios/40@2x.png b/assets/base/release/icons/ios/40@2x.png similarity index 100% rename from assets/release/icons/ios/40@2x.png rename to assets/base/release/icons/ios/40@2x.png diff --git a/assets/release/icons/ios/40@3x.png b/assets/base/release/icons/ios/40@3x.png similarity index 100% rename from assets/release/icons/ios/40@3x.png rename to assets/base/release/icons/ios/40@3x.png diff --git a/assets/release/icons/ios/76.png b/assets/base/release/icons/ios/76.png similarity index 100% rename from assets/release/icons/ios/76.png rename to assets/base/release/icons/ios/76.png diff --git a/assets/release/icons/ios/76@2x.png b/assets/base/release/icons/ios/76@2x.png similarity index 100% rename from assets/release/icons/ios/76@2x.png rename to assets/base/release/icons/ios/76@2x.png diff --git a/assets/release/icons/ios/83.5@2x.png b/assets/base/release/icons/ios/83.5@2x.png similarity index 100% rename from assets/release/icons/ios/83.5@2x.png rename to assets/base/release/icons/ios/83.5@2x.png diff --git a/assets/release/icons/ios/Icon-60.png b/assets/base/release/icons/ios/Icon-60.png similarity index 100% rename from assets/release/icons/ios/Icon-60.png rename to assets/base/release/icons/ios/Icon-60.png diff --git a/assets/release/icons/ios/Icon-60@2x.png b/assets/base/release/icons/ios/Icon-60@2x.png similarity index 100% rename from assets/release/icons/ios/Icon-60@2x.png rename to assets/base/release/icons/ios/Icon-60@2x.png diff --git a/assets/release/icons/ios/Icon-60@3x.png b/assets/base/release/icons/ios/Icon-60@3x.png similarity index 100% rename from assets/release/icons/ios/Icon-60@3x.png rename to assets/base/release/icons/ios/Icon-60@3x.png diff --git a/assets/release/icons/ios/Icon-72.png b/assets/base/release/icons/ios/Icon-72.png similarity index 100% rename from assets/release/icons/ios/Icon-72.png rename to assets/base/release/icons/ios/Icon-72.png diff --git a/assets/release/icons/ios/Icon-72@2x.png b/assets/base/release/icons/ios/Icon-72@2x.png similarity index 100% rename from assets/release/icons/ios/Icon-72@2x.png rename to assets/base/release/icons/ios/Icon-72@2x.png diff --git a/assets/release/icons/ios/Icon-Small-50.png b/assets/base/release/icons/ios/Icon-Small-50.png similarity index 100% rename from assets/release/icons/ios/Icon-Small-50.png rename to assets/base/release/icons/ios/Icon-Small-50.png diff --git a/assets/release/icons/ios/Icon-Small-50@2x.png b/assets/base/release/icons/ios/Icon-Small-50@2x.png similarity index 100% rename from assets/release/icons/ios/Icon-Small-50@2x.png rename to assets/base/release/icons/ios/Icon-Small-50@2x.png diff --git a/assets/release/icons/ios/Icon.png b/assets/base/release/icons/ios/Icon.png similarity index 100% rename from assets/release/icons/ios/Icon.png rename to assets/base/release/icons/ios/Icon.png diff --git a/assets/release/icons/ios/Icon@2x.png b/assets/base/release/icons/ios/Icon@2x.png similarity index 100% rename from assets/release/icons/ios/Icon@2x.png rename to assets/base/release/icons/ios/Icon@2x.png diff --git a/assets/release/icons/ios/iTunesArtwork@2x.png b/assets/base/release/icons/ios/iTunesArtwork@2x.png similarity index 100% rename from assets/release/icons/ios/iTunesArtwork@2x.png rename to assets/base/release/icons/ios/iTunesArtwork@2x.png diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 44ed3de1b..4437bec30 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,154 +1,44 @@ -fastlane_version '2.56.0' +fastlane_version '2.71.0' skip_docs platform :ios do before_all do |lane| - if lane == :beta or lane === :release - current_branch = (sh 'git rev-parse --abbrev-ref HEAD').chop! - - UI.user_error!("To cut a beta or a release you need to be on master or in a release branch. - Current branch is #{current_branch} - Exiting") unless current_branch == 'master' or current_branch.start_with?('release') - - if lane == :beta - sh "git checkout -b ios-#{lane}" - end + unless ENV['GIT_LOCAL_BRANCH'].nil? || ENV['GIT_LOCAL_BRANCH'].empty? + sh "git checkout -b #{ENV['GIT_LOCAL_BRANCH']}" end end after_all do |lane| - if lane == :beta + if ENV['RESET_GIT_BRANCH'] == 'true' reset_git_repo( force: true, skip_clean: true ) sh 'git checkout master' - sh "git branch -D ios-#{lane}" end end - desc 'Build Release file' - desc 'This will also make sure the profile is up to date' - lane :dev do - match(type: 'adhoc', app_identifier: 'com.mattermost.rnbeta') - - build_ios({ - release: false, - increment_build: false, - ensure_git_status_clean: false, - method: 'ad-hoc' - }) - end - - desc 'Submit a new Beta Build to Apple TestFlight' - desc 'This will also make sure the profile is up to date' - lane :beta do - match(type: 'appstore', app_identifier: 'com.mattermost.rnbeta') + desc 'Build iOS app' + lane :build do + if ENV['SYNC_IOS_PROVISIONING_PROFILES'] == 'true' + match(type: ENV['MATCH_TYPE'] || 'adhoc') + end configure_from_env() - build_ios({ - release: true, - increment_build: true, - ensure_git_status_clean: true, - method: 'app-store' - }) + build_ios() - pilot(skip_waiting_for_build_processing: true) - - commit = last_git_commit - - push_to_git_remote( - remote: 'origin', - local_branch: 'ios-beta', - force: false, - tags: false - ) - - unless ENV['GITHUB_TOKEN'].nil? - create_pull_request( - api_token: ENV['GITHUB_TOKEN'], - repo: 'mattermost/mattermost-mobile', - head: 'mattermost:ios-beta', - base: 'master', - title: "IOS #{commit[:message]}" - ) + if ENV['SUBMIT_IOS_TO_TESTFLIGHT'] == 'true' + pilot end - if ENV['MATTERMOST_WEBHOOK_URL'] - testflight_url = ENV['TESTFLIGHT_URL'] - send_message_for_ios( - '#### New iOS beta published on TestFlight', - '', - "#ios-beta in #{testflight_url.nil? ? 'TestFlight' : "[TestFlight](#{testflight_url})"} on [#{Time.new.utc.to_s}]", - [], - true - ) - end - end - - desc 'Deploy a new version to the App Store' - lane :release do - match(type: 'appstore', app_identifier: 'com.mattermost.rn') - - configure_from_env() - - # snapshot - - update_app_identifier( - xcodeproj: './ios/Mattermost.xcodeproj', - plist_path: 'Mattermost/Info.plist', - app_identifier: 'com.mattermost.rn' - ) - update_info_plist( - xcodeproj: './ios/Mattermost.xcodeproj', - plist_path: 'Mattermost/Info.plist', - display_name: 'Mattermost' - ) - - sh 'cp -R ../assets/release/icons/ios/* ../ios/Mattermost/Images.xcassets/AppIcon.appiconset/' - - build_ios({ - release: true, - increment_build: false, - ensure_git_status_clean: false, - method: 'app-store' - }) - - # deliver( - # force: true, - # skip_screenshots: true, - # skip_metadata: true, - # submit_for_review: false, #lets try this after the first release - # automatic_release: false #lets try this after the first release - # ) - - ### We are going to publish the app to the testflight first and not deliver it directly to the app store - pilot(skip_waiting_for_build_processing: true) - - # frameit - - reset_git_repo( - force: true, - skip_clean: true - ) - - if ENV['MATTERMOST_WEBHOOK_URL'] - appstore_url = ENV['APPSTORE_URL'] - send_message_for_ios( - '#### New iOS release published on the App Store', - '', - "#ios-release in #{appstore_url.nil? ? 'App Store' : "[App Store](#{appstore_url})"} on [#{Time.new.utc.to_s}]", - [], - true - ) - end + git_actions() end desc 'Build an unsigned ipa' lane :unsigned do - if ENV['SEGMENT_API_KEY'] + unless ENV['SEGMENT_API_KEY'].nil? || ENV['SEGMENT_API_KEY'].empty? find_replace_string( path_to_file: './dist/assets/config.json', old_string: '"SegmentApiKey": "3MT7rAoC0OP7yy3ThzqFSAtKzmzqtUPX"', @@ -156,18 +46,8 @@ platform :ios do ) end - update_app_identifier( - xcodeproj: './ios/Mattermost.xcodeproj', - plist_path: 'Mattermost/Info.plist', - app_identifier: 'com.mattermost.rn' - ) - update_info_plist( - xcodeproj: './ios/Mattermost.xcodeproj', - plist_path: 'Mattermost/Info.plist', - display_name: 'Mattermost' - ) - - sh 'cp -R ../assets/release/icons/ios/* ../ios/Mattermost/Images.xcassets/AppIcon.appiconset/' + update_identifiers() + replace_ios_assets() end error do |lane, exception| @@ -176,31 +56,95 @@ platform :ios do end end - def build_ios(options) - if options[:ensure_git_status_clean] + def update_identifiers() + unless ENV['IOS_MAIN_APP_IDENTIFIER'].nil? || ENV['IOS_MAIN_APP_IDENTIFIER'].empty? || ENV['IOS_MAIN_APP_IDENTIFIER'] == 'com.mattermost.rnbeta' + update_app_identifier( + xcodeproj: './ios/Mattermost.xcodeproj', + plist_path: 'Mattermost/Info.plist', + app_identifier: ENV['IOS_MAIN_APP_IDENTIFIER'] + ) + end + + if ENV['IOS_APP_NAME'] != 'Mattermost Beta' + update_info_plist( + xcodeproj: './ios/Mattermost.xcodeproj', + plist_path: 'Mattermost/Info.plist', + display_name: ENV['IOS_APP_NAME'] + ) + end + + if Dir.exist?('../ios/MattermostShare/') + unless ENV['IOS_APP_GROUP'].nil? || ENV['IOS_APP_GROUP'].empty? || ENV['IOS_APP_GROUP'] == 'group.com.mattermost.rnbeta' + update_app_group_identifiers( + entitlements_file: './ios/Mattermost/Mattermost.entitlements', + app_group_identifiers: [ENV['IOS_APP_GROUP']] + ) + + update_app_group_identifiers( + entitlements_file: './ios/MattermostShare/MattermostShare.entitlements', + app_group_identifiers: [ENV['IOS_APP_GROUP']] + ) + end + + unless ENV['IOS_EXTENSION_APP_IDENTIFIER'].nil? || ENV['IOS_EXTENSION_APP_IDENTIFIER'].empty? || ENV['IOS_EXTENSION_APP_IDENTIFIER'] == 'com.mattermost.rnbeta.MattermostShare' + update_app_identifier( + xcodeproj: './ios/Mattermost.xcodeproj', + plist_path: 'MattermostShare/Info.plist', + app_identifier: ENV['IOS_EXTENSION_APP_IDENTIFIER'] + ) + end + end + end + + def replace_ios_assets() + if ENV['IOS_REPLACE_ASSETS'] == 'true' + sh 'cp -R ../dist/assets/release/icons/ios/* ../ios/Mattermost/Images.xcassets/AppIcon.appiconset/' + end + end + + def build_ios() + if ENV['ENSURE_GIT_IS_CLEAN'] == 'true' ensure_git_status_clean end - if options[:increment_build] + if ENV['IOS_INCREMENT_BUILD_NUMBER'] == 'true' current_build_number = get_build_number(xcodeproj: './ios/Mattermost.xcodeproj').to_i increment_build_number( xcodeproj: './ios/Mattermost.xcodeproj', build_number: current_build_number + 1 ) - commit_version_bump(xcodeproj: './ios/Mattermost.xcodeproj') + + commit_version_options = { + xcodeproj: './ios/Mattermost.xcodeproj' + } + + commit_version_message = "#{ENV['IOS_COMMIT_INCREMENT_BUILD_NUMBER_MESSAGE']} #{(current_build_number + 1).to_s}" + unless ENV['IOS_COMMIT_INCREMENT_BUILD_NUMBER_MESSAGE'].nil? || ENV['IOS_COMMIT_INCREMENT_BUILD_NUMBER_MESSAGE'].empty? + commit_version_options[:message] = commit_version_message + end + + commit_version_bump(commit_version_options) end - update_project_team( - path: './ios/Mattermost.xcodeproj', - teamid: ENV['FASTLANE_TEAM_ID'] - ) + update_identifiers() + replace_ios_assets() + + unless ENV['FASTLANE_TEAM_ID'].nil? || ENV['FASTLANE_TEAM_ID'].empty? + update_project_team( + path: './ios/Mattermost.xcodeproj', + teamid: ENV['FASTLANE_TEAM_ID'] + ) + end + + config_mode = ENV['IOS_BUILD_FOR_RELEASE'] == 'true' ? 'Release' : 'Debug' + method = ENV['IOS_BUILD_EXPORT_METHOD'].nil? || ENV['IOS_BUILD_EXPORT_METHOD'].empty? ? 'ad-hoc' : ENV['IOS_BUILD_EXPORT_METHOD'] gym( clean: true, scheme: 'Mattermost', - configuration: (options[:release] ? 'Release' : 'Debug'), + configuration: config_mode, workspace: './ios/Mattermost.xcworkspace', - export_method: options[:method] + export_method: method ) end @@ -240,114 +184,49 @@ end platform :android do before_all do |lane| - if lane == :alpha or lane === :release - current_branch = (sh 'git rev-parse --abbrev-ref HEAD').chop! - - UI.user_error!("To cut a beta or a release you need to be on master or in a release branch. - Current branch is #{current_branch} - Exiting") unless current_branch == 'master' or current_branch.start_with?('release') - - if lane == :alpha - sh "git checkout -b android-#{lane}" - end + unless ENV['GIT_LOCAL_BRANCH'].nil? || ENV['GIT_LOCAL_BRANCH'].empty? + sh "git checkout -b #{ENV['GIT_LOCAL_BRANCH']}" end end after_all do |lane| - if lane == :alpha + if ENV['RESET_GIT_BRANCH'] == 'true' + packageId = ENV['ANDROID_PACKAGE_ID'] || 'com.mattermost.rnbeta' + beta_dir = '../android/app/src/main/java/com/mattermost/rnbeta' + release_dir = "../android/app/src/main/java/#{packageId.gsub '.', '/'}" + + if beta_dir != release_dir + sh "rm -rf #{release_dir}" + end + reset_git_repo( force: true, skip_clean: true ) + sh 'git checkout master' - sh "git branch -D android-#{lane}" end end - desc 'Build Release file' - lane :dev do - build_android({release: true}) - end - - desc 'Submit a new Beta Build to Google Play' - lane :alpha do + desc 'Build Android app' + lane :build do configure_from_env() + link_sentry_android() - build_android({ - release: true, - increment_build: true, - ensure_git_status_clean: true - }) + build_android() - supply( - track: 'alpha', - apk: "#{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]}", - ) + apk_path = "#{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]}" - commit = last_git_commit - - push_to_git_remote( - remote: 'origin', - local_branch: 'android-alpha', - force: false, - tags: false - ) - - unless ENV['GITHUB_TOKEN'].nil? - create_pull_request( - api_token: ENV['GITHUB_TOKEN'], - repo: 'mattermost/mattermost-mobile', - head: 'mattermost:android-alpha', - base: 'master', - title: "Android #{commit[:message]}" + if ENV['SUBMIT_ANDROID_TO_GOOGLE_PLAY'] == 'true' + supply( + track: ENV['SUPPLY_TRACK'] || 'alpha', + apk: apk_path ) end - if ENV['MATTERMOST_WEBHOOK_URL'] - beta_url = ENV['GOOGLE_PLAY_BETA_URL'] - send_message_for_android( - '#### New Android beta published for Beta Testing', - '', - "#android-beta in #{beta_url.nil? ? 'Google Play Beta Program' : "[Google Play Beta Program](#{beta_url})"} on [#{Time.new.utc.to_s}]", - [], - true - ) - end - end + sh "mv #{apk_path} ../Mattermost.apk" - desc 'Deploy a new version to Google Play' - lane :release do - prepare_release() - - build_android({ - release: true, - increment_build: false, - ensure_git_status_clean: false - }) - - supply( - track: 'beta', - apk: "#{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]}", - ) - - - sh 'mv ../android/app/src/main/java/com/mattermost/rn/ ../android/app/src/main/java/com/mattermost/rnbeta/' - - reset_git_repo( - force: true, - skip_clean: true - ) - - if ENV['MATTERMOST_WEBHOOK_URL'] - google_play_url = ENV['GOOGLE_PLAY_URL'] - send_message_for_android( - '#### New Android beta published for Production', - '', - "#android-beta in #{google_play_url.nil? ? 'Google Play' : "[Google Play](#{google_play_url})"} on [#{Time.new.utc.to_s}]", - [], - true - ) - end + git_actions() end desc 'Build an unsigned apk' @@ -368,63 +247,90 @@ platform :android do end def prepare_release - android_change_package_identifier(newIdentifier: 'com.mattermost.rn', manifest: './android/app/src/main/AndroidManifest.xml') - android_change_string_app_name(newName: 'Mattermost', stringsFile: './android/app/src/main/res/values/strings.xml') - android_update_application_id(app_folder_name: 'android/app', application_id: 'com.mattermost.rn') + packageId = ENV['ANDROID_PACKAGE_ID'] || 'com.mattermost.rnbeta' + beta_dir = './android/app/src/main/java/com/mattermost/rnbeta/' + release_dir = "./android/app/src/main/java/#{packageId.gsub '.', '/'}/" - beta_dir = '../android/app/src/main/java/com/mattermost/rnbeta/' - release_dir = '../android/app/src/main/java/com/mattermost/rn/' + if ENV['ANDROID_REPLACE_ASSETS'] == 'true' + sh 'cp -R ../dist/assets/release/icons/android/* ../android/app/src/main/res/' + end - sh "mv #{beta_dir} #{release_dir}" - sh 'cp -R ../assets/release/icons/android/* ../android/app/src/main/res/' + if packageId != 'com.mattermost.rnbeta' + android_change_package_identifier(newIdentifier: packageId, manifest: './android/app/src/main/AndroidManifest.xml') + android_update_application_id(app_folder_name: 'android/app', application_id: packageId) + end - find_replace_string( - path_to_file: './android/app/src/main/java/com/mattermost/rn/MainApplication.java', - old_string: 'return BuildConfig.DEBUG;', - new_string: 'return false;' - ) + unless ENV['ANDROID_APP_NAME'].nil? || ENV['ANDROID_APP_NAME'].empty? || ENV['ANDROID_APP_NAME'] == 'Mattermost Beta' + android_change_string_app_name( + newName: ENV['ANDROID_APP_NAME'], + stringsFile: './android/app/src/main/res/values/strings.xml' + ) - find_replace_string( - path_to_file: './android/app/BUCK', - old_string: 'package com.mattermost.rnbeta;', - new_string: 'package com.mattermost.rn;' - ) - - find_replace_string( - path_to_file: './fastlane/metadata/android/en-US/title.txt', - old_string: 'Mattermost Beta', - new_string: 'Mattermost' - ) - - Dir.glob("#{release_dir}*.java") do |item| find_replace_string( - path_to_file: item[1..-1], - old_string: 'package com.mattermost.rnbeta;', - new_string: 'package com.mattermost.rn;' + path_to_file: './fastlane/metadata/android/en-US/title.txt', + old_string: 'Mattermost Beta', + new_string: ENV['ANDROID_APP_NAME'] ) end - configure_from_env() + if ENV['ANDROID_BUILD_FOR_RELEASE'] == 'true' + find_replace_string( + path_to_file: "#{beta_dir}MainApplication.java", + old_string: 'return BuildConfig.DEBUG;', + new_string: 'return false;' + ) + end + + if release_dir != beta_dir + unless Dir.exist?(".#{release_dir}") + FileUtils.mkdir_p ".#{release_dir}" + end + + sh "mv .#{beta_dir}* .#{release_dir}" + + find_replace_string( + path_to_file: './android/app/BUCK', + old_string: 'package com.mattermost.rnbeta;', + new_string: "package #{packageId};" + ) + + Dir.glob(".#{release_dir}*.java") do |item| + find_replace_string( + path_to_file: item[1..-1], + old_string: 'package com.mattermost.rnbeta;', + new_string: "package #{packageId};" + ) + end + end end - def build_android(options) - if options[:ensure_git_status_clean] + def build_android() + if ENV['ENSURE_GIT_IS_CLEAN'] == 'true' ensure_git_status_clean end - if options[:increment_build] + if ENV['ANDROID_INCREMENT_BUILD_NUMBER'] == 'true' android_increment_version_code(app_folder_name: 'android/app') - android_commit_version_bump( - app_folder_name: 'android/app', - force: true - ) + build_number = get_version_code('android/app') + commit_version_options = { + app_folder_name: 'android/app' + } + + commit_version_message = "#{ENV['ANDROID_COMMIT_INCREMENT_BUILD_NUMBER_MESSAGE']} #{build_number.to_s}" + unless ENV['ANDROID_COMMIT_INCREMENT_BUILD_NUMBER_MESSAGE'].nil? || ENV['ANDROID_COMMIT_INCREMENT_BUILD_NUMBER_MESSAGE'].empty? + commit_version_options[:message] = commit_version_message + end + + android_commit_version_bump(commit_version_options) end - link_sentry_android() + prepare_release() + + config_mode = ENV['ANDROID_BUILD_FOR_RELEASE'] == 'true' ? 'Release' : 'Debug' gradle( task: 'assemble', - build_type: (options[:release] ? 'Release' : 'Debug'), + build_type: config_mode, project_dir: 'android/' ) end @@ -524,10 +430,27 @@ platform :android do success: success ) end + + def link_sentry_android + if ENV['SENTRY_ENABLED'] == 'true' + url = 'https://sentry.io' + File.open('../android/sentry.properties', 'w+') do |f| + UI.message('Creating sentry.properties from environment') + f.write( + "defaults.url=#{url}\n"\ + "defaults.org=#{ENV['SENTRY_ORG']}\n"\ + "defaults.project=#{ENV['SENTRY_PROJECT_ANDROID']}\n"\ + "auth.token=#{ENV['SENTRY_AUTH_TOKEN']}\n" + ) + end + else + UI.message('Not creating sentry.properties because Sentry is disabled') + end + end end -def configure_from_env() - if ENV['SEGMENT_API_KEY'] +def configure_from_env + unless ENV['SEGMENT_API_KEY'].nil? || ENV['SEGMENT_API_KEY'].empty? find_replace_string( path_to_file: './dist/assets/config.json', old_string: '"SegmentApiKey": "3MT7rAoC0OP7yy3ThzqFSAtKzmzqtUPX"', @@ -535,7 +458,7 @@ def configure_from_env() ) end - if ENV['SENTRY_ENABLED'] + if ENV['SENTRY_ENABLED'] == 'true' find_replace_string( path_to_file: './dist/assets/config.json', old_string: '"SentryEnabled": false', @@ -543,7 +466,7 @@ def configure_from_env() ) end - if ENV['SENTRY_ORG'] + unless ENV['SENTRY_ORG'].nil? || ENV['SENTRY_ORG'].empty? find_replace_string( path_to_file: './dist/assets/config.json', old_string: '"SentryOrg": ""', @@ -551,7 +474,7 @@ def configure_from_env() ) end - if ENV['SENTRY_PROJECT_IOS'] + unless ENV['SENTRY_PROJECT_IOS'].nil? || ENV['SENTRY_PROJECT_IOS'].empty? find_replace_string( path_to_file: './dist/assets/config.json', old_string: '"SentryProjectIos": ""', @@ -559,7 +482,7 @@ def configure_from_env() ) end - if ENV['SENTRY_PROJECT_ANDROID'] + unless ENV['SENTRY_PROJECT_ANDROID'].nil? || ENV['SENTRY_PROJECT_ANDROID'].empty? find_replace_string( path_to_file: './dist/assets/config.json', old_string: '"SentryProjectAndroid": ""', @@ -567,7 +490,7 @@ def configure_from_env() ) end - if ENV['SENTRY_DSN_IOS'] + unless ENV['SENTRY_DSN_IOS'].nil? || ENV['SENTRY_DSN_IOS'].empty? find_replace_string( path_to_file: './dist/assets/config.json', old_string: '"SentryDsnIos": ""', @@ -575,7 +498,7 @@ def configure_from_env() ) end - if ENV['SENTRY_DSN_ANDROID'] + unless ENV['SENTRY_DSN_ANDROID'].nil? || ENV['SENTRY_DSN_ANDROID'].empty? find_replace_string( path_to_file: './dist/assets/config.json', old_string: '"SentryDsnAndroid": ""', @@ -584,19 +507,22 @@ def configure_from_env() end end -def link_sentry_android() - if ENV['SENTRY_ENABLED'] == 'true' - url = 'https://sentry.io' - File.open('../android/sentry.properties', 'w+') do |f| - UI.message('Creating sentry.properties from environment') - f.write( - "defaults.url=#{url}\n"\ - "defaults.org=#{ENV['SENTRY_ORG']}\n"\ - "defaults.project=#{ENV['SENTRY_PROJECT_ANDROID']}\n"\ - "auth.token=#{ENV['SENTRY_AUTH_TOKEN']}\n" +def git_actions + if ENV['COMMIT_CHANGES_TO_GIT'] == 'true' && ENV['GIT_BRANCH'] != 'master' + commit_message = last_git_commit[:message] + push_to_git_remote( + remote: ENV['GIT_REMOTE'] || 'origin', + local_branch: ENV['GIT_BRANCH'], + remote_branch: ENV['GIT_REMOTE_BRANCH'] || ENV['GIT_BRANCH'], + force: false, + tags: false + ) + + unless ENV['GITHUB_PULL_REQUEST_API_TOKEN'].nil? || ENV['GITHUB_PULL_REQUEST_API_TOKEN'].empty? + create_pull_request( + repo: ENV['GITHUB_PULL_REQUEST_REPO'] || 'mattermost/mattermost-mobile', + title: commit_message ) end - else - UI.message('Not creating sentry.properties because Sentry is disabled') end end diff --git a/fastlane/Gemfile.lock b/fastlane/Gemfile.lock index 6c5814791..e9d5db8f3 100644 --- a/fastlane/Gemfile.lock +++ b/fastlane/Gemfile.lock @@ -15,7 +15,7 @@ GEM domain_name (0.5.20170404) unf (>= 0.0.5, < 1.0.0) dotenv (2.2.1) - excon (0.59.0) + excon (0.60.0) faraday (0.13.1) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) @@ -23,8 +23,8 @@ GEM http-cookie (~> 1.0.0) faraday_middleware (0.12.2) faraday (>= 0.7.4, < 1.0) - fastimage (2.1.0) - fastlane (2.68.2) + fastimage (2.1.1) + fastlane (2.71.0) CFPropertyList (>= 2.3, < 3.0.0) addressable (>= 2.3, < 3.0.0) babosa (>= 1.0.2, < 2.0.0) @@ -52,7 +52,7 @@ 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.2) + tty-screen (~> 0.6.3) word_wrap (~> 1.0.0) xcodeproj (>= 1.5.2, < 2.0.0) xcpretty (>= 0.2.4, < 1.0.0) @@ -100,7 +100,7 @@ GEM nokogiri (1.8.1) mini_portile2 (~> 2.3.0) os (0.9.6) - plist (3.3.0) + plist (3.4.0) public_suffix (2.0.5) representable (3.0.4) declarative (< 0.1.0) @@ -119,14 +119,14 @@ GEM terminal-notifier (1.8.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) - tty-screen (0.6.3) + tty-screen (0.6.4) uber (0.1.0) unf (0.1.4) unf_ext unf_ext (0.0.7.4) unicode-display_width (1.3.0) word_wrap (1.0.0) - xcodeproj (1.5.3) + xcodeproj (1.5.4) CFPropertyList (~> 2.3.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) diff --git a/fastlane/Matchfile b/fastlane/Matchfile index 4f3f56994..a3748f78c 100644 --- a/fastlane/Matchfile +++ b/fastlane/Matchfile @@ -1,6 +1,4 @@ -git_url "git@github.com:mattermost/mattermost-mobile-private.git" - -type "development" # The default type, can be: appstore, adhoc, enterprise or development +#type "development" # The default type, can be: appstore, adhoc, enterprise or development # app_identifier ["tools.fastlane.app", "tools.fastlane.app2"] # username "user@fastlane.tools" # Your Apple Developer Portal username diff --git a/fastlane/env_vars_example b/fastlane/env_vars_example new file mode 100644 index 000000000..cef78eefc --- /dev/null +++ b/fastlane/env_vars_example @@ -0,0 +1,151 @@ +############ COMMON ############ +export LC_ALL="en_US.UTF-8" + +############ ANDROID ############ + +# Should we submit the app to be rollout in Google Play, use along with SUPPLY_TRACK +export SUBMIT_ANDROID_TO_GOOGLE_PLAY=false + +# Defines if the Android app should be built in release mode +export ANDROID_BUILD_FOR_RELEASE=false + +# Should we use the assets found in assets/release/icons/android +export ANDROID_REPLACE_ASSETS=false + +# Should we increment the Android app build number +export ANDROID_INCREMENT_BUILD_NUMBER=false + +# The message that will be used for committing the increment of the build number, build number will be appended to the end of this message +export ANDROID_COMMIT_INCREMENT_BUILD_NUMBER_MESSAGE="Bump Android build number to" + +# The name of the app as it is going to be shown in the Android home screen +export ANDROID_APP_NAME="Mattermost Beta" + +# The package Id for the Android app +export ANDROID_PACKAGE_ID=com.mattermost.rnbeta + +# The track of the application to use when submitting to Google Play, valid values are: alpha, beta, production +export SUPPLY_TRACK= + +# The package id of the application, should match ANDROID_PACKAGE_ID +export SUPPLY_PACKAGE_NAME=com.mattermost.rnbeta + +# The path to the service account json file used to authenticate with Google +export SUPPLY_JSON_KEY= + +############ IOS ############ + +# Should we run Fastlane's match to sync the provisioning profiles +export SYNC_IOS_PROVISIONING_PROFILES=false + +# Should we submit the app to TestFlight once the build completes +export SUBMIT_IOS_TO_TESTFLIGHT=false + +# Defines if the iOS app should be built in release mode +export IOS_BUILD_FOR_RELEASE=false + +# Should we use the assets found in assets/release/icons/ios +export IOS_REPLACE_ASSETS=false + +# Should we increment the iOS app build number +export IOS_INCREMENT_BUILD_NUMBER=false + +# The message that will be used for committing the increment of the build number, build number will be appended to the end of this message +export IOS_COMMIT_INCREMENT_BUILD_NUMBER_MESSAGE="Bump iOS build number to" + +# The name of the app as it is going to be shown in the iOS home screen +export IOS_APP_NAME="Mattermost Beta" + +# The Bundle Identifier for the main app +export IOS_MAIN_APP_IDENTIFIER=com.mattermost.rnbeta + +# The Bundle Identifier for the extension app +export IOS_EXTENSION_APP_IDENTIFIER=com.mattermost.rnbeta.MattermostShare + +# The iOS App Group identifier used to share data between the app and the extension +export IOS_APP_GROUP=group.com.mattermost.rnbeta + +# Method used to export the archive. Valid values are: app-store, ad-hoc, package, enterprise, development, developer-id +export IOS_BUILD_EXPORT_METHOD=app-store + +# Your Apple ID Username +export MATCH_USERNAME= + +# Your Apple ID Password +export MATCH_PASSWORD= + +# URL to the git repo containing all the certificates +export MATCH_GIT_URL= + +# The bundle identifier(s) of your app (comma-separated) +export MATCH_APP_IDENTIFIER=com.mattermost.rnbeta.MattermostShare,com.mattermost.rnbeta + +# Define the profile type. Valid values are: appstore, adhoc, development, enterprise +export MATCH_TYPE=adhoc + +# Make a shallow clone of the repository (truncate the history to 1 revision) +export MATCH_SHALLOW_CLONE=true + +# Skip generation of a README.md for the created git repository +export MATCH_SKIP_DOCS=true + +# The ID of your Developer Portal team +export FASTLANE_TEAM_ID= + +# Your Apple ID Username +export PILOT_USERNAME= + +# Don't wait for the build to process. +export PILOT_SKIP_WAITING_FOR_BUILD_PROCESSING=true + +############ ANALYTICS AND CRASH REPORT ############ + +# Your Segment API Key if you want to track analytics using segment.io +export SEGMENT_API_KEY= + +# If you want to enable sentry to collect crash reports +export SENTRY_ENABLED=false + +# Your sentry organization +export SENTRY_ORG= + +# The name of your iOS Mattermost project in Sentry +export SENTRY_PROJECT_IOS=mattermost-mobile-ios + +# The DSN for your iOS Mattermost project +export SENTRY_DSN_IOS= + +# The name of your Android Mattermost project in Sentry +export SENTRY_PROJECT_ANDROID=mattermost-mobile-android + +# The DSN for your Android Mattermost project +export SENTRY_DSN_ANDROID= + +# Your Sentry auth token +export SENTRY_AUTH_TOKEN= + + +############ GIT ############ +# Commit changes made by the increase build number to a remote git and optionally submit a Pull Request to Github +export COMMIT_CHANGES_TO_GIT=false + +# Reset your git branch for any changes made and checkout the master branch +export RESET_GIT_BRANCH=false + +# Ensure that there are no pending changes to be committed before building the app +export ENSURE_GIT_IS_CLEAN=true + +# The remote git where to submit the branch +export GIT_REMOTE=origin + +# The name of the local branch to be created before building the app +export GIT_LOCAL_BRANCH= + +# The name of the remote branch to be created when submitting the changes +export GIT_REMOTE_BRANCH=beta + +# The API Token in github in order to submit a Pull Request +export GITHUB_PULL_REQUEST_API_TOKEN= + +# The GitHub repo to submit the Pull Request against. +export GITHUB_PULL_REQUEST_REPO=mattermost/mattermost-mobile