Browse Source

Add fastlane folder

onevcat 10 years ago
parent
commit
607c17203f

+ 13 - 1
.gitignore

@@ -80,5 +80,17 @@ Network Trash Folder
 Temporary Items
 Temporary Items
 .apdisk
 .apdisk
 images/logo.sketch
 images/logo.sketch
-fastlane
+
+# fastlane specific
+fastlane/report.xml
+
+# deliver temporary files
+fastlane/Preview.html
+
+# snapshot generated screenshots
+fastlane/screenshots/**/*.png
+fastlane/screenshots/screenshots.html
+
+# scan temporary files
+fastlane/test_output
 test_output
 test_output

+ 46 - 0
fastlane/Fastfile

@@ -0,0 +1,46 @@
+
+fastlane_version "1.37.0"
+
+default_platform :ios
+
+platform :ios do
+  before_all do
+    
+  end
+
+  desc "Runs all the tests"
+  lane :test do
+    scan
+  end
+  
+  desc "Release new version"
+  lane :release do |options|
+      target_version = options[:version]
+      raise "The version is missed. Use `fastlane release version:{version_number}`.`" if target_version.nil?
+      
+      ensure_git_branch
+      ensure_git_status_clean
+      scan
+      sync_build_number_to_git
+      increment_version_number(version_number: target_version)
+      version_bump_podspec(path: "Kingfisher.podspec", version_number: target_version)
+      
+      git_commit_all(message: "Bump version to #{target_version}")
+      add_git_tag tag: target_version
+      
+      push_to_git_remote
+      pod_push
+  end
+
+  lane :podpush do
+    pod_push
+  end
+
+  after_all do |lane|
+    
+  end
+
+  error do |lane, exception|
+    
+  end
+end

+ 13 - 0
fastlane/Scanfile

@@ -0,0 +1,13 @@
+# For more information about this configuation visit
+# https://github.com/fastlane/scan#scanfile
+
+# In general, you can use the options available
+# scan --help
+
+# Remove the # in front of the line to enable the option
+
+scheme "Kingfisher"
+
+# open_report true
+
+clean true

+ 35 - 0
fastlane/actions/git_commit_all.rb

@@ -0,0 +1,35 @@
+module Fastlane
+  module Actions
+    class GitCommitAllAction < Action
+      def self.run(params)
+          Actions.sh "git commit -am \"#{params[:message]}\""
+      end
+
+      #####################################################
+      # @!group Documentation
+      #####################################################
+
+      def self.description
+        "Commit all unsaved changes to git."
+      end
+
+      def self.available_options
+        [
+          FastlaneCore::ConfigItem.new(key: :message,
+                                       env_name: "FL_GIT_COMMIT_ALL",
+                                       description: "The git message for the commit",
+                                       is_string: true)
+        ]
+      end
+
+      def self.authors
+        # So no one will ever forget your contribution to fastlane :) You are awesome btw!
+        ["onevcat"]
+      end
+
+      def self.is_supported?(platform)
+        true
+      end
+    end
+  end
+end

+ 47 - 0
fastlane/actions/sync_build_number_to_git.rb

@@ -0,0 +1,47 @@
+module Fastlane
+  module Actions
+    module SharedValues
+      BUILD_NUMBER = :BUILD_NUMBER
+    end
+    class SyncBuildNumberToGitAction < Action
+      def self.is_git?
+        Actions.sh 'git rev-parse HEAD'
+        return true
+      rescue
+        return false
+      end
+        
+      def self.run(params)
+        if is_git?
+          command = 'git rev-list HEAD --count'
+        else
+          raise "Not in a git repository."
+        end
+      build_number = (Actions.sh command).strip
+      Fastlane::Actions::IncrementBuildNumberAction.run(build_number: build_number)
+      Actions.lane_context[SharedValues::BUILD_NUMBER] = build_number
+      end
+
+      def self.output
+        [
+          ['BUILD_NUMBER', 'The new build number']
+        ]
+      end
+      #####################################################
+      # @!group Documentation
+      #####################################################
+
+      def self.description
+        "Set the build version of your project to the same number of your total git commit count"
+      end
+
+      def self.authors
+        ["onevcat"]
+      end
+
+      def self.is_supported?(platform)
+        [:ios, :mac].include? platform
+      end
+    end
+  end
+end