automate-flutter-app-releases

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Automate Flutter App Releases

自动化Flutter应用发布

TLDR You can find the script here.
#!/bin/bash

echo "App Release Automator by @rodydavis"

action="$1"
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`

if [ ${action} = "build" ]; then

    echo "${green}Generating built files.. ${reset}"
    flutter packages pub run build_runner clean
    flutter packages pub run build_runner build --delete-conflicting-outputs

    pub global activate pubspec_version
    git commit -a -m "Build $(pubver bump patch)"
    
    echo "${green}Building Project...${reset}"
    find . -name "*-e" -type f -delete
    flutter format .
    flutter clean

    echo "${green}Project Size: $(find . -name "*.dart" | xargs cat | wc -c)${reset}"

    echo "${green}Building APK...${reset}"
    flutter build apk

    echo "${green}Builing IPA..${reset}"
    cd ./ios && pod install && pod repo update && cd ..
    flutter build ios

    git commit -a -m "Project Rebuilt"


elif [ ${action} = "beta" ]; then

    echo "${green}Generating built files..${reset}"
    flutter packages pub run build_runner clean
    flutter packages pub run build_runner build --delete-conflicting-outputs

    pub global activate pubspec_version
    git commit -a -m "Beta $(pubver bump patch)"
    
    echo "${green}Building Project...${reset}"
    find . -name "*-e" -type f -delete
    flutter format .
    flutter clean

    echo "${green}Project Size: $(find . -name "*.dart" | xargs cat | wc -c)${reset}"

    echo "${green}Building APK...${reset}"
    flutter build apk

    echo "${green}Sending Android to Beta...${reset}"
    cd ./android && fastlane beta && cd ..

    echo "${green}Builing IPA..${reset}"
    flutter build ios

    echo "${green}Sending iOS to Beta..${reset}"
    cd ./ios && fastlane beta && cd ..

    git commit -a -m "Sent to Beta"


elif [ ${action} = "release" ]; then

    echo "${green}Generating built files..${reset}"
    flutter packages pub run build_runner clean
    flutter packages pub run build_runner build --delete-conflicting-outputs

    pub global activate pubspec_version
    git commit -a -m "Production $(pubver bump minor)"

    echo "${green}Building Project...${reset}"
    find . -name "*-e" -type f -delete
    flutter format .
    flutter clean

    echo "${green}Project Size: $(find . -name "*.dart" | xargs cat | wc -c)${reset}"

    echo "${green}Building APK...${reset}"
    flutter build apk

    echo "${green}Sending Android to Production...${reset}"
    cd ./android && fastlane release && cd ..

    echo "${green}Builing IPA..${reset}"
    flutter build ios

    echo "${green}Sending iOS to Production...${reset}"
    cd ./ios && fastlane release && cd ..

    git commit -a -m "Sent to Production"

fi

echo "${green}Successfully completed${reset}"
Needed:
  • Fastlane setup in each directory
  • build_runner as a dependency
  • Git Project in VCS
Steps to Run:
  1. Download this file and put it at the root level of your flutter project
  2. Open the terminal and navigate to your project location
  3. Enter this command: 
    chmod +x release.sh
Usage
  • For beta: 
    ./release.sh beta
  • For production: 
    ./release.sh release
It will do the following:
  • Bump the version numbers if you are using the version in the 
    pubspec.yaml
  • Release the apps with Fastlane
  • Format all Dart Files
  • Clean Project
  • Rebuild classes
  • Add commit message
Make your life easier and automate your builds to beta and production!
TLDR 你可以在这里找到该脚本。
#!/bin/bash

echo "App Release Automator by @rodydavis"

action="$1"
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`

if [ ${action} = "build" ]; then

    echo "${green}Generating built files.. ${reset}"
    flutter packages pub run build_runner clean
    flutter packages pub run build_runner build --delete-conflicting-outputs

    pub global activate pubspec_version
    git commit -a -m "Build $(pubver bump patch)"
    
    echo "${green}Building Project...${reset}"
    find . -name "*-e" -type f -delete
    flutter format .
    flutter clean

    echo "${green}Project Size: $(find . -name "*.dart" | xargs cat | wc -c)${reset}"

    echo "${green}Building APK...${reset}"
    flutter build apk

    echo "${green}Builing IPA..${reset}"
    cd ./ios && pod install && pod repo update && cd ..
    flutter build ios

    git commit -a -m "Project Rebuilt"


elif [ ${action} = "beta" ]; then

    echo "${green}Generating built files..${reset}"
    flutter packages pub run build_runner clean
    flutter packages pub run build_runner build --delete-conflicting-outputs

    pub global activate pubspec_version
    git commit -a -m "Beta $(pubver bump patch)"
    
    echo "${green}Building Project...${reset}"
    find . -name "*-e" -type f -delete
    flutter format .
    flutter clean

    echo "${green}Project Size: $(find . -name "*.dart" | xargs cat | wc -c)${reset}"

    echo "${green}Building APK...${reset}"
    flutter build apk

    echo "${green}Sending Android to Beta...${reset}"
    cd ./android && fastlane beta && cd ..

    echo "${green}Builing IPA..${reset}"
    flutter build ios

    echo "${green}Sending iOS to Beta..${reset}"
    cd ./ios && fastlane beta && cd ..

    git commit -a -m "Sent to Beta"


elif [ ${action} = "release" ]; then

    echo "${green}Generating built files..${reset}"
    flutter packages pub run build_runner clean
    flutter packages pub run build_runner build --delete-conflicting-outputs

    pub global activate pubspec_version
    git commit -a -m "Production $(pubver bump minor)"

    echo "${green}Building Project...${reset}"
    find . -name "*-e" -type f -delete
    flutter format .
    flutter clean

    echo "${green}Project Size: $(find . -name "*.dart" | xargs cat | wc -c)${reset}"

    echo "${green}Building APK...${reset}"
    flutter build apk

    echo "${green}Sending Android to Production...${reset}"
    cd ./android && fastlane release && cd ..

    echo "${green}Builing IPA..${reset}"
    flutter build ios

    echo "${green}Sending iOS to Production...${reset}"
    cd ./ios && fastlane release && cd ..

    git commit -a -m "Sent to Production"

fi

echo "${green}Successfully completed${reset}"
所需环境:
  • 每个目录中已配置Fastlane
  • 添加build_runner作为项目依赖
  • 项目已托管在Git版本控制系统中
运行步骤:
  1. 下载该文件并放置在Flutter项目的根目录下
  2. 打开终端并导航到项目所在路径
  3. 执行命令:
    chmod +x release.sh
使用方法
  • 发布Beta版:
    ./release.sh beta
  • 发布正式版:
    ./release.sh release
该脚本会执行以下操作:
  • 若你使用
    pubspec.yaml
    中的版本号,将自动升级版本号
  • 通过Fastlane发布应用
  • 格式化所有Dart文件
  • 清理项目
  • 重建类文件
  • 添加提交信息
让你的工作更轻松,将Beta版和正式版的构建流程自动化!

What you need 

所需环境

  • Fastlane 已在各目录配置完成
  • build_runner 已作为项目依赖
  • 项目已托管在Git版本控制系统中

Initial Setup 

初始设置

  • Download this file
  • Put it at the root level of your flutter project
  • Open the terminal and navigate to your project location
  • Enter this command: chmod +x release.sh
  • 下载该文件
  • 将其放置在Flutter项目的根目录下
  • 打开终端并导航到项目所在路径
  • 执行命令:chmod +x release.sh

Usage 

使用方法

Now you can call this script!
  • For beta: 
    ./release.sh beta
  • For production: 
    ./release.sh release
现在你可以调用该脚本了!
  • 发布Beta版:
    ./release.sh beta
  • 发布正式版:
    ./release.sh release

Overview 

功能概述

  • Bump the version numbers if you are using the version in the pubspec.yaml
  • Release the apps with Fastlane
  • Format all Dart Files
  • Clean Project
  • Rebuild classes
  • Add commit messages
  • Updates Cocoa Pods
  • 若使用
    pubspec.yaml
    中的版本号,自动升级版本号
  • 通过Fastlane发布应用
  • 格式化所有Dart文件
  • 清理项目
  • 重建类文件
  • 添加提交信息
  • 更新Cocoa Pods