MM-12215 Make deep link URL prefix configurable for Release/Debug (#3767)

Default deep link URL prefix: `mattermost-beta`

To set to `mattermost-mobile` (or anything else, for that matter) in production releases, set fastlane ENV var `DEEPLINK_PREFIX` to `mattermost-mobile`
This commit is contained in:
Amit Uttam 2020-01-09 16:00:20 -03:00 committed by GitHub
parent 422fc5ee4a
commit a17983c1e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 7 deletions

View file

@ -40,7 +40,7 @@
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mattermost" />
<data android:scheme="mattermost-beta" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

View file

@ -9,6 +9,7 @@ import {Files} from 'mattermost-redux/constants';
import {DeepLinkTypes} from 'app/constants';
const ytRegex = /(?:http|https):\/\/(?:www\.|m\.)?(?:(?:youtube\.com\/(?:(?:v\/)|(?:(?:watch|embed\/watch)(?:\/|.*v=))|(?:embed\/)|(?:user\/[^/]+\/u\/[0-9]\/)))|(?:youtu\.be\/))([^#&?]*)/;
const APP_SCHEME = 'mattermost-beta';
export function isValidUrl(url = '') {
const regex = /^https?:\/\//i;
@ -103,7 +104,7 @@ export function matchDeepLink(url, serverURL, siteURL) {
return null;
}
const linkRoot = `(?:${escapeRegex('mattermost:/')}|${escapeRegex(serverURL)}|${escapeRegex(siteURL)})?`;
const linkRoot = `(?:${escapeRegex(APP_SCHEME)}:\\/|${escapeRegex(serverURL)}|${escapeRegex(siteURL)})?`;
let match = new RegExp('^' + linkRoot + '\\/([^\\/]+)\\/channels\\/(\\S+)').exec(url);

View file

@ -167,6 +167,14 @@ lane :configure do
# Save the config.json file
save_config_json('../dist/assets/config.json', json)
# Set deep link prefix for URL lookups
app_scheme = ENV['APP_SCHEME'] || 'mattermost-beta'
find_replace_string(
path_to_file: './app/utils/url.js',
old_string: "APP_SCHEME = 'mattermost-beta'",
new_string: "APP_SCHEME = '#{app_scheme}'",
)
configured = true
end
@ -276,7 +284,7 @@ end
desc 'Create GitHub release'
lane :github do
tag = ENV['CIRCLE_TAG'] || ENV['TAG']
if tag
version = get_version_number(xcodeproj: './ios/Mattermost.xcodeproj', target: 'Mattermost')
build = get_build_number(xcodeproj: './ios/Mattermost.xcodeproj')
@ -330,6 +338,7 @@ platform :ios do
ENV['APP_NAME'] = 'Mattermost'
ENV['REPLACE_ASSETS'] = 'true'
ENV['BUILD_FOR_RELEASE'] = 'true'
ENV['APP_SCHEME'] = 'mattermost-mobile'
update_identifiers
replace_assets
@ -392,6 +401,17 @@ platform :ios do
new_string: app_bundle_id
)
# Set the deep link prefix
app_scheme = ENV['APP_SCHEME'] || 'mattermost-beta'
update_info_plist(
xcodeproj: './ios/Mattermost.xcodeproj',
plist_path: 'Mattermost/Info.plist',
block: proc do |plist|
urlScheme = plist["CFBundleURLTypes"].find{|scheme| scheme["CFBundleURLName"] == "com.mattermost"}
urlScheme[:CFBundleURLSchemes] = [app_scheme]
end
)
# If set update the development team
unless ENV['FASTLANE_TEAM_ID'].nil? || ENV['FASTLANE_TEAM_ID'].empty?
update_project_team(
@ -420,7 +440,6 @@ platform :ios do
new_string: app_group_id
)
update_app_group_identifiers(
entitlements_file: './ios/MattermostShare/MattermostShare.entitlements',
app_group_identifiers: [app_group_id]
@ -490,7 +509,7 @@ platform :ios do
end
end
def build_ios()
def build_ios
app_name = ENV['APP_NAME'] || 'Mattermost Beta'
app_name_sub = app_name.gsub(" ", "_")
config_mode = ENV['BUILD_FOR_RELEASE'] == 'true' ? 'Release' : 'Debug'
@ -538,6 +557,7 @@ platform :android do
ENV['APP_NAME'] = 'Mattermost'
ENV['REPLACE_ASSETS'] = 'true'
ENV['BUILD_FOR_RELEASE'] = 'true'
ENV['APP_SCHEME'] = 'mattermost-mobile'
update_identifiers
replace_assets
@ -585,6 +605,13 @@ platform :android do
android_change_package_identifier(newIdentifier: package_id, manifest: './android/app/src/main/AndroidManifest.xml')
android_update_application_id(app_folder_name: 'android/app', application_id: package_id)
app_scheme = ENV['APP_SCHEME'] || 'mattermost-beta'
find_replace_string(
path_to_file: "./android/app/src/main/AndroidManifest.xml",
old_string: 'scheme="mattermost-beta"',
new_string: "scheme=\'#{app_scheme}\'"
)
beta_dir = './android/app/src/main/java/com/mattermost/rnbeta/'
release_dir = "./android/app/src/main/java/#{package_id.gsub '.', '/'}/"
if ENV['BUILD_FOR_RELEASE'] == 'true'
@ -661,7 +688,7 @@ platform :android do
})
end
def build_android()
def build_android
config_mode = ENV['BUILD_FOR_RELEASE'] == 'true' ? 'Release' : 'Debug'
gradle(

View file

@ -5,6 +5,7 @@ export BRANCH_TO_BUILD=master
export GIT_LOCAL_BRANCH=build
export APP_NAME="Mattermost Beta"
export APP_SCHEME=mattermost-beta
#export INCREMENT_BUILD_NUMBER=false
## This sets the version number ex: 1.22.0 if not set it uses the one in the code base

View file

@ -29,7 +29,7 @@
<string>com.mattermost</string>
<key>CFBundleURLSchemes</key>
<array>
<string>mattermost</string>
<string>mattermost-beta</string>
</array>
</dict>
</array>