mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Replace the last of the fastlane lanes with swift tooling
- move more sharable code to CI static methods - merge `release_to_github` and `prepare_next_release` into one single command as they had dependencies on each other - remove all traces of ruby and fastlane
This commit is contained in:
committed by
Stefan Ceriu
parent
96ea54e299
commit
bce9119bc3
@@ -1,123 +0,0 @@
|
||||
require 'yaml'
|
||||
|
||||
skip_docs
|
||||
|
||||
simulator_version = "26.1"
|
||||
|
||||
before_all do
|
||||
xcversion(version: "~> 26.1.0")
|
||||
|
||||
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "180"
|
||||
ENV["FASTLANE_XCODE_LIST_TIMEOUT"] = "180"
|
||||
end
|
||||
|
||||
lane :release_to_github do
|
||||
api_token = ENV["GITHUB_TOKEN"]
|
||||
UI.user_error!("Invalid GitHub API token.") unless !api_token.to_s.empty?
|
||||
|
||||
release_version = get_version_number(target: "ElementX")
|
||||
|
||||
github_release = set_github_release(
|
||||
repository_name: "element-hq/element-x-ios",
|
||||
api_token: api_token,
|
||||
name: release_version,
|
||||
tag_name: "release/#{release_version}",
|
||||
is_generate_release_notes: true,
|
||||
)
|
||||
|
||||
release_date = Date.today.strftime("%Y-%m-%d")
|
||||
generated_notes = github_release["body"].gsub(/<!-- .*? -->/, '').gsub("### ", "\n").gsub("## ", "### ")
|
||||
UI.user_error!("The generated release notes are missing!") unless !generated_notes.to_s.empty?
|
||||
|
||||
# Prepend the new release notes to the CHANGES.md file
|
||||
changes_file = "../CHANGES.md"
|
||||
File.open(changes_file, "r+") do |file|
|
||||
content = file.read
|
||||
file.rewind
|
||||
file.write("## Changes in #{release_version} (#{release_date})#{generated_notes}\n\n#{content}")
|
||||
end
|
||||
|
||||
# The changelog will be committed when prepare_next_release is called.
|
||||
sh("git add #{changes_file}")
|
||||
end
|
||||
|
||||
lane :prepare_next_release do
|
||||
target_file_path = "../project.yml"
|
||||
xcode_project_file_path = "../ElementX.xcodeproj"
|
||||
|
||||
data = YAML.load_file target_file_path
|
||||
current_version = data["settings"]["MARKETING_VERSION"]
|
||||
|
||||
matches = current_version.match(/^(\d{2})\.(\d{2})\.(\d+)$/)
|
||||
unless matches
|
||||
UI.user_error!("Invalid version format: #{current_version}")
|
||||
end
|
||||
|
||||
year, month, build = matches.captures
|
||||
new_build = build.to_i + 1
|
||||
new_version = "#{year}.#{month}.#{new_build}"
|
||||
|
||||
# Bump the patch version. The empty string after -i is so that sed doesn't
|
||||
# create a backup file on macOS
|
||||
sh("sed -i '' 's/MARKETING_VERSION: #{current_version}/MARKETING_VERSION: #{new_version}/g' #{target_file_path}")
|
||||
UI.message("Version updated from #{current_version} to #{new_version}")
|
||||
|
||||
xcodegen(spec: "project.yml")
|
||||
|
||||
setup_git()
|
||||
|
||||
sh("git add #{target_file_path} #{xcode_project_file_path}")
|
||||
|
||||
sh("git commit -m 'Prepare next release'")
|
||||
|
||||
git_push()
|
||||
|
||||
rebase_main_onto_current_branch()
|
||||
end
|
||||
|
||||
def rebase_main_onto_current_branch
|
||||
# Capture the current branch name
|
||||
current_branch = sh("git rev-parse --abbrev-ref HEAD").strip
|
||||
|
||||
UI.message("Current branch: #{current_branch}")
|
||||
|
||||
# Switch to main and update it
|
||||
sh("git reset --hard")
|
||||
sh("git checkout main")
|
||||
sh("git pull origin main")
|
||||
sh("git rebase #{current_branch}")
|
||||
|
||||
git_push()
|
||||
|
||||
UI.success("Successfully rebased main onto #{current_branch}")
|
||||
end
|
||||
|
||||
private_lane :setup_git do
|
||||
sh("git config --global user.name 'Element CI'")
|
||||
sh("git config --global user.email 'ci@element.io'")
|
||||
end
|
||||
|
||||
private_lane :git_push do |options|
|
||||
# Use the Github API token for repo write access
|
||||
api_token = ENV["GITHUB_TOKEN"]
|
||||
UI.user_error!("Invalid GitHub API token.") unless !api_token.to_s.empty?
|
||||
|
||||
# Get repo url path, without `http`, `https` or `git@` prefixes or `.git` suffix
|
||||
repo_url = sh("git ls-remote --get-url origin | sed 's#http://##g' | sed 's#https:\/\/##g' | sed 's#git@##g' | sed 's#.git##g'")
|
||||
|
||||
# This sometimes has a trailing newline
|
||||
repo_url = repo_url.strip
|
||||
|
||||
# Push the tag separately if available
|
||||
if options[:tag_name]
|
||||
sh("git push https://#{api_token}@#{repo_url} #{options[:tag_name]}")
|
||||
end
|
||||
|
||||
sh("git push https://#{api_token}@#{repo_url}")
|
||||
end
|
||||
|
||||
private_lane :bump_build_number do
|
||||
# Increment build number to current date
|
||||
build_number = Time.now.strftime("%Y%m%d%H%M")
|
||||
increment_build_number(build_number: build_number)
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
# Autogenerated by fastlane
|
||||
#
|
||||
# Ensure this file is checked in to source control!
|
||||
|
||||
gem 'fastlane-plugin-xcodegen'
|
||||
gem 'fastlane-plugin-xcconfig'
|
||||
|
||||
# Until Fastlane includes them directly.
|
||||
# https://github.com/fastlane/fastlane/issues/29183
|
||||
gem "abbrev"
|
||||
gem "mutex_m"
|
||||
gem "ostruct"
|
||||
Reference in New Issue
Block a user