flutter打包编译设置为蒲公英的最新版本

2023-08-21  本文已影响0人  Crassus

# Fastfile

platform :android do
  project_dir = 'android/'

  desc 'Android: 执行打包过程'
  private_lane :build do |options|
    sh('flutter clean')
    # gradle(task: 'clean', project_dir: project_dir)
    sh('flutter pub get')
    gradle(
      task: 'assemble',
      build_type: options[:type],
      project_dir: project_dir,
    )
  end
  
  desc 'Android: 打包上传蒲公英'
  lane :pgy do |options|
    apkType = options[:type] || 'Release'
    apkUrl = "#{File.expand_path("..", Dir.pwd)}/build/app/outputs/apk/#{apkType.downcase}/app-#{apkType.downcase}.apk"
    api_key = ""
    build(type: apkType)
    answer = pgyer(
      api_key: api_key, 
      apk: apkUrl,
      update_description: options[:desc])
    buildKey = "#{answer["buildKey"]}"
    # 设置为最新版本
    sh("curl -X POST -F _api_key=#{api_key} -F buildKey=#{buildKey} https://www.pgyer.com/apiv2/app/setNewestVersion")
  end

  desc 'Android本地打包'
  lane :buildApk do |options|
    apkType = options[:type] || 'Release'
    build(type: apkType)
  end
end

上一篇下一篇

猜你喜欢

热点阅读