summaryrefslogtreecommitdiff
path: root/fastlane/Fastfile
blob: b4ff17874aed0dbc0eaaf0a99bf2561cb7feff7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# 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(:android)

platform :android do
  desc "Runs all the tests"
  lane :test do
    gradle(task: "test")
  end

   desc "Build debug and test APK for screenshots"
   lane :build_bitmask_for_screengrab do
      gradle(
        task: 'clean'
      )
      gradle(
        task: 'assemble',
        build_type: 'Debug',
        flavor: 'NormalProductionFat'
      )
      gradle(
        task: 'assemble',
        build_type: 'DebugAndroidTest',
        flavor: 'NormalProductionFat'
      )
  end

     desc "Build debug and test APK for screenshots"
     lane :build_custom_for_screengrab do
        gradle(
          task: 'clean'
        )
        gradle(
          task: 'assemble',
          build_type: 'Debug',
          flavor: 'CustomProductionFat'
        )
        gradle(
          task: 'assemble',
          build_type: 'DebugAndroidTest',
          flavor: 'CustomProductionFat'
        )
    end

    desc "Create framed screenshots"
    lane :create_framed_screenshots do |options|
        flavor = options[:flavor] || "normal"
        metadata_path = File.expand_path("../../src/#{flavor}ProductionFat/fastlane/metadata", __FILE__)
        Dir.chdir(metadata_path) do
            frameit(
                white: true,
                force_device_type: "Google Pixel 5",
                path: "."
            )
            # rename screenshots, replacing unframed pendants
            sh(
              "find . -path '*/images/phoneScreenshots/*_framed.png' -print0 2>/dev/null | " \
              "xargs -0 -I{} sh -c 'f=\"{}\"; " \
              "nf=\"${f%_framed.png}.png\"; " \
              "mv \"$f\" \"$nf\"'"
            )
           end
        puts "Created framed screenshots"
    end

    desc "set device animations"
    lane :set_animations do |options|
        animated = options[:animated]
        system("adb shell settings put global window_animation_scale #{animated}")
        system("adb shell settings put global transition_animation_scale #{animated}")
        system("adb shell settings put global animator_duration_scale #{animated}")
        puts "set device animations to #{animated}"
    end

  lane :bitmask_screenshots do
    # Prepare builds for Automatic UI Tests
    build_bitmask_for_screengrab

    # disable animations
    set_animations(animated: 0)

    verbose_screenshots = ENV["VERBOSE_SCREENSHOTS"] || "false"
    capture_android_screenshots(
        launch_arguments: ["verbose_screenshots #{verbose_screenshots}"]
    )

    # Re-enable animations
    set_animations(animated: 1)

    create_framed_screenshots(flavor: "normal")
    # deliver
  end

   lane :custom_build_screenshots do
     # Prepare builds for Automatic UI Tests
     build_custom_for_screengrab
     capture_android_screenshots
     create_framed_screenshots(flavor: "custom")
     # deliver
   end

  desc "Submit a new Beta Build to Crashlytics Beta"
  lane :beta do
    gradle(task: "clean assembleRelease")
    crashlytics
  
    # sh "your_script.sh"
    # You can also use other beta testing services here
  end

  desc "Deploy a new version to the Google Play"
  lane :deploy do
    gradle(task: "clean assembleRelease")
    upload_to_play_store
  end
end