default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"
  # 打包时候用的名称   例如 fastlane app
   
  bundle_id = "com.intelligence.galaxy"
  adhoc_profile_name = "com.adhoc.profile"
  release_profile_name = "dis.intelligence.com"
  
  adhoc_pgyer_api_key = "ba79f62a052072f2486ad29632fefd46"
  release_pgyer_api_key =  "ac973522a8c357596c3dd58d311d10d8"

  #可以用来打包的分支
  develop_branch = "develop"
  main_branch = "main"
  youhua_branch = "youhua-dev"
  
  #打包正使用的分支
  myPack_branch = "main"

  # 打adhoc包 执行命令 fastlane galaxyTest
  lane :galaxyTest do 
    # add actions here: https://docs.fastlane.tools/actions

    sh "git checkout #{myPack_branch}"
     # 拉取最新代码
     sh "git pull origin #{myPack_branch}"
     # 显示git当前分支最新submit id
     sh "git rev-parse HEAD"
     # 更新pod第三方库
     cocoapods(use_bundle_exec: true)

    gym(
    workspace: 'galaxy.xcworkspace',
    # 每次打包之前clean一下
    clean: true,    
    # 打包出 ipa 文件的路径，我放到了桌面文件夹，你自行更改文件夹
    output_directory: './App/ad-hoc',
    # 打包的名称，可任意取 
    output_name: 'galaxy.ipa', 
    # 项目的 scheme，自己项目名   .xcworkspace 前面的项目名就是
    scheme: "galaxyForTestArchive",      
    # 默认 Release，Release or Debug     
    configuration: 'TestEnv', 
    # 是否包含 bitcode  
    include_bitcode: false,  
    # 是否包含 symbols 
    include_symbols: true, 
    # 打包导出方式，包含 app-store, validation, ad-hoc, package, enterprise, development, developer-id and mac-application   
    export_method: 'ad-hoc',  
    # 这个设置是为了设置 xcode 自动配置证书和配置文件，当然也可以手动配置，可以参考文档
    # export_xcargs: '-allowProvisioningUpdates', 
    
    #手动配置证书和配置文件
    export_options: {
      signingStyle: "manual",
      provisioningProfiles: {
        "#{bundle_id}" => "#{adhoc_profile_name}",
      }
    }
    )


    # mac上的通知弹窗，通知打包完毕
    notification(app_icon: "./fastlane/icon.png", title: "manager", subtitle: "打包成功，已导出安装包", message: "准备发布到蒲公英中……")

   #配置上传蒲公英账号  蒲公英的 api_key
   pgyer(
    # 蒲公英 API Key
    api_key: "#{adhoc_pgyer_api_key}"
   )
  end

  
  # 打realease包 执行命令 fastlane galaxyRelease

 lane :galaxyAdhoc do 
    # add actions here: https://docs.fastlane.tools/actions

    sh "git checkout #{myPack_branch}"
    # 拉取最新代码
    sh "git pull origin #{myPack_branch}"
    # 显示git当前分支最新submit id
    sh "git rev-parse HEAD"
    # 更新pod第三方库
    cocoapods(use_bundle_exec: true)
  
    gym(
    workspace: 'galaxy.xcworkspace',
    # 每次打包之前clean一下
    clean: true,    
    # 打包出 ipa 文件的路径，我放到了桌面文件夹，你自行更改文件夹
    output_directory: './App/Release',
    # 打包的名称，可任意取 
    output_name: 'galaxy.ipa', 
    # 项目的 scheme，自己项目名   .xcworkspace 前面的项目名就是
    scheme: "galaxy",      
    # 默认 Release，Release or Debug     
    configuration: 'Release', 
    # 是否包含 bitcode  
    include_bitcode: false,  
    # 是否包含 symbols 
    include_symbols: true, 
    # 打包导出方式，包含 app-store, validation, ad-hoc, package, enterprise, development, developer-id and mac-application   
    export_method: 'ad-hoc',  
    # 这个设置是为了设置 xcode 自动配置证书和配置文件，当然也可以手动配置，可以参考文档
    # export_xcargs: '-allowProvisioningUpdates', 
    
    #手动配置证书和配置文件
    export_options: {
      signingStyle: "manual",
      provisioningProfiles: {
       "#{bundle_id}" => "#{adhoc_profile_name}",
      }
    }
    )


    # mac上的通知弹窗，通知打包完毕
    notification(app_icon: "./fastlane/icon.png", title: "manager", subtitle: "打包成功，已导出安装包", message: "准备发布到蒲公英中……")

   #配置上传蒲公英账号  蒲公英的 api_key和 user_key  用自己蒲公英账号的，别用我的！！！如果没有可删除
   pgyer(
    # 蒲公英 API Key
    api_key: "#{release_pgyer_api_key}"
   )
  end
end