Skip to content

Instantly share code, notes, and snippets.

@ThePredators

ThePredators/readme.md

Last active Apr 29, 2021
Embed
What would you like to do?
AppCenter Deployment

AppCenter Deployment

About :

MDM Apps :

Fastlane :

iOS :

  • The "Fastfile" must have this lanes :
default_platform(:ios)

platform :ios do
  desc "Build & Deliver to AppCenter"
  lane :ac_b do |options|
    # Update Info plist Version
    increment_version_number(
      version_number: ENV["VERSION"] # Set a specific version number
    )

    increment_build_number build_number: build_number
    
    # Update Info plist Bundle ID
    update_app_identifier(
      xcodeproj: "FreekitSampleApp.xcodeproj", # Optional path to xcodeproj, will use the first .xcodeproj if not set
      plist_path: "./FreekitSampleApp/Configuration/Info.plist", # Path to info plist file, relative to xcodeproj
      app_identifier: ENV["MY_APP_ID"] # The App Identifier
    )
    # Update Info plist AppName
    update_info_plist( # Change the Display Name of your app
      plist_path: "./FreekitSampleApp/Configuration/Info.plist",
      display_name: "FreekitSampleApp"
    )
    # Use cert to generate a certificate
    cert
    
    # Use sigh to download or generate a provisioning profile
    sigh(
      app_identifier: ENV["MY_APP_ID"]
    )
    
    # Use gym to archive your app
    gym(
      silent: true,
      output_directory: "./fastlane/builds",
      scheme: ENV["SCHEME"],
      configuration: ENV["CONFIGURATION"]
    )
    ac_up
  end

  desc "AppCenter Upload"
  lane :ac_up do |options|
    APP_NAME="FreekitSampleApp"
    appcenter_api_token="API_TOKEN"
    appcenter_owner_name="TEST"
    appcenter_dist_group=["FREEKIT_ORGA"]
    appcenter_app_name=ENV["APP_NAME"]
    appcenter_upload(
      api_token: appcenter_api_token,
      owner_name: appcenter_owner_name,
      owner_type: "user",
      destinations: "FREEKIT_ORGA", # Default is user - set to organization for appcenter organizations
      app_name: appcenter_app_name,
      dsym: "./fastlane/builds/FreekitSampleApp.app.dSYM.zip",
      file: "./fastlane/builds/FreekitSampleApp.ipa",
      notify_testers: true # Set to false if you don't want to notify testers of your new release (default: `false`)
    )
  end
  
end
  • Then the "Pluginfile" must have this :
gem 'fastlane-plugin-appcenter'
  • The "Appfile" have :
app_identifier("BUNDLE_ID")
apple_dev_portal_id "EMAIL_DISTRIBUTION_USER"  # Apple Developer Account
itunes_connect_id "EMAIL_DISTRIBUTION_USER"     # App Store Connect Account
team_id "DEVELOPER_ACCOUNT_TEAM_ID" # Developer Portal Team ID
itc_team_id "APPSTORE_ACCOUNT_TEAM_ID" # App Store Connect Team ID
  • To Make things pretier its advised to use ".env" file (for environnement variables) :
CONFIGURATION="Dev"
VERSION="1.0.0"
MY_APP_ID="fr.freekit.sample"
MY_PROFILE="freekit-sample-pp"
APP_NAME="FreekitSampleApp"
SCHEME="freekit-dev"

(To support multiple environnement just create a file with this name : .env-{environement_to_user} )

Android :

  • The "Appfile" must have :
package_name("fr.freekit.sample") 
  • The "Fastfile" :
default_platform(:android)

  desc "Build & Deliver to AppCenter"
  lane :ac_deploy do |options|
    build(
      task: ENV["TASK"]
    )
  end  
end
  • The ".env" file must be like this (ex. for Prod) :
TASK="appCenterAssembleAndUploadAcRelease" # or (ex. dev : appCenterAssembleAndUploadAcdRelease)
  • The "app/build.gradle" must have :
android {
  
  // ...
  
  flavorDimensions "distribute"
  productFlavors {
      ac {
          dimension "distribute"
          buildConfigField "String", "appcenter_token", "\"${appcenter_token}\""
      }
      acd {
          dimension "distribute"
          buildConfigField "String", "appcenter_token", "\"${appcenter_dev_token}\""
      }
  }
  
   // ...
}

// ...

apply plugin: "com.betomorrow.appcenter"
appcenter {
    apiToken = appcenter_api_token //
    ownerName = appcenter_owner_name //
    distributionGroups = appcenter_dist_group       // Name of the AppCenter Distribution Group
    releaseNotes = file("../CHANGELOG.md")      // Can be a file or text
    notifyTesters = true                        // Send mail to testers
    apps {
        // Here we manage 3 AppCenter applications : alpha, beta and prod
        ac {
            dimension = "distribute"           // This dimension match the flavor dimension
            appName = appcenter_app_name     // The AppCenter application name
        }
        acd {
            dimension = "distribute"           // This dimension match the flavor dimension
            appName = appcenter_app_name_dev      // The AppCenter application name
        }
    }
}
  • The "rootProj/build.gradle" must have :
// ...

buildscript {
    // ...
    dependencies {
        // ...
        classpath "gradle.plugin.com.betomorrow.gradle:appcenter-plugin:1.2.1"
    }
}

// ...
  • The "gradle.properties" must have :
appcenter_token="APPCENTER_APP_PROD_TOKEN"
appcenter_dev_token="APPCENTER_APP_DEV_TOKEN"
appcenter_api_token="APPCENTER_API_TOKEN"
appcenter_owner_name="TEST"
appcenter_dist_group=["FREEKIT_ORGA"]
appcenter_app_name="FreekitSampleApp"
appcenter_app_name_dev="FreekitDevSampleApp"
@ThePredators

This comment has been minimized.

Copy link
Owner Author

@ThePredators ThePredators commented Mar 9, 2021

If u got issues with iOS --> microsoft/appcenter#866

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment