From 8d613dd33f8984bb4b65de6bd6aac8215437dbae Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Tue, 1 Mar 2022 18:05:24 +0300 Subject: [PATCH 01/16] add ios merge request workflow --- .github/workflows/ios_lib.merge_request.yml | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ios_lib.merge_request.yml diff --git a/.github/workflows/ios_lib.merge_request.yml b/.github/workflows/ios_lib.merge_request.yml new file mode 100644 index 0000000..7c16995 --- /dev/null +++ b/.github/workflows/ios_lib.merge_request.yml @@ -0,0 +1,23 @@ +name: ios merge request + +on: + workflow_call: + +jobs: + check: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up ruby env + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7.2 + + - name: Bundle install + run: bundle install + + - name: tests lint + run: bundle exec fastlane check + + From 22948007b11365c1244557b10ce028cb62fbdbff Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Tue, 1 Mar 2022 18:05:36 +0300 Subject: [PATCH 02/16] add ios publish workflow --- .github/workflows/ios_lib.publish.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ios_lib.publish.yml diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml new file mode 100644 index 0000000..4c8fb26 --- /dev/null +++ b/.github/workflows/ios_lib.publish.yml @@ -0,0 +1,23 @@ +name: deploy_to_cocoapods + +on: + workflow_call: + +jobs: + build: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + + - name: Bundle install + run: bundle install + + - name: Deploy to Cocoapods + run: | + git config user.name github-actions + git config user.email github-actions@github.com + bundle exec fastlane release type:${{ inputs.bump_type }} + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} \ No newline at end of file From 99023a240db79d0c150f25c851cdca8b09e05253 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Tue, 1 Mar 2022 18:09:28 +0300 Subject: [PATCH 03/16] add ios base Fastfile for libs --- fastlane/Fastfile | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 fastlane/Fastfile diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000..9192387 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,86 @@ +lane :release do |options| + # Checking bump type + bump_type = resolve_bump_type(options) + + # Checking that everything is alright + checkup + + # Checking git + ensure_git_status_clean + ensure_git_branch(branch: "master") + + # Bumping podspec version + version = version_bump_podspec(bump_type: bump_type) + + # Stamping changelog + stamp_changelog(section_identifier: version) + + # Creating release commit and tag + git_commit(path: "CHANGELOG.md", message: "Release #{version}") + add_git_tag(tag: version) + + # Pushing to remote repo + push_to_git_remote(tags: true) + + # Pushing podspec to Cocoapods repo + push_podspec +end + +lane :check do + # Linting ruby files + lint_fastfile + + # Linting podspec + pod_lib_lint(allow_warnings: true) + + # Buidling Swift package + build_swift_package +end + +lane :build_swift_package do + project_name = "TinkoffID.xcodeproj" + scheme_name = "TinkoffID-Package" + config_file_name = "Config.xcconfig" + + # Creating configuration file + sh("echo SWIFT_ACTIVE_COMPILATION_CONDITIONS=''> #{config_file_name}") + + # Generating xcode project + sh("swift package generate-xcodeproj --xcconfig-overrides #{config_file_name}") + + # Building generated xcode project + sh("xcodebuild clean build -project ../#{project_name} -sdk iphoneos -scheme '#{scheme_name}'") + + # Cleaning up + sh("rm -f #{config_file_name}") + sh("rm -rf ../#{project_name}") +end + +lane :lint_fastfile do + Dir.chdir("..") do + error_callback = lambda do |result| + UI.user_error!("rubocop execution failed: #{result}") + end + + sh('bundle exec rubocop -c .rubocop.yml', error_callback: error_callback) + end +end + +lane :push_podspec do + podspec_name = "TinkoffID.podspec" + + pod_push( + path: podspec_name, + allow_warnings: true, + skip_tests: true + ) +end + +def resolve_bump_type(options) + valid_bump_types = ['patch', 'minor', 'major'] + bump_type = valid_bump_types.include?(options[:type]) ? options[:type] : nil + + UI.abort_with_message!("Bump type is not specified or incorrect! You can use `type: #{valid_bump_types.join('/')}` to specify it.") unless bump_type + + return bump_type +end From fb6547fdac40b7e47a7fd198f9221a4601010425 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Mon, 14 Mar 2022 18:47:06 +0300 Subject: [PATCH 04/16] env variables for base workflow --- .github/workflows/ios_lib.merge_request.yml | 14 ++++++++++++++ .github/workflows/ios_lib.publish.yml | 11 ++++++++++- fastlane/Fastfile | 10 +++------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ios_lib.merge_request.yml b/.github/workflows/ios_lib.merge_request.yml index 7c16995..55b2235 100644 --- a/.github/workflows/ios_lib.merge_request.yml +++ b/.github/workflows/ios_lib.merge_request.yml @@ -2,6 +2,16 @@ name: ios merge request on: workflow_call: + inputs: + xcodeproj_path: + required: true + type: string + scheme_name: + required: true + type: string + podspec_name: + required: true + type: string jobs: check: @@ -18,6 +28,10 @@ jobs: run: bundle install - name: tests lint + env: + XCODEPROJ_PATH: ${{ inputs.xcodeproj_path }} + SCHEME_NAME: ${{ inputs.scheme_name }} + PODSPEC_NAME: ${{ inputs.podspec_name }} run: bundle exec fastlane check diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index 4c8fb26..da90377 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -2,6 +2,13 @@ name: deploy_to_cocoapods on: workflow_call: + inputs: + xcodeproj_path: + required: true + type: string + scheme_name: + required: true + type: string jobs: build: @@ -20,4 +27,6 @@ jobs: git config user.email github-actions@github.com bundle exec fastlane release type:${{ inputs.bump_type }} env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} \ No newline at end of file + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + XCODEPROJ_PATH: ${{ inputs.xcodeproj_path }} + SCHEME_NAME: ${{ inputs.scheme_name }} \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 9192387..1c6f4c8 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -3,11 +3,7 @@ lane :release do |options| bump_type = resolve_bump_type(options) # Checking that everything is alright - checkup - - # Checking git - ensure_git_status_clean - ensure_git_branch(branch: "master") + check # Bumping podspec version version = version_bump_podspec(bump_type: bump_type) @@ -38,8 +34,8 @@ lane :check do end lane :build_swift_package do - project_name = "TinkoffID.xcodeproj" - scheme_name = "TinkoffID-Package" + project_name = ENV['XCODEPROJ_PATH'] + scheme_name = ENV['SCHEME_NAME'] config_file_name = "Config.xcconfig" # Creating configuration file From 8d9eba3467b1ac7a59ec095b6202aee18fb49d7d Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Tue, 15 Mar 2022 10:14:39 +0300 Subject: [PATCH 05/16] commit podspec --- .github/workflows/ios_lib.publish.yml | 10 +++++++++- fastlane/Fastfile | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index da90377..4e3701e 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -9,6 +9,13 @@ on: scheme_name: required: true type: string + podspec_name: + required: true + type: string + bump_type: + default: "patch" + required: true + type: string jobs: build: @@ -29,4 +36,5 @@ jobs: env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} XCODEPROJ_PATH: ${{ inputs.xcodeproj_path }} - SCHEME_NAME: ${{ inputs.scheme_name }} \ No newline at end of file + SCHEME_NAME: ${{ inputs.scheme_name }} + PODSPEC_NAME: ${{ inputs.podspec_name }} \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 1c6f4c8..48c49a8 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -12,7 +12,7 @@ lane :release do |options| stamp_changelog(section_identifier: version) # Creating release commit and tag - git_commit(path: "CHANGELOG.md", message: "Release #{version}") + git_commit(path: ["CHANGELOG.md", ENV['PODSPEC_NAME']], message: "Release #{version}") add_git_tag(tag: version) # Pushing to remote repo @@ -63,7 +63,7 @@ lane :lint_fastfile do end lane :push_podspec do - podspec_name = "TinkoffID.podspec" + podspec_name = ENV['PODSPEC_NAME'] pod_push( path: podspec_name, From d58781e74702ea89297df1f8640746c0aaad0d57 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Wed, 16 Mar 2022 09:47:27 +0300 Subject: [PATCH 06/16] fix checkout --- .github/workflows/ios_lib.publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index 4e3701e..3ba60e5 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -24,6 +24,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} - name: Bundle install run: bundle install From 3d6731e94e0b73d23a4076319cf7f6cd70333c3a Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 17 Mar 2022 14:15:55 +0300 Subject: [PATCH 07/16] create release card for ios publish --- .github/workflows/ios_lib.publish.yml | 27 ++++++++++++++++++++++++--- fastlane/Fastfile | 5 +++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index 3ba60e5..13df16a 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -28,15 +28,36 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} - name: Bundle install - run: bundle install + run: | + brew install grep + bundle install - - name: Deploy to Cocoapods + - name: Release + id: release run: | git config user.name github-actions git config user.email github-actions@github.com bundle exec fastlane release type:${{ inputs.bump_type }} + NEW_CHANGES=$(cat fastlane/new_changes.txt) + echo "NEW_CHANGES<> $GITHUB_ENV + echo "$NEW_CHANGES" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + BUMPED_VERSION=$(ggrep -oP "s\.version\s+=\s+['\"]\K([\d.]+)" ${{ inputs.podspec_name }}) + echo "::set-output name=bumped_version::$BUMPED_VERSION" env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} XCODEPROJ_PATH: ${{ inputs.xcodeproj_path }} SCHEME_NAME: ${{ inputs.scheme_name }} - PODSPEC_NAME: ${{ inputs.podspec_name }} \ No newline at end of file + PODSPEC_NAME: ${{ inputs.podspec_name }} + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + tag_name: ${{ steps.release.outputs.bumped_version }} + release_name: ${{ steps.release.outputs.bumped_version }} + body: ${{ env.NEW_CHANGES }} + draft: false + prerelease: false \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 48c49a8..7a4bf66 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -8,6 +8,11 @@ lane :release do |options| # Bumping podspec version version = version_bump_podspec(bump_type: bump_type) + text = read_changelog + changelog = File.open('new_changes.txt', "w") + changelog.puts(text) + changelog.close + # Stamping changelog stamp_changelog(section_identifier: version) From 71e0eaf154b1c93df12b26f23825c12ffdf5bc83 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 17 Mar 2022 18:07:17 +0300 Subject: [PATCH 08/16] add "cocapods_trunk_token" for publish to cocapods --- .github/workflows/ios_lib.publish.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index 13df16a..1be7ae3 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -2,6 +2,9 @@ name: deploy_to_cocoapods on: workflow_call: + secrets: + cocapods_trunk_token: + required: true inputs: xcodeproj_path: required: true @@ -45,7 +48,7 @@ jobs: BUMPED_VERSION=$(ggrep -oP "s\.version\s+=\s+['\"]\K([\d.]+)" ${{ inputs.podspec_name }}) echo "::set-output name=bumped_version::$BUMPED_VERSION" env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + COCOAPODS_TRUNK_TOKEN: ${{ secrets.cocapods_trunk_token }} XCODEPROJ_PATH: ${{ inputs.xcodeproj_path }} SCHEME_NAME: ${{ inputs.scheme_name }} PODSPEC_NAME: ${{ inputs.podspec_name }} From 8a84c70021342a716917f9ab1fb2716312c750d3 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 17 Mar 2022 19:09:05 +0300 Subject: [PATCH 09/16] add README for iOS --- README.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e86aa7e..651b6fa 100644 --- a/README.md +++ b/README.md @@ -74,4 +74,86 @@ jobs: java_version: '8' ``` -by default java is 11 \ No newline at end of file +by default java is 11 + +## iOS library workflow + +### Setup + +1. `./Gemfile` in the root repository: + +``` +source "https://rubygems.org" + +gem 'cocoapods', '~> 1.10.1' +gem 'fastlane', '~> 2.172.0' +gem 'rubocop', '~> 0.93.1' +gem 'rubocop-require_tools' + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) +``` + +2. `fastlane/Pluginfile` + +``` +gem 'fastlane-plugin-changelog' +``` + +3. `fastlane/Fastfile` + +```ruby +import_from_git( + url: "https://github.com/tinkoff-mobile-tech/workflows.git", + branch: "master", + path: "fastlane/Fastfile" +) +``` + +### setup merge request workflow + +```yaml +name: merge request + +on: + pull_request: + branches: + - 'master' + +jobs: + check: + uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.merge_request.yml@v1 + with: + xcodeproj_path: "TinkoffID.xcodeproj" + scheme_name: "TinkoffID-Package" + podspec_name: "TinkoffID.podspec" +``` + +it calls `lint_fastfile`, `pod_lib_lint`, `swift package generate-xcodeproj`, `xcodebuild clean build`. + +### setup publications + +```yaml +name: publish + +on: + workflow_dispatch: + inputs: + bump_type: + default: "patch" + required: true + type: string + +jobs: + publish: + uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.publish.yml@v1 + with: + xcodeproj_path: "TinkoffID.xcodeproj" + scheme_name: "TinkoffID-Package" + podspec_name: "TinkoffID.podspec" + bump_type: ${{ inputs.bump_type }} + secrets: + cocapods_trunk_token: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} +``` + +it pushes to cocapods trunk. From 4089328133c5187267b8c0ed5e5cd89e3682c9bf Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 17 Mar 2022 19:32:48 +0300 Subject: [PATCH 10/16] check if rubocop exists --- fastlane/Fastfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 7a4bf66..c1f5675 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -63,7 +63,9 @@ lane :lint_fastfile do UI.user_error!("rubocop execution failed: #{result}") end - sh('bundle exec rubocop -c .rubocop.yml', error_callback: error_callback) + if(File.exist?('.rubocop.yml')) + sh('bundle exec rubocop -c .rubocop.yml', error_callback: error_callback) + end end end From 6ce8f26a4a6358ef545af83cab5501a2a54f1188 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Mon, 28 Mar 2022 18:05:25 +0300 Subject: [PATCH 11/16] add support without swift package --- .github/workflows/ios_lib.merge_request.yml | 8 ++------ README.md | 6 +++--- fastlane/Fastfile | 4 +++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ios_lib.merge_request.yml b/.github/workflows/ios_lib.merge_request.yml index 55b2235..cbe1e4a 100644 --- a/.github/workflows/ios_lib.merge_request.yml +++ b/.github/workflows/ios_lib.merge_request.yml @@ -4,13 +4,10 @@ on: workflow_call: inputs: xcodeproj_path: - required: true + required: false type: string scheme_name: - required: true - type: string - podspec_name: - required: true + required: false type: string jobs: @@ -31,7 +28,6 @@ jobs: env: XCODEPROJ_PATH: ${{ inputs.xcodeproj_path }} SCHEME_NAME: ${{ inputs.scheme_name }} - PODSPEC_NAME: ${{ inputs.podspec_name }} run: bundle exec fastlane check diff --git a/README.md b/README.md index 651b6fa..d1ff212 100644 --- a/README.md +++ b/README.md @@ -85,9 +85,9 @@ by default java is 11 ``` source "https://rubygems.org" -gem 'cocoapods', '~> 1.10.1' -gem 'fastlane', '~> 2.172.0' -gem 'rubocop', '~> 0.93.1' +gem "cocoapods", "~> 1.11.3" +gem 'fastlane', '~> 2.204.3' +gem 'rubocop', '~> 0.93.1' # if exists gem 'rubocop-require_tools' plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') diff --git a/fastlane/Fastfile b/fastlane/Fastfile index c1f5675..becb069 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -35,7 +35,9 @@ lane :check do pod_lib_lint(allow_warnings: true) # Buidling Swift package - build_swift_package + if(File.exist?('Package.swift')) + build_swift_package + end end lane :build_swift_package do From 4b522f7eb512c64e03aab71c61e9d2f73f5c29b0 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Tue, 29 Mar 2022 14:41:29 +0300 Subject: [PATCH 12/16] add swiftlint check --- .github/workflows/ios_lib.merge_request.yml | 7 +++++++ .github/workflows/ios_lib.publish.yml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ios_lib.merge_request.yml b/.github/workflows/ios_lib.merge_request.yml index cbe1e4a..932e47b 100644 --- a/.github/workflows/ios_lib.merge_request.yml +++ b/.github/workflows/ios_lib.merge_request.yml @@ -30,4 +30,11 @@ jobs: SCHEME_NAME: ${{ inputs.scheme_name }} run: bundle exec fastlane check + swiftlint: + runs-on: ubuntu-latest + container: ghcr.io/realm/swiftlint:0.47.0 + steps: + - uses: actions/checkout@v3 + - run: swiftlint --quiet + diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index 1be7ae3..e84b092 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -45,7 +45,7 @@ jobs: echo "NEW_CHANGES<> $GITHUB_ENV echo "$NEW_CHANGES" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - BUMPED_VERSION=$(ggrep -oP "s\.version\s+=\s+['\"]\K([\d.]+)" ${{ inputs.podspec_name }}) + BUMPED_VERSION=$(ggrep -oP "\.version\s+=\s+['\"]\K([\d.]+)" ${{ inputs.podspec_name }}) echo "::set-output name=bumped_version::$BUMPED_VERSION" env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.cocapods_trunk_token }} From 6398fc7a33d83bdefa0b0160d52bb7495c2976b8 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Tue, 29 Mar 2022 20:44:16 +0300 Subject: [PATCH 13/16] support multiple podspec_names --- .github/workflows/ios_lib.publish.yml | 10 +++------- fastlane/Fastfile | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index e84b092..668982b 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -7,13 +7,10 @@ on: required: true inputs: xcodeproj_path: - required: true + required: false type: string scheme_name: - required: true - type: string - podspec_name: - required: true + required: false type: string bump_type: default: "patch" @@ -45,13 +42,12 @@ jobs: echo "NEW_CHANGES<> $GITHUB_ENV echo "$NEW_CHANGES" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - BUMPED_VERSION=$(ggrep -oP "\.version\s+=\s+['\"]\K([\d.]+)" ${{ inputs.podspec_name }}) + BUMPED_VERSION=$(cat fastlane/version.txt) echo "::set-output name=bumped_version::$BUMPED_VERSION" env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.cocapods_trunk_token }} XCODEPROJ_PATH: ${{ inputs.xcodeproj_path }} SCHEME_NAME: ${{ inputs.scheme_name }} - PODSPEC_NAME: ${{ inputs.podspec_name }} - name: Create Release id: create_release diff --git a/fastlane/Fastfile b/fastlane/Fastfile index becb069..04eb36c 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -4,27 +4,36 @@ lane :release do |options| # Checking that everything is alright check - + root_path = File.join(Dir.pwd, "..") + podspec_names = Dir.glob('*.podspec', base: root_path).select { |f| File.expand_path(f) } # Bumping podspec version - version = version_bump_podspec(bump_type: bump_type) + for podspec_name in podspec_names + version = version_bump_podspec(path: podspec_name, bump_type: bump_type) + end text = read_changelog changelog = File.open('new_changes.txt', "w") changelog.puts(text) changelog.close + version_file = File.open('version.txt', "w") + version_file.puts(version) + version_file.close + # Stamping changelog stamp_changelog(section_identifier: version) # Creating release commit and tag - git_commit(path: ["CHANGELOG.md", ENV['PODSPEC_NAME']], message: "Release #{version}") + git_commit(path: ["CHANGELOG.md"] + podspec_names, message: "Release #{version}") add_git_tag(tag: version) # Pushing to remote repo push_to_git_remote(tags: true) # Pushing podspec to Cocoapods repo - push_podspec + for podspec_name in podspec_names + push_podspec(podspec_name) + end end lane :check do @@ -71,9 +80,7 @@ lane :lint_fastfile do end end -lane :push_podspec do - podspec_name = ENV['PODSPEC_NAME'] - +def push_podspec(podspec_name) pod_push( path: podspec_name, allow_warnings: true, From 4162338ac70234ca03ff8ec893116b4663158e97 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Wed, 30 Mar 2022 23:45:46 +0300 Subject: [PATCH 14/16] bump_version without default param --- .github/workflows/ios_lib.publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index 668982b..8b56600 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -13,7 +13,6 @@ on: required: false type: string bump_type: - default: "patch" required: true type: string From ee73f42a98dd0898a1fbd76ccfa60b3791ca0ba6 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 31 Mar 2022 01:35:30 +0300 Subject: [PATCH 15/16] extended bump version file option --- README.md | 12 ++---------- fastlane/Fastfile | 8 +++++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d1ff212..e21ae9f 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ source "https://rubygems.org" gem "cocoapods", "~> 1.11.3" gem 'fastlane', '~> 2.204.3' +gem 'fastlane-plugin-changelog' gem 'rubocop', '~> 0.93.1' # if exists gem 'rubocop-require_tools' @@ -94,18 +95,11 @@ plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) ``` -2. `fastlane/Pluginfile` - -``` -gem 'fastlane-plugin-changelog' -``` - -3. `fastlane/Fastfile` +2`fastlane/Fastfile` ```ruby import_from_git( url: "https://github.com/tinkoff-mobile-tech/workflows.git", - branch: "master", path: "fastlane/Fastfile" ) ``` @@ -126,7 +120,6 @@ jobs: with: xcodeproj_path: "TinkoffID.xcodeproj" scheme_name: "TinkoffID-Package" - podspec_name: "TinkoffID.podspec" ``` it calls `lint_fastfile`, `pod_lib_lint`, `swift package generate-xcodeproj`, `xcodebuild clean build`. @@ -150,7 +143,6 @@ jobs: with: xcodeproj_path: "TinkoffID.xcodeproj" scheme_name: "TinkoffID-Package" - podspec_name: "TinkoffID.podspec" bump_type: ${{ inputs.bump_type }} secrets: cocapods_trunk_token: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 04eb36c..a59b612 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -11,6 +11,8 @@ lane :release do |options| version = version_bump_podspec(path: podspec_name, bump_type: bump_type) end + add_files = extend_bump_version(version: version) + text = read_changelog changelog = File.open('new_changes.txt', "w") changelog.puts(text) @@ -24,7 +26,7 @@ lane :release do |options| stamp_changelog(section_identifier: version) # Creating release commit and tag - git_commit(path: ["CHANGELOG.md"] + podspec_names, message: "Release #{version}") + git_commit(path: ["CHANGELOG.md"] + podspec_names + add_files, message: "Release #{version}", skip_git_hooks: true) add_git_tag(tag: version) # Pushing to remote repo @@ -36,6 +38,10 @@ lane :release do |options| end end +lane :extend_bump_version do |options| + [] +end + lane :check do # Linting ruby files lint_fastfile From 11d2aba7a14b5b2c70991a0efc5c4edc5ce79a97 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 31 Mar 2022 02:26:42 +0300 Subject: [PATCH 16/16] use only macOS Big Sur 11 --- .github/workflows/ios_lib.merge_request.yml | 2 +- .github/workflows/ios_lib.publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ios_lib.merge_request.yml b/.github/workflows/ios_lib.merge_request.yml index 932e47b..b258bb1 100644 --- a/.github/workflows/ios_lib.merge_request.yml +++ b/.github/workflows/ios_lib.merge_request.yml @@ -12,7 +12,7 @@ on: jobs: check: - runs-on: macos-latest + runs-on: macos-11 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/ios_lib.publish.yml b/.github/workflows/ios_lib.publish.yml index 8b56600..aa7ac68 100644 --- a/.github/workflows/ios_lib.publish.yml +++ b/.github/workflows/ios_lib.publish.yml @@ -19,7 +19,7 @@ on: jobs: build: - runs-on: macos-latest + runs-on: macos-11 steps: - uses: actions/checkout@v3