diff --git a/.github/workflows/build-staging-android.yml b/.github/workflows/build-staging-android.yml new file mode 100644 index 0000000000..fbb686cbb8 --- /dev/null +++ b/.github/workflows/build-staging-android.yml @@ -0,0 +1,78 @@ +name: Build staging Android project +on: + push: + branches: + - master + +jobs: + build-ios: + name: Build Android + runs-on: macOS-latest + steps: + - name: Checkout project + uses: actions/checkout@v1 + - name: Set global env vars + run: | + echo "BUILD_ID=$(date +%s)" >> $GITHUB_ENV + echo "APP_ENVIRONMENT=staging" >> $GITHUB_ENV + - name: Decrypt env files + run: sh ./scripts/git-crypt-unlock.sh + env: + GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }} + - name: install node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + - name: Get potential cached node_modules + uses: actions/cache@v2 + id: modules-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/patches/**.patch') }} + - name: Install node_modules + if: steps.modules-cache.outputs.cache-hit != 'true' + run: yarn install + - name: Bundle install, fastlane dependencies + run: bundle install + - name: Set environment + run: sh ./scripts/override-environment.sh $APP_ENVIRONMENT + - name: Override native config files + run: sh ./scripts/override-config-files.sh + - name: Get potential cached APK + uses: actions/cache@v2 + id: apk-cache + with: + path: 'app-staging.apk' + key: ${{ runner.os }}-android-cache-${{ hashFiles('android/**') }} + - name: Get Android keystore + run: sh ./scripts/android/create-keystore-file.sh + env: + GPG_KEYSTORE_FILE: ${{ secrets.GPG_KEYSTORE_FILE }} + GPG_KEYSTORE_PASS: ${{ secrets.GPG_KEYSTORE_PASS }} + - name: Generate icons + if: steps.apk-cache.outputs.cache-hit != 'true' + run: brew install imagemagick && yarn app-icon generate -i icon.qa.png --platforms=android --rounded none && yarn app-icon generate -i icon.qa.round.png --platforms=android --rounded only + - name: Run fastlane build + if: steps.apk-cache.outputs.cache-hit != 'true' + run: yarn build:android + env: + KEYSTORE_PASS: ${{ secrets.ATB_KEYSTORE_PASS }} + KEY_PASS: ${{ secrets.ATB_KEY_PASS }} + KEY_ALIAS: ${{ secrets.ATB_KEY_ALIAS }} + - name: Replace apk bundle + if: steps.apk-cache.outputs.cache-hit == 'true' + run: sh ./scripts/android/replace-bundle.sh + env: + APK_FILE_NAME: app-staging.apk + KEYSTORE_FILE: keystore.jks + KEYSTORE_PASS: ${{ secrets.ATB_KEYSTORE_PASS }} + KEY_PASS: ${{ secrets.ATB_KEY_PASS }} + KEY_ALIAS: ${{ secrets.ATB_KEY_ALIAS }} + - name: Distribute to AppCenter + run: yarn appcenter:android + env: + APPCENTER_API_KEY: ${{ secrets.APPCENTER_ANDROID_API_KEY }} + - name: Upload bundle and source maps + run: sh ./scripts/android/upload-sourcemaps.sh + env: + BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }} diff --git a/.github/workflows/build-staging-ios.yml b/.github/workflows/build-staging-ios.yml new file mode 100644 index 0000000000..4ccdd7c047 --- /dev/null +++ b/.github/workflows/build-staging-ios.yml @@ -0,0 +1,83 @@ +name: Build staging iOS project +on: + push: + branches: + - master + +jobs: + build-ios: + name: Build iOS + runs-on: macOS-latest + steps: + - name: Checkout project + uses: actions/checkout@v1 + - name: Set global env vars + run: | + echo "BUILD_ID=$(date +%s)" >> $GITHUB_ENV + echo "APP_ENVIRONMENT=staging" >> $GITHUB_ENV + - name: Decrypt env files + run: sh ./scripts/git-crypt-unlock.sh + env: + GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }} + - name: install node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + - name: Get potential cached node_modules + uses: actions/cache@v2 + id: modules-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/patches/**.patch') }} + - name: Install node_modules + if: steps.modules-cache.outputs.cache-hit != 'true' + run: yarn install + - name: Bundle Install + run: bundle install + - name: Set environment + run: sh ./scripts/override-environment.sh $APP_ENVIRONMENT + - name: Override native config files + run: sh ./scripts/override-config-files.sh + - uses: webfactory/ssh-agent@v0.4.0 + with: + ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} + - name: Get potential cached ipa + uses: actions/cache@v2 + id: ipa-cache + with: + path: 'AtB.ipa' + key: ${{ runner.os }}-ios-cache-${{ hashFiles('ios/**') }} + - name: Run fastlane cert match + run: yarn cert:ios + env: + FASTLANE_MATCH_URL: ${{ secrets.FASTLANE_MATCH_URL }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + - name: Generate icons + if: steps.ipa-cache.outputs.cache-hit != 'true' + run: brew install imagemagick && yarn app-icon generate -i icon.qa.png --platforms=ios + - name: Run fastlane build + if: steps.ipa-cache.outputs.cache-hit != 'true' + run: yarn build:ios + - name: Replace ipa bundle + if: steps.ipa-cache.outputs.cache-hit == 'true' + run: sh ./scripts/ios/replace-bundle.sh + env: + IPA_FILE_NAME: 'AtB.ipa' + APP_NAME: 'AtB.app' + CODE_SIGN_IDENTITY: ${{ secrets.IOS_CODE_SIGN_IDENTITY }} + - name: Distribute to AppCenter + run: yarn appcenter:ios + env: + APPCENTER_API_KEY: ${{ secrets.APPCENTER_IOS_API_KEY }} + - name: Create bundle and source maps + if: steps.ipa-cache.outputs.cache-hit != 'true' + run: sh ./scripts/ios/create-sourcemaps.sh + - name: Upload bundle and source maps + run: sh ./scripts/ios/upload-sourcemaps.sh + env: + BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }} + - name: Upload dSYMs + if: steps.ipa-cache.outputs.cache-hit != 'true' + run: sh ./scripts/ios/upload-dsyms.sh + env: + BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }} diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..b38f3c1ff3 --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +source "https://rubygems.org" + +gem "fastlane" +gem "cocoapods" + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..40cf08e212 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,245 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.2) + activesupport (4.2.11.3) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + algoliasearch (1.27.3) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + aws-eventstream (1.1.0) + aws-partitions (1.354.0) + aws-sdk-core (3.104.3) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.239.0) + aws-sigv4 (~> 1.1) + jmespath (~> 1.0) + aws-sdk-kms (1.36.0) + aws-sdk-core (~> 3, >= 3.99.0) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.78.0) + aws-sdk-core (~> 3, >= 3.104.3) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.2.1) + aws-eventstream (~> 1, >= 1.0.2) + babosa (1.0.3) + claide (1.0.3) + cocoapods (1.9.3) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.9.3) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.2.2, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.6.6) + nap (~> 1.0) + ruby-macho (~> 1.4) + xcodeproj (>= 1.14.0, < 2.0) + cocoapods-core (1.9.3) + activesupport (>= 4.0.2, < 6) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.4) + cocoapods-downloader (1.4.0) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.0) + cocoapods-stats (1.1.0) + cocoapods-trunk (1.5.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) + colored (1.2) + colored2 (3.1.2) + commander-fastlane (4.4.6) + highline (~> 1.7.2) + concurrent-ruby (1.1.7) + declarative (0.0.20) + declarative-option (0.1.0) + digest-crc (0.6.1) + rake (~> 13.0) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.7.6) + emoji_regex (3.0.0) + escape (0.0.4) + ethon (0.12.0) + ffi (>= 1.3.0) + excon (0.76.0) + faraday (1.0.1) + multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) + faraday_middleware (1.0.0) + faraday (~> 1.0) + fastimage (2.2.0) + fastlane (2.156.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.3, < 3.0.0) + aws-sdk-s3 (~> 1.0) + babosa (>= 1.0.3, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander-fastlane (>= 4.4.6, < 5.0.0) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 4.0) + excon (>= 0.71.0, < 1.0.0) + faraday (~> 1.0) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 1.0) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-api-client (>= 0.37.0, < 0.39.0) + google-cloud-storage (>= 1.15.0, < 2.0.0) + highline (>= 1.7.2, < 2.0.0) + json (< 3.0.0) + jwt (>= 2.1.0, < 3) + mini_magick (>= 4.9.4, < 5.0.0) + multipart-post (~> 2.0.0) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 2.0.0, < 3.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + slack-notifier (>= 2.0.0, < 3.0.0) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.13.0, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) + fastlane-plugin-appcenter (1.10.0) + ffi (1.13.1) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + google-api-client (0.38.0) + addressable (~> 2.5, >= 2.5.1) + googleauth (~> 0.9) + httpclient (>= 2.8.1, < 3.0) + mini_mime (~> 1.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + signet (~> 0.12) + google-cloud-core (1.5.0) + google-cloud-env (~> 1.0) + google-cloud-errors (~> 1.0) + google-cloud-env (1.3.3) + faraday (>= 0.17.3, < 2.0) + google-cloud-errors (1.0.1) + google-cloud-storage (1.27.0) + addressable (~> 2.5) + digest-crc (~> 0.4) + google-api-client (~> 0.33) + google-cloud-core (~> 1.2) + googleauth (~> 0.9) + mini_mime (~> 1.0) + googleauth (0.13.1) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.4, < 3.0) + memoist (~> 0.16) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (~> 0.14) + highline (1.7.10) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + jmespath (1.4.0) + json (2.3.1) + jwt (2.2.1) + memoist (0.16.2) + mini_magick (4.10.1) + mini_mime (1.0.2) + minitest (5.14.1) + molinillo (0.6.6) + multi_json (1.15.0) + multipart-post (2.0.0) + nanaimo (0.3.0) + nap (1.1.0) + naturally (2.2.0) + netrc (0.11.0) + os (1.1.1) + plist (3.5.0) + public_suffix (4.0.5) + rake (13.0.1) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rouge (2.0.7) + ruby-macho (1.4.0) + rubyzip (2.3.0) + security (0.1.3) + signet (0.14.0) + addressable (~> 2.3) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.8) + CFPropertyList + naturally + slack-notifier (2.3.2) + terminal-notifier (2.0.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + thread_safe (0.3.6) + tty-cursor (0.7.1) + tty-screen (0.8.1) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) + typhoeus (1.4.0) + ethon (>= 0.9.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.7) + unicode-display_width (1.7.0) + word_wrap (1.0.0) + xcodeproj (1.17.1) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.0) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods + fastlane + fastlane-plugin-appcenter + +BUNDLED WITH + 2.1.4 diff --git a/android/app/build.gradle b/android/app/build.gradle index 2b53485042..34586450c8 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -138,7 +138,7 @@ android { applicationId "no.mittatb" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 1 + versionCode project.hasProperty("versionCode") ? project.getProperty("versionCode") as Integer : 1 versionName "1.1" multiDexEnabled true } diff --git a/appcenter-pre-build.sh b/appcenter-pre-build.sh index e47076a41b..5519e668b9 100644 --- a/appcenter-pre-build.sh +++ b/appcenter-pre-build.sh @@ -1,19 +1,15 @@ #!/bin/bash +echo "Attempting to decrypt env" +sh ./scripts/git-crypt-unlock.sh $GIT_CRYPT_KEY + echo "Installing pre-build dependencies" -brew install openssl git-crypt findutils xmlstarlet # for git-crypt -# git-crypt + openssl for decryption +brew installfindutils xmlstarlet # findutils for gxargs which is used to load environment variables from .env file # xmlstarlet to edit androidmanifest -echo "Decoding git-crypt key" -echo $GIT_CRYPT_KEY | openssl base64 -d -A -out mittatb.key - -echo "Unlocking repository sensitive files" -git-crypt unlock mittatb.key - echo "Attempting to override environment: $APP_ENVIRONMENT" -sh ./override-environment.sh $APP_ENVIRONMENT +sh ./scripts/override-environment.sh $APP_ENVIRONMENT echo "Loading all env variables from .env file" export $(grep -v '^#' .env | gxargs -d '\n') @@ -71,18 +67,18 @@ if [[ "$APP_ENVIRONMENT" = "staging" || "$APP_ENVIRONMENT" = "prodstaging" ]]; t fi fi -if [ "$ENABLE_E2E" = true ]; then - echo "Install E2E tools" - brew tap wix/brew - brew update - brew install applesimutils +# if [ "$ENABLE_E2E" = true ]; then +# echo "Install E2E tools" +# brew tap wix/brew +# brew update +# brew install applesimutils - echo "Install pods" - cd ios; pod install; cd .. +# echo "Install pods" +# cd ios; pod install; cd .. - echo "Build detox E2E tests" - npx detox build --configuration ios.sim.release +# echo "Build detox E2E tests" +# npx detox build --configuration ios.sim.release - echo "Run detox E2E tests" - npx detox test --configuration ios.sim.release --cleanup -fi \ No newline at end of file +# echo "Run detox E2E tests" +# npx detox test --configuration ios.sim.release --cleanup +# fi \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000000..bdf02d51fe --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,114 @@ +fastlane_version '2.142.0' + +before_all do + # ensure_git_status_clean + # git_pull +end + +platform :ios do + desc 'Match certificates' + lane :get_cert do + ensure_env_vars( + env_vars: ['MATCH_PASSWORD', 'FASTLANE_MATCH_URL'] + ) + if is_ci + create_keychain( + name: "CI", + password: ENV["MATCH_PASSWORD"], + default_keychain: true, + unlock: true, + timeout: 3600, + lock_when_sleeps: false + ) + match( + type: "adhoc", + readonly: true, + keychain_name: "CI", + keychain_password: ENV["MATCH_PASSWORD"] + ) + else + match(type: 'adhoc', readonly: true) + end + end + # iOS Lanes + desc 'Build the iOS application.' + lane :build do + ensure_env_vars( + env_vars: ['BUILD_ID'] + ) + increment_build_number( + build_number: ENV["BUILD_ID"], + xcodeproj: './ios/atb.xcodeproj/' + ) + update_code_signing_settings( + use_automatic_signing: false, + bundle_identifier:"no.mittatb.staging", + code_sign_identity:"iPhone Distribution", + profile_name: "match AdHoc no.mittatb.staging", + path: "./ios/atb.xcodeproj" + ) + cocoapods(podfile: './ios/Podfile') + build_app( + scheme: 'atb', + configuration: 'Release', + export_method: "ad-hoc", + workspace: './ios/atb.xcworkspace' + ) + end + + desc 'Upload the build to AppCenter' + lane :appcenter do + ensure_env_vars( + env_vars: ['APPCENTER_API_KEY'] + ) + appcenter_upload( + api_token: ENV["APPCENTER_API_KEY"], + owner_name: "AtB-AS", + app_name: "MittAtb-1", + owner_type: "organization", + file: "AtB.ipa", + notify_testers: false + ) + end +end + +platform :android do + desc 'Upload the build to AppCenter' + + lane :build do + ensure_env_vars( + env_vars: ['BUILD_ID', 'KEYSTORE_PASS', 'KEY_ALIAS', 'KEY_PASS'] + ) + gradle(task: 'clean', project_dir: 'android/') + gradle( + task: 'assemble', + build_type: 'staging', + project_dir: 'android/', + print_command: false, #don't print my passwords please + properties: { + "versionCode" => ENV["BUILD_ID"], + "android.injected.signing.store.file" => "./keystore.jks", + "android.injected.signing.store.password" => ENV["KEYSTORE_PASS"], + "android.injected.signing.key.alias" => ENV["KEY_ALIAS"], + "android.injected.signing.key.password" => ENV["KEY_PASS"], + }) + sh("cp", "../android/app/build/outputs/apk/staging/app-staging.apk", "../") + sh("mkdir", "-p", "../bundle") + sh("cp", "../android/app/build/generated/assets/react/staging/index.android.bundle", "../bundle") + sh("cp", "../android/app/build/generated/sourcemaps/react/staging/index.android.bundle.map", "../bundle") + end + + lane :appcenter do + ensure_env_vars( + env_vars: ['APPCENTER_API_KEY'] + ) + appcenter_upload( + api_token: ENV["APPCENTER_API_KEY"], + owner_name: "AtB-AS", + app_name: "MittAtb", + owner_type: "organization", + file: "app-staging.apk", + notify_testers: false + ) + end +end \ No newline at end of file diff --git a/fastlane/Matchfile b/fastlane/Matchfile new file mode 100644 index 0000000000..763145c67a --- /dev/null +++ b/fastlane/Matchfile @@ -0,0 +1,7 @@ +git_url(ENV["FASTLANE_MATCH_URL"]) + +app_identifier(["no.mittatb.staging"]) + +storage_mode("git") + +type("adhoc") # The default type, can be: appstore, adhoc, enterprise or development \ No newline at end of file diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile new file mode 100644 index 0000000000..756bff8e13 --- /dev/null +++ b/fastlane/Pluginfile @@ -0,0 +1,5 @@ +# Autogenerated by fastlane +# +# Ensure this file is checked in to source control! + +gem 'fastlane-plugin-appcenter' diff --git a/fastlane/README.md b/fastlane/README.md new file mode 100644 index 0000000000..83edd1b05e --- /dev/null +++ b/fastlane/README.md @@ -0,0 +1,53 @@ +fastlane documentation +================ +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +``` +xcode-select --install +``` + +Install _fastlane_ using +``` +[sudo] gem install fastlane -NV +``` +or alternatively using `brew install fastlane` + +# Available Actions +## iOS +### ios get_cert +``` +fastlane ios get_cert +``` +Match certificates +### ios build +``` +fastlane ios build +``` +Build the iOS application. +### ios appcenter +``` +fastlane ios appcenter +``` +Upload the build to AppCenter + +---- + +## Android +### android build +``` +fastlane android build +``` +Upload the build to AppCenter +### android appcenter +``` +fastlane android appcenter +``` + + +---- + +This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run. +More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). +The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/icon.qa.png b/icon.qa.png new file mode 100644 index 0000000000..ea8522d8c0 Binary files /dev/null and b/icon.qa.png differ diff --git a/icon.qa.round.png b/icon.qa.round.png new file mode 100644 index 0000000000..f00b718855 Binary files /dev/null and b/icon.qa.round.png differ diff --git a/ios/atb.xcodeproj/project.pbxproj b/ios/atb.xcodeproj/project.pbxproj index ca1f2b1d81..eb55127014 100644 --- a/ios/atb.xcodeproj/project.pbxproj +++ b/ios/atb.xcodeproj/project.pbxproj @@ -317,6 +317,7 @@ 13B07F861A680F5B00A75B9A = { DevelopmentTeam = CSV447Q97L; LastSwiftMigration = 1140; + ProvisioningStyle = Manual; }; 2D02E47A1E0B4A5D006451C7 = { CreatedOnToolsVersion = 8.2.1; @@ -716,6 +717,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = CSV447Q97L; ENABLE_BITCODE = NO; @@ -733,6 +735,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = no.mittatb.debug; PRODUCT_NAME = AtB; + PROVISIONING_PROFILE_SPECIFIER = "match Development no.mittatb.debug"; SWIFT_OBJC_BRIDGING_HEADER = "atb-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -746,6 +749,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = CSV447Q97L; INFOPLIST_FILE = atb/Info.plist; @@ -758,6 +762,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = no.mittatb.debug; PRODUCT_NAME = AtB; + PROVISIONING_PROFILE_SPECIFIER = "match Development no.mittatb.debug"; SWIFT_OBJC_BRIDGING_HEADER = "atb-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; diff --git a/package.json b/package.json index ce97227071..9c09ae3419 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,12 @@ "release-draft": "sh tools/release/release-draft.sh", "generate-svg-mono-icons": "svgr --config-file .svgrrc.mono-icons.yml -d ./src/assets/svg/icons ./assets/svgs/mono-icons && prettier --write ./src/assets/svg/icons", "generate-svg-color": "svgr --config-file .svgrrc.color.yml -d ./src/assets/svg/ ./assets/svgs/color && prettier --write ./src/assets/svg/", - "generate-svgs": "yarn generate-svg-mono-icons && yarn generate-svg-color" + "generate-svgs": "yarn generate-svg-mono-icons && yarn generate-svg-color", + "build:ios": "fastlane ios build", + "appcenter:ios": "fastlane ios appcenter", + "cert:ios": "fastlane ios get_cert", + "build:android": "fastlane android build", + "appcenter:android": "fastlane android appcenter" }, "dependencies": { "@bugsnag/react-native": "^7.5.0", diff --git a/scripts/android/create-keystore-file.sh b/scripts/android/create-keystore-file.sh new file mode 100644 index 0000000000..52e4be7ed5 --- /dev/null +++ b/scripts/android/create-keystore-file.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [[ + -z "${GPG_KEYSTORE_FILE}" + || -z "${GPG_KEYSTORE_PASS}" + ]]; then + echo "Argument error!" + echo "Expected two env variables: + - GPG_KEYSTORE_FILE + - GPG_KEYSTORE_PASS" + exit 1 +else + echo "$GPG_KEYSTORE_FILE" > atb.keystore.asc + gpg -d --passphrase "$GPG_KEYSTORE_PASS" --batch atb.keystore.asc > keystore.jks + cp keystore.jks android/app/keystore.jks +fi \ No newline at end of file diff --git a/scripts/android/replace-bundle.sh b/scripts/android/replace-bundle.sh new file mode 100644 index 0000000000..b50a9a96d3 --- /dev/null +++ b/scripts/android/replace-bundle.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Security wise trying to avoid secrets being sent in via command line to the script +# Safer to do it by env variable according to Github Actions docs + +if [[ + -z "${APK_FILE_NAME}" + || -z "${KEYSTORE_FILE}" + || -z "${KEYSTORE_PASS}" + || -z "${KEY_PASS}" + || -z "${KEY_ALIAS}" + || -z "${BUILD_ID}" + ]]; then + echo "Argument error!" + echo "Expected six env variables: + - BUILD_ID + - APK_FILE_NAME + - KEYSTORE_FILE + - KEYSTORE_PASS + - KEY_PASS + - KEY_ALIAS" + + exit 1 +else + mkdir -p bundle + + echo "Re-generate bundle" + npx react-native bundle --platform android --dev false --reset-cache --entry-file index.js --bundle-output bundle/temp.bundle --sourcemap-output bundle/temp.bundle.map + + echo "Compile JS to Hermes Bytecode" + ./node_modules/hermes-engine/osx-bin/hermesc -emit-binary -source-map=bundle/temp.bundle.map -output-source-map -out bundle/index.android.bundle bundle/temp.bundle + + brew install apktool yq + + echo "Decompile Android APK" + apktool d $APK_FILE_NAME --output decompiled-apk + + echo "Replace bundle in decompiled APK" + rm decompiled-apk/assets/index.android.bundle + cp bundle/index.android.bundle decompiled-apk/assets/ + + echo "Set version code to build id: $BUILD_ID" + yq write decompiled-apk/apktool.yml versionInfo.versionCode $BUILD_ID + + echo "Re-compile Android APK" + apktool b decompiled-apk -o temp-$APK_FILE_NAME + + echo "Re-sign APK" + jarsigner -keystore $KEYSTORE_FILE -storepass "$KEYSTORE_PASS" -keypass "$KEY_PASS" -verbose -sigalg MD5withRSA -digestalg SHA1 -signedjar temp-$APK_FILE_NAME temp-$APK_FILE_NAME $KEY_ALIAS + + echo "The APK must be aligned to 4 byte boundaries to work on Android" + ~/Library/Android/sdk/build-tools/29.0.2/zipalign -f 4 temp-$APK_FILE_NAME $APK_FILE_NAME +fi \ No newline at end of file diff --git a/scripts/android/upload-sourcemaps.sh b/scripts/android/upload-sourcemaps.sh new file mode 100644 index 0000000000..da9865a8e0 --- /dev/null +++ b/scripts/android/upload-sourcemaps.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [[ + -z "${BUGSNAG_API_KEY}" + || -z "${BUILD_ID}" + ]]; then + echo "Argument error!" + echo "Expected two env variables: + - BUGSNAG_API_KEY + - BUILD_ID" + + exit 1 +else +echo "Generating and uploading Android source maps" + npx bugsnag-sourcemaps upload \ + --api-key=$BUGSNAG_API_KEY \ + --app-version=$BUILD_ID \ + --minifiedFile=bundle/index.android.bundle \ + --source-map=bundle/index.android.bundle.map \ + --minified-url=index.android.bundle \ + --upload-sources \ + --overwrite +fi \ No newline at end of file diff --git a/scripts/git-crypt-unlock.sh b/scripts/git-crypt-unlock.sh new file mode 100644 index 0000000000..3e7043b7a3 --- /dev/null +++ b/scripts/git-crypt-unlock.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [[ + -z "${GIT_CRYPT_KEY}" + ]]; then + echo "Argument error!" + echo "Expected one env variables: + - GIT_CRYPT_KEY" + exit 1 +else + echo "Installing pre-build dependencies" + brew install openssl git-crypt + # git-crypt + openssl for decryption + + echo "Decoding git-crypt key" + echo $GIT_CRYPT_KEY | openssl base64 -d -A -out mittatb.key + + echo "Unlocking repository sensitive files" + git-crypt unlock mittatb.key + + echo "Delete key" + rm mittatb.key +fi \ No newline at end of file diff --git a/scripts/ios/create-sourcemaps.sh b/scripts/ios/create-sourcemaps.sh new file mode 100644 index 0000000000..874fcbe6ac --- /dev/null +++ b/scripts/ios/create-sourcemaps.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# iOS doesn't output source maps when bundling normally +npx react-native bundle --platform ios --dev false --reset-cache --entry-file index.js --bundle-output bundle/main.jsbundle --sourcemap-output bundle/main.jsbundle.map \ No newline at end of file diff --git a/scripts/ios/replace-bundle.sh b/scripts/ios/replace-bundle.sh new file mode 100644 index 0000000000..505051387c --- /dev/null +++ b/scripts/ios/replace-bundle.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Security wise trying to avoid secrets being sent in via command line to the script +# Safer to do it by env variable according to Github Actions docs + +if [[ + -z "${IPA_FILE_NAME}" + || -z "${APP_NAME}" + || -z "${CODE_SIGN_IDENTITY}" + || -z "${BUILD_ID}" + ]]; then + echo "Argument error!" + echo "Expected four env variables: + - BUILD_ID + - IPA_FILE_NAME + - APP_NAME + - CODE_SIGN_IDENTITY" + exit 1 +else + mkdir -p bundle + + echo "Re-generate bundle" + npx react-native bundle --platform ios --dev false --reset-cache --entry-file index.js --bundle-output bundle/main.jsbundle --sourcemap-output bundle/main.jsbundle.map + + unzip $IPA_FILE_NAME + + echo "Delete old signature" + rm -rf Payload/$APP_NAME/\_CodeSignature + + echo "Replace bundle" + rm Payload/$APP_NAME/main.jsbundle + cp bundle/main.jsbundle Payload/$APP_NAME/ + + echo "Set CFBundleVersion to build id: $BUILD_ID" + plutil -replace CFBundleVersion -string "${BUILD_ID}" "Payload/$APP_NAME/Info.plist" + + echo "Generated entitlements file from ipa content" + codesign -d --entitlements :- "Payload/$APP_NAME" > entitlements.plist + + echo "Re-sign new Payload" + codesign -f -s "$CODE_SIGN_IDENTITY" --entitlements entitlements.plist Payload/$APP_NAME/ + + echo "Generate new ipa" + zip -qr $IPA_FILE_NAME Payload/ +fi \ No newline at end of file diff --git a/scripts/ios/upload-dsyms.sh b/scripts/ios/upload-dsyms.sh new file mode 100644 index 0000000000..939e3a805d --- /dev/null +++ b/scripts/ios/upload-dsyms.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [[ + -z "${BUGSNAG_API_KEY}" + ]]; then + echo "Argument error!" + echo "Expected one env variables: + - BUGSNAG_API_KEY" + + exit 1 +else + echo "Uploading iOS dsyms" + curl --http1.1 https://upload.bugsnag.com/ \ + -F apiKey=$BUGSNAG_API_KEY \ + -F dsym=@AtB.app.dSYM.zip +fi \ No newline at end of file diff --git a/scripts/ios/upload-sourcemaps.sh b/scripts/ios/upload-sourcemaps.sh new file mode 100644 index 0000000000..b3ac70bbdc --- /dev/null +++ b/scripts/ios/upload-sourcemaps.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [[ + -z "${BUGSNAG_API_KEY}" + || -z "${BUILD_ID}" + ]]; then + echo "Argument error!" + echo "Expected two env variables: + - BUGSNAG_API_KEY + - BUILD_ID" + + exit 1 +else +echo "Uploading iOS source maps" + curl --http1.1 https://upload.bugsnag.com/react-native-source-map \ + -F apiKey=$BUGSNAG_API_KEY \ + -F appVersion=1.0 \ + -F appBundleVersion=$BUILD_ID \ + -F dev=false \ + -F platform=ios \ + -F sourceMap=@bundle/main.jsbundle.map \ + -F bundle=@bundle/main.jsbundle \ + -F projectRoot=`pwd` +fi \ No newline at end of file diff --git a/scripts/override-config-files.sh b/scripts/override-config-files.sh new file mode 100644 index 0000000000..603f1e4620 --- /dev/null +++ b/scripts/override-config-files.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +echo "Installing pre-build dependencies" +brew install findutils xmlstarlet # for git-crypt +# findutils for gxargs which is used to load environment variables from .env file +# xmlstarlet to edit androidmanifest + +echo "Loading all env variables from .env file" +export $(grep -v '^#' .env | gxargs -d '\n') > /dev/null 2>&1 + +echo "Currently set ios bundle id: $IOS_BUNDLE_IDENTIFIER" + +echo "Adding Bugsnag API key and release stage to Info.plist" +/usr/libexec/PlistBuddy -c "Add :BugsnagAPIKey string $BUGSNAG_API_KEY" ./ios/atb/Info.plist +/usr/libexec/PlistBuddy -c "Add :BugsnagReleaseStage string $BUGSNAG_RELEASE_STAGE" ./ios/atb/Info.plist + +echo "Adding Bugsnag API key and release stage to AndroidManifest.xml" +xmlstarlet edit --inplace --omit-decl \ + -s //manifest/application -t elem -n "bugsnagkey" \ + -i //manifest/application/bugsnagkey -t attr -n "android:name" -v "com.bugsnag.android.API_KEY" \ + -i //manifest/application/bugsnagkey -t attr -n "android:value" -v "$BUGSNAG_API_KEY" \ + -r //manifest/application/bugsnagkey -v meta-data \ + -s //manifest/application -t elem -n "bugsnagreleasestage" \ + -i //manifest/application/bugsnagreleasestage -t attr -n "android:name" -v "com.bugsnag.android.RELEASE_STAGE" \ + -i //manifest/application/bugsnagreleasestage -t attr -n "android:value" -v "$BUGSNAG_RELEASE_STAGE" \ + -r //manifest/application/bugsnagreleasestage -v meta-data \ + android/app/src/main/AndroidManifest.xml + +echo "Set Intercom API key and App ID in Intercom.plist" +/usr/libexec/PlistBuddy -c "Set :IntercomApiKey $INTERCOM_IOS_API_KEY" ./ios/atb/Intercom.plist +/usr/libexec/PlistBuddy -c "Set :IntercomAppId $INTERCOM_APP_ID" ./ios/atb/Intercom.plist + +echo "Set Intercom API key and App ID in Intercom.xml" +xmlstarlet edit --inplace --omit-decl \ + -u "//resources/string[@name='IntercomApiKey']" -v "$INTERCOM_ANDROID_API_KEY" \ + -u "//resources/string[@name='IntercomAppId']" -v "$INTERCOM_APP_ID" \ + android/app/src/main/res/values/Intercom.xml diff --git a/override-environment.sh b/scripts/override-environment.sh similarity index 100% rename from override-environment.sh rename to scripts/override-environment.sh diff --git a/src/screens/Ticketing/Payment/CreditCard/index.tsx b/src/screens/Ticketing/Payment/CreditCard/index.tsx index e53a38721f..206ea2ef05 100644 --- a/src/screens/Ticketing/Payment/CreditCard/index.tsx +++ b/src/screens/Ticketing/Payment/CreditCard/index.tsx @@ -10,6 +10,7 @@ import { } from 'react-native-webview/lib/WebViewTypes'; import {capturePayment} from '../../../../api'; import {useTicketState, PaymentFailedReason} from '../../TicketContext'; +import {API_BASE_URL} from '@env'; type Props = { navigation: StackNavigationProp;