-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tinkoff-mobile-tech/add_ios
Add ios
- Loading branch information
Showing
4 changed files
with
280 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: ios merge request | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
xcodeproj_path: | ||
required: false | ||
type: string | ||
scheme_name: | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
check: | ||
runs-on: macos-11 | ||
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 | ||
env: | ||
XCODEPROJ_PATH: ${{ inputs.xcodeproj_path }} | ||
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: deploy_to_cocoapods | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
cocapods_trunk_token: | ||
required: true | ||
inputs: | ||
xcodeproj_path: | ||
required: false | ||
type: string | ||
scheme_name: | ||
required: false | ||
type: string | ||
bump_type: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: macos-11 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Bundle install | ||
run: | | ||
brew install grep | ||
bundle install | ||
- name: Release | ||
id: release | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
bundle exec fastlane release type:${{ inputs.bump_type }} | ||
NEW_CHANGES=$(cat fastlane/new_changes.txt) | ||
echo "NEW_CHANGES<<EOF" >> $GITHUB_ENV | ||
echo "$NEW_CHANGES" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
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 }} | ||
|
||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
lane :release do |options| | ||
# Checking bump type | ||
bump_type = resolve_bump_type(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 | ||
for podspec_name in podspec_names | ||
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) | ||
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"] + podspec_names + add_files, message: "Release #{version}", skip_git_hooks: true) | ||
add_git_tag(tag: version) | ||
|
||
# Pushing to remote repo | ||
push_to_git_remote(tags: true) | ||
|
||
# Pushing podspec to Cocoapods repo | ||
for podspec_name in podspec_names | ||
push_podspec(podspec_name) | ||
end | ||
end | ||
|
||
lane :extend_bump_version do |options| | ||
[] | ||
end | ||
|
||
lane :check do | ||
# Linting ruby files | ||
lint_fastfile | ||
|
||
# Linting podspec | ||
pod_lib_lint(allow_warnings: true) | ||
|
||
# Buidling Swift package | ||
if(File.exist?('Package.swift')) | ||
build_swift_package | ||
end | ||
end | ||
|
||
lane :build_swift_package do | ||
project_name = ENV['XCODEPROJ_PATH'] | ||
scheme_name = ENV['SCHEME_NAME'] | ||
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 | ||
|
||
if(File.exist?('.rubocop.yml')) | ||
sh('bundle exec rubocop -c .rubocop.yml', error_callback: error_callback) | ||
end | ||
end | ||
end | ||
|
||
def push_podspec(podspec_name) | ||
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 |