9
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FlutterでbitriseでDeploygateでCI/CD

Last updated at Posted at 2019-01-13

そのままは無理

BitriseはFlutterをサポートしているとはいえ、ipaを出力する方法がflutterコマンドにない。
そのため、それぞれのプラットフォームのやり方をやるしかない。

fastlane build ios --release とかはどうあがいてもipa作れなかったので、結局fastlaneで設定するのがその後のためにもいい。

fastlane

結局いつものコレ。
fastlane initしてできたのを以下のように編集。

# AppFile

app_identifier("xxxxxx") # The bundle identifier of your app
apple_id("xxxxxxx") # Your Apple email address

itc_team_id("xxxxx") # App Store Connect Team ID
team_id("xxxxx") # Developer Portal Team ID

# For more information about the Appfile, see:
#     https://docs.fastlane.tools/advanced/#appfile

# FastFile

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do
  desc "Push a new beta build to TestFlight"
  lane :beta do
    sigh(force: false, adhoc: true)
    gym()
    deploygate(
      api_token: 'xxxxxx', 
      user: 'adriablue', 
      message: "Fastlane build #{lane_context[SharedValues::BUILD_NUMBER]}",
    )
  end
end

# GymFile

scheme("Runner")

clean(true)
export_options({
  method: "ad-hoc",
})
export_xcargs("-allowProvisioningUpdates")
output_directory("./build")    # store the ipa in this folder

おそらくなくても良い設定とかもある。もりもりで検証で入れているのもある。
これで fastlane beta で動く。まずはローカルで動くのを確認しましょう。

ビルド時のエラー

/bin/sh: /packages/flutter_tools/bin/xcode_backend.sh: No such file or directory

ほほう。flutterでのプロジェクト作成時に自動で作られたworkspaceの設定の環境変数 FLUTTER_ROOT がないことが問題。

パスとしては /Users/vagrant/Library/flutter に入るので、これをEnv Varsに入れる。

Bitrise


---
format_version: '6'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: flutter
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
workflows:
  deploy:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.14: {}
    - script@1.1.5:
        title: Do anything with Script step
    - certificate-and-profile-installer@1.10.1: {}
    - flutter-installer@0.9.2: {}
    - flutter-test@0.9.1:
        inputs:
        - project_location: "$BITRISE_FLUTTER_PROJECT_LOCATION"
    - flutter-build@0.9.1:
        inputs:
        - project_location: "$BITRISE_FLUTTER_PROJECT_LOCATION"
    - xcode-archive@2.4.18:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
        - export_method: "$BITRISE_EXPORT_METHOD"
        - configuration: Release
    - deploy-to-bitrise-io@1.3.19: {}
  primary:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.14: {}
    - certificate-and-profile-installer@1.10.1: {}
    - flutter-installer@0.9.2: {}
    - flutter-build@0.9.1:
        inputs:
        - platform: ios
    - cocoapods-install@1.7.2:
        inputs:
        - source_root_path: "$BITRISE_SOURCE_DIR/ios"
    - fastlane@2.3.12:
        inputs:
        - work_dir: "$BITRISE_SOURCE_DIR/ios"
        - lane: beta
    - deploygate--upload-app-bitrise-step@1.0.1:
        inputs:
        - owner_name: adriablue
        - app_path: "$FLUTTER_IPA_PATH"
        - api_key: "$DEPLOYGATE_API_KEY"
    - slack@3.1.2:
        is_always_run: false
        inputs:
        - webhook_url: "$slack_incomming_url"
app:
  envs:
  - opts:
      is_expand: false
    BITRISE_FLUTTER_PROJECT_LOCATION: "."
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: ios/Runner.xcworkspace
  - opts:
      is_expand: false
    BITRISE_SCHEME: Runner
  - opts:
      is_expand: false
    BITRISE_EXPORT_METHOD: ad-hoc
  - opts:
      is_expand: false
    DEPLOYGATE_USER: adriablue
  - opts:
      is_expand: false
    FLUTTER_ROOT: "/Users/vagrant/flutter-sdk/"
  - opts:
      is_expand: false
    FLUTTER_IPA_PATH: "/Users/vagrant/git/ios/build/Runner.ipa"

  • 設定している環境変数はこんな感じ。あとはPasswordにdeploygate, fastlaneのパスワードなどを入れる。
    あとはiosのプロジェクト側でCode SigningをAutomaticじゃなくてManualにした。
  • workflowでFlutterのタスクはいろいろあるんだけど、 Flutter じゃなくて Flutter Build じゃないとsixのライブラリがなくてビルドできない。でも Flutter の方にもbuildができる引数があるので注意

これでFlutterでもBitriseで動く。まる2日くらいかかったぞ・・・

9
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?