I have implemented the configuration for fastlane and github actions in my flutter project for iOS, with some custom actions for incrementing the version and build number.
default_platform(:ios)
DEVELOPER_APP_ID = ENV['DEVELOPER_APP_ID']
DEVELOPER_APP_IDENTIFIER = ENV['DEVELOPER_APP_IDENTIFIER']
PROVISIONING_PROFILE_SPECIFIER = ENV['PROVISIONING_PROFILE_SPECIFIER']
TEMP_KEYCHAIN_USER = ENV['TEMP_KEYCHAIN_USER']
TEMP_KEYCHAIN_PASSWORD = ENV['TEMP_KEYCHAIN_PASSWORD']
Path = '/Users/*********'
def delete_temp_keychain(name)
if File.exist? File.expand_path("~/Library/Keychains/#{name}-db")
delete_keychain(
name: name
)
end
end
def create_temp_keychain(name, password)
print('name', name, 'password', password)
create_keychain(
name: name,
password: password,
unlock: false,
timeout: 0
)
end
def ensure_temp_keychain(name, password)
delete_temp_keychain(name)
create_temp_keychain(name, password)
end
def update_version(type)
case type
when 'major' then increment_version_number_in_xcodeproj(bump_type: 'major')
when 'minor' then increment_version_number_in_xcodeproj(bump_type: 'minor')
when 'patch' then increment_version_number_in_xcodeproj(bump_type: 'patch')
else abort("Unknown version bump type: #{type}\nValid options: major, minor, patch.")
end
end
platform :ios do
lane :update_major do
update_version('major')
increment_build_number
end
lane :update_minor do
update_version('minor')
increment_build_number
end
lane :update_patch do
# update_patch('patch')
# increment_build_number
script = 'perlscript.pl'
latest
exec("/usr/bin/perl #{script}")
# perl -i -pe 's/^(version:\s+\d+\.\d+\.\d+\+)(\d+)$/$1.($2+1)/e' /Users/*******/Dev/******/pubspec.yaml")
end
lane :_release_candidate do
keychain_name = TEMP_KEYCHAIN_USER
keychain_password = TEMP_KEYCHAIN_PASSWORD
# ensure_temp_keychain('fastlane_keychain_login', '!QA#ED4rf')
ensure_temp_keychain(keychain_name, keychain_password)
add_git_tag(
grouping: 'fastlane-builds',
includes_lane: true,
prefix: 'v',
build_number: get_build_number,
postfix: "-RC#{get_build_number}"
)
push_to_git_remote # this will git-push the above newly created local git-tag
# match(
# type: 'appstore',
# app_identifier: "#{DEVELOPER_APP_IDENTIFIER}",
# git_basic_authorization: Base64.strict_encode64(ENV['GIT_AUTHORIZATION']),
# readonly: true,
# keychain_name: keychain_name,
# keychain_password: keychain_password
# )
# gym(
# configuration: 'Release',
# workspace: 'Runner.xcworkspace',
# scheme: 'Runner',
# export_method: 'app-store',
# export_options: {
# provisioningProfiles: {
# DEVELOPER_APP_ID => PROVISIONING_PROFILE_SPECIFIER
# }
# }
# )
# pilot(
# apple_id: "#{DEVELOPER_APP_ID}",
# app_identifier: "#{DEVELOPER_APP_IDENTIFIER}",
# skip_waiting_for_build_processing: false,
# skip_submission: true,
# distribute_external: false,
# notify_external_testers: false,
# ipa: './Runner.ipa'
# )
delete_temp_keychain(keychain_name)
end
end
as shown in the fastfile above I even tried to using perl to update the pubspec but I couldn't manage to pass the new value after incrementing it.
#!/bin/bash
# set -e
# Find and increment the version number.
perl -i -pe 's/^(version:\s+\d+\.\d+\.\d+\+)(\d+)$/$1.($2+1)/e' /Users/******/Dev/*******/pubspec.yaml
I am facing a problem updating the incremented number in xcode using increment_build_number action from fastlane, to pubspec.yaml version and syncing the changed files from the github action to the main repo or to my local repo, since the incrementation is occuring by running the lane in the github action.