├── README.md ├── fastlane ├── README.md ├── Fastfile ├── report.xml └── actions │ └── remove_git_tag.rb └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # LXFUpdatePodTool 2 | fastlane 自动化更新私有库工具 3 | 4 | - 一个帮助我们自动化更新私有库的工具 5 | - 与[iOS 组件化开发(四):fastlane实现pod自动化](https://juejin.im/post/5ac6eb6351882555731c5e9e)配合使用,味道更佳~ 6 | 7 | ## 使用 8 | 9 | 1. 将fastlane拷贝到你的本地仓库的根目录 10 | 2. 打开Fastfile,找到pod_push并进行修改 11 | 12 | ``` 13 | # repo:将 LXFSpecs 修改为你自己的本地私有索引库的名称 14 | pod_push(path: "#{podspecName}.podspec", repo: "LXFSpecs") 15 | 16 | ``` 17 | 3. 打开终端,cd到你的组件仓库的根目录下 18 | 19 | ``` 20 | # fastlane LXFUpdatePodTool tag:版本号 specName:podspec文件名字 21 | 22 | # 如: 23 | fastlane LXFUpdatePodTool tag:0.1.1 specName:LXFMain 24 | ``` 25 | -------------------------------------------------------------------------------- /fastlane/README.md: -------------------------------------------------------------------------------- 1 | fastlane documentation 2 | ================ 3 | # Installation 4 | 5 | Make sure you have the latest version of the Xcode command line tools installed: 6 | 7 | ``` 8 | xcode-select --install 9 | ``` 10 | 11 | Install _fastlane_ using 12 | ``` 13 | [sudo] gem install fastlane -NV 14 | ``` 15 | or alternatively using `brew cask install fastlane` 16 | 17 | # Available Actions 18 | ### LXFUpdatePodTool 19 | ``` 20 | fastlane LXFUpdatePodTool 21 | ``` 22 | LXFUpdatePodTool 航道用来自动化升级维护私有库 23 | 24 | ---- 25 | 26 | This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run. 27 | More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). 28 | The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). 29 | -------------------------------------------------------------------------------- /fastlane/Fastfile: -------------------------------------------------------------------------------- 1 | desc 'LXFUpdatePodTool 航道用来自动化升级维护私有库' 2 | lane :LXFUpdatePodTool do |options| 3 | 4 | tagNum = options[:tag] 5 | podspecName = options[:specName] 6 | 7 | # 航道上需要执行的操作 8 | # 具体action到 https://docs.fastlane.tools/actions 上面查找 9 | # 这里的路径以仓库根目录为准 10 | 11 | # 1、修改spec文件(修改s.version,s.description等) 12 | # 2、pod install (使Example与pod下来的库产生关联) 13 | cocoapods( 14 | clean: true, 15 | podfile: "./Example/Podfile" 16 | ) 17 | 18 | 19 | # 3、提交本地仓库代码至远程仓库 20 | git_add(path: ".") 21 | git_commit(path: ".", message: "upgrade repo") 22 | push_to_git_remote 23 | 24 | 25 | # 4、打标签,并提交至远程 26 | # 先验证tag是否存在,如果存在则删除本地标签和远程标签 27 | if git_tag_exists(tag: tagNum) 28 | UI.message("您输入的tag:#{tagNum}已存在,即将自动清除") 29 | remove_git_tag(tagNum: tagNum) 30 | end 31 | add_git_tag( 32 | tag: tagNum 33 | ) 34 | push_git_tags 35 | 36 | 37 | # 5、验证spec,并提至私有索引库 38 | pod_lib_lint(allow_warnings: true) 39 | # 因为本地索引库repo的名字是基本上不会去改变的,所以这里直接写死 LXFSpecs 40 | # podspec的名字需要由外界传入 41 | pod_push(path: "#{podspecName}.podspec", repo: "LXFSpecs") 42 | 43 | 44 | end -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 林洵锋 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /fastlane/report.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /fastlane/actions/remove_git_tag.rb: -------------------------------------------------------------------------------- 1 | module Fastlane 2 | module Actions 3 | module SharedValues 4 | REMOVE_GIT_TAG_CUSTOM_VALUE = :REMOVE_GIT_TAG_CUSTOM_VALUE 5 | end 6 | 7 | class RemoveGitTagAction < Action 8 | def self.run(params) 9 | 10 | # params[:参数名称] 参数名称与下面self.available_options中的保持一致 11 | tagNum = params[:tagNum] 12 | rmLocalTag = params[:rmLocalTag] 13 | rmRemoteTag = params[:rmRemoteTag] 14 | 15 | command = [] 16 | if rmLocalTag 17 | # 删除本地标签 18 | # git tag -d 标签名称 19 | command << "git tag -d #{tagNum}" 20 | end 21 | if rmRemoteTag 22 | # 删除远程标签 23 | # git push origin :标签名称 24 | command << "git push origin :#{tagNum}" 25 | end 26 | 27 | result = Actions.sh(command.join('&')) 28 | UI.success("Successfully remove tag 🚀 ") 29 | return result 30 | 31 | end 32 | 33 | ##################################################### 34 | # @!group Documentation 35 | ##################################################### 36 | 37 | # 可以使用 fastlane action remove_git_tag 来参看详细描述 38 | # 39 | 40 | def self.description 41 | "删除tag" 42 | end 43 | 44 | def self.details 45 | "使用当前action来删除本地和远程冲突的tag" 46 | end 47 | 48 | def self.available_options 49 | # Define all options your action supports. 50 | 51 | # Below a few examples 52 | [ 53 | FastlaneCore::ConfigItem.new(key: :tagNum, 54 | description: "输入即将删除的tag", 55 | is_string: true), 56 | FastlaneCore::ConfigItem.new(key: :rmLocalTag, 57 | description: "是否删除本地tag", 58 | optional:true, 59 | is_string: false, 60 | default_value: true), 61 | FastlaneCore::ConfigItem.new(key: :rmRemoteTag, 62 | description: "是否删除远程tag", 63 | optional:true, 64 | is_string: false, 65 | default_value: true) 66 | ] 67 | end 68 | 69 | def self.output 70 | # Define the shared values you are going to provide 71 | # Example 72 | # [ 73 | # ['REMOVE_GIT_TAG_CUSTOM_VALUE', 'A description of what this value contains'] 74 | # ] 75 | end 76 | 77 | def self.return_value 78 | # If your method provides a return value, you can describe here what it does 79 | end 80 | 81 | def self.authors 82 | # So no one will ever forget your contribution to fastlane :) You are awesome btw! 83 | ["LinXunFeng"] 84 | end 85 | 86 | def self.is_supported?(platform) 87 | # you can do things like 88 | # 89 | # true 90 | # 91 | # platform == :ios 92 | # 93 | # [:ios, :mac].include?(platform) 94 | # 95 | 96 | platform == :ios 97 | end 98 | end 99 | end 100 | end 101 | --------------------------------------------------------------------------------