From d924c2a99598ae3e84cdd9b2566cb28dd49078f8 Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Fri, 14 Oct 2022 17:22:46 +0500 Subject: [PATCH 01/11] API key configuration with environment variable added --- xcode/commonFastfile | 45 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 0c00145..1d86cad 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -64,6 +64,7 @@ def upload_to_app_store_using_options(options) upload_to_app_store( username: options[:username] || options[:apple_id], api_key_path: options[:api_key_path], + api_key: options[:api_key], ipa: options[:ipa_path], force: true, # skip metainfo prompt skip_metadata: true, @@ -348,6 +349,7 @@ def sync_code_signing_using_options(options) app_identifier: options[:app_identifier], username: options[:username] || options[:apple_id], api_key_path: options[:api_key_path], + api_key: options[:api_key], team_id: options[:team_id], type: options[:type], readonly: options[:readonly].nil? ? true : options[:readonly], @@ -372,13 +374,48 @@ end def fill_up_options_using_configuration_type(options, configuration_type) configuration = get_configuration_for_type(configuration_type.type) + api_key_json_path = File.expand_path "../fastlane/#{configuration_type.prefix}_api_key.json" + is_api_key_file_exists = File.exists?(api_key_json_path) + + api_key_path = nil + api_key = nil + + # Check whether configuration type is required to configure one of api key parameters or not + if configuration_type.is_app_store || configuration_type.is_development - api_key_path = "fastlane/#{configuration_type.prefix}_api_key.json" - else - api_key_path = nil + + # Check whether API key JSON file exists or not + + if is_api_key_file_exists + + # If exists then fill in all required information through api_key_path parameter + + api_key_path = "fastlane/#{configuration_type.prefix}_api_key.json" + else + + require 'json' + + # If doesn't exist then build api_key parameter through app_store_connect_api_key action + + api_key_parameters = JSON.parse(ENV['API_KEY_JSON']) + + api_key = app_store_connect_api_key( + key_id: api_key_parameters['key_id'], + issuer_id: api_key_parameters['issuer_id'], + key_content: api_key_parameters['key'], + duration: api_key_parameters['duration'], + in_house: api_key_parameters['in_house'] + ) + end end - default_options = {:api_key_path => api_key_path} + # Setting required parameter depending on API key JSON file existence + + if is_api_key_file_exists + default_options = {:api_key_path => api_key_path} + else + default_options = {:api_key => api_key} + end default_options .merge(configuration.to_options) From 7c22f6e4fc2ee0908e5a9d2a36e576090dcbfa4b Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Mon, 17 Oct 2022 17:47:18 +0500 Subject: [PATCH 02/11] app_store_connect_api_key action calling moved to a separate method, api_key_path used directly --- xcode/commonFastfile | 45 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 1d86cad..40539c1 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -374,11 +374,8 @@ end def fill_up_options_using_configuration_type(options, configuration_type) configuration = get_configuration_for_type(configuration_type.type) - api_key_json_path = File.expand_path "../fastlane/#{configuration_type.prefix}_api_key.json" - is_api_key_file_exists = File.exists?(api_key_json_path) - - api_key_path = nil - api_key = nil + api_key_path = File.expand_path "../fastlane/#{configuration_type.prefix}_api_key.json" + is_api_key_file_exists = File.exists?(api_key_path) # Check whether configuration type is required to configure one of api key parameters or not @@ -389,40 +386,38 @@ def fill_up_options_using_configuration_type(options, configuration_type) if is_api_key_file_exists # If exists then fill in all required information through api_key_path parameter + # and set a value to an options` parameter respectively - api_key_path = "fastlane/#{configuration_type.prefix}_api_key.json" + default_options = {:api_key_path => api_key_path} else - require 'json' - # If doesn't exist then build api_key parameter through app_store_connect_api_key action + # and set a value to an options` parameter respectively also - api_key_parameters = JSON.parse(ENV['API_KEY_JSON']) - - api_key = app_store_connect_api_key( - key_id: api_key_parameters['key_id'], - issuer_id: api_key_parameters['issuer_id'], - key_content: api_key_parameters['key'], - duration: api_key_parameters['duration'], - in_house: api_key_parameters['in_house'] - ) + default_options = {:api_key => get_app_store_connect_api_key()} end end - # Setting required parameter depending on API key JSON file existence - - if is_api_key_file_exists - default_options = {:api_key_path => api_key_path} - else - default_options = {:api_key => api_key} - end - default_options .merge(configuration.to_options) .merge(get_keychain_options(options)) .merge(options) end +def get_app_store_connect_api_key() + require 'json' + + api_key_parameters = JSON.parse(ENV['API_KEY_JSON']) + + return app_store_connect_api_key( + key_id: api_key_parameters['key_id'], + issuer_id: api_key_parameters['issuer_id'], + key_content: api_key_parameters['key'], + duration: api_key_parameters['duration'], + in_house: api_key_parameters['in_house'] + ) +end + def get_keychain_options(options) keychain_name = options[:keychain_name] keychain_password = options[:keychain_password] From 805064784776fca9ee6f36f75a5f70a30114aac6 Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Tue, 18 Oct 2022 19:50:58 +0500 Subject: [PATCH 03/11] `default_options` empty initializer added for correct method running --- xcode/commonFastfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 40539c1..c196074 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -377,6 +377,10 @@ def fill_up_options_using_configuration_type(options, configuration_type) api_key_path = File.expand_path "../fastlane/#{configuration_type.prefix}_api_key.json" is_api_key_file_exists = File.exists?(api_key_path) + # default_options required to be empty due to the possibility of skipping the configuration type check below + + default_options = {} + # Check whether configuration type is required to configure one of api key parameters or not if configuration_type.is_app_store || configuration_type.is_development From a54982e4821e8c01d2980c2da3fd91c1507ac926 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Thu, 8 Dec 2022 18:59:01 +0300 Subject: [PATCH 04/11] add makefile shortcuts for iOS development --- xcode/bootstrap/Brewfile | 14 ++++++ xcode/bootstrap/Gemfile | 9 ++++ xcode/bootstrap/Makefile | 86 +++++++++++++++++++++++++++++++++++ xcode/bootstrap/setup.command | 6 +++ 4 files changed, 115 insertions(+) create mode 100644 xcode/bootstrap/Brewfile create mode 100644 xcode/bootstrap/Gemfile create mode 100644 xcode/bootstrap/Makefile create mode 100755 xcode/bootstrap/setup.command diff --git a/xcode/bootstrap/Brewfile b/xcode/bootstrap/Brewfile new file mode 100644 index 0000000..396ea43 --- /dev/null +++ b/xcode/bootstrap/Brewfile @@ -0,0 +1,14 @@ +# Working environment +brew "rbenv" # ruby + bundler +brew "gettext" + +# Code, configs and project generation +brew "php" +brew "python" +brew "xcodegen" + +# code quality +brew "pmd" + +# CI badge +# brew "imagemagick" \ No newline at end of file diff --git a/xcode/bootstrap/Gemfile b/xcode/bootstrap/Gemfile new file mode 100644 index 0000000..8f79a29 --- /dev/null +++ b/xcode/bootstrap/Gemfile @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gem "cocoapods" +gem "fastlane" +gem 'mustache' # for config generator +gem 'xcode-install' + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) \ No newline at end of file diff --git a/xcode/bootstrap/Makefile b/xcode/bootstrap/Makefile new file mode 100644 index 0000000..26477bc --- /dev/null +++ b/xcode/bootstrap/Makefile @@ -0,0 +1,86 @@ +GREEN := $(shell tput -Txterm setaf 2) +YELLOW := $(shell tput -Txterm setaf 3) +WHITE := $(shell tput -Txterm setaf 7) +RESET := $(shell tput -Txterm sgr0) + +RUBY_VERSION="2.7.6" + +open_project=(open *.xcworkspace) +install_dev_certs=(bundle exec fastlane SyncCodeSigning type:development readonly:true) +install_pods=(bundle exec pod install || bundle exec pod install --repo-update) + +TARGET_MAX_CHAR_NUM=20 +## Show help +help: + @echo '' + @echo 'Использование:' + @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' + @echo '' + @echo 'Команды:' + @awk '/^[a-zA-Z\-\_0-9]+:/ { \ + helpMessage = match(lastLine, /^## (.*)/); \ + if (helpMessage) { \ + helpCommand = substr($$1, 0, index($$1, ":")-1); \ + helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ + printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ + } \ + } \ + { lastLine = $$0 }' $(MAKEFILE_LIST) + +## Инициализирует проект и устанавливает системные утилиты +init: + brew bundle + + eval "$(rbenv init -)" + + rbenv install -s ${RUBY_VERSION} + rbenv global ${RUBY_VERSION} + + if ! gem spec bundler > /dev/null 2>&1; then\ + echo "bundler gem is not installed!";\ + -sudo gem install bundler;\ + fi + + bundle install + + xcodegen generate + + $(call install_pods) + + bundle exec fastlane install_plugins + + $(call install_dev_certs) + + $(call open_project) + + git config --local core.hooksPath .githooks + +## Устанавливает поды +pod: + $(call install_pods) + +## Устанавливает сертификат и профили для запуска на девайсе +dev_certs: + $(call install_dev_certs) + +## Открывает папку для ручного редактирования сертификатов и профайлов +update_certs: + bundle exec fastlane ManuallyUpdateCodeSignin + +## Поднимает версию приложения (параметр "X.Y.Z") +bumpAppVersion: + ifeq ($(version),undefined) + @echo "Version parameter is missing (ex: x.y.z)" $(target) + else + bundle exec fastlane run increment_version_number version_number:$(version) + endif + +## Позволяет быстро открыть workspace проекта +start: + $(call open_project) + +## Очищает содержимое папки DerivedData +clean: + rm -rf ~/Library/Developer/Xcode/DerivedData/* + + diff --git a/xcode/bootstrap/setup.command b/xcode/bootstrap/setup.command new file mode 100755 index 0000000..0ae8983 --- /dev/null +++ b/xcode/bootstrap/setup.command @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_DIR="${DIR}/../../../" + +make init -C ${PROJECT_DIR} \ No newline at end of file From c4b340ec448fa674ffd214434149d74b61bed8bc Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Fri, 9 Dec 2022 18:21:07 +0300 Subject: [PATCH 05/11] fix Makefile commands --- xcode/bootstrap/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcode/bootstrap/Makefile b/xcode/bootstrap/Makefile index 26477bc..31fa135 100644 --- a/xcode/bootstrap/Makefile +++ b/xcode/bootstrap/Makefile @@ -43,7 +43,7 @@ init: bundle install - xcodegen generate + xcodegen $(call install_pods) @@ -65,7 +65,7 @@ dev_certs: ## Открывает папку для ручного редактирования сертификатов и профайлов update_certs: - bundle exec fastlane ManuallyUpdateCodeSignin + bundle exec fastlane ManuallyUpdateCodeSigning ## Поднимает версию приложения (параметр "X.Y.Z") bumpAppVersion: From 34dcae1d5cad13d8a0d587e87898e82f89c52714 Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Mon, 16 Jan 2023 12:22:21 +0300 Subject: [PATCH 06/11] Common `Makefile` indentations converted to tabs --- xcode/bootstrap/Makefile | 80 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/xcode/bootstrap/Makefile b/xcode/bootstrap/Makefile index 31fa135..7894911 100644 --- a/xcode/bootstrap/Makefile +++ b/xcode/bootstrap/Makefile @@ -12,75 +12,75 @@ install_pods=(bundle exec pod install || bundle exec pod install --repo-update) TARGET_MAX_CHAR_NUM=20 ## Show help help: - @echo '' - @echo 'Использование:' - @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' - @echo '' - @echo 'Команды:' - @awk '/^[a-zA-Z\-\_0-9]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")-1); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) + @echo '' + @echo 'Использование:' + @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' + @echo '' + @echo 'Команды:' + @awk '/^[a-zA-Z\-\_0-9]+:/ { \ + helpMessage = match(lastLine, /^## (.*)/); \ + if (helpMessage) { \ + helpCommand = substr($$1, 0, index($$1, ":")-1); \ + helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ + printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ + } \ + } \ + { lastLine = $$0 }' $(MAKEFILE_LIST) ## Инициализирует проект и устанавливает системные утилиты init: - brew bundle + brew bundle - eval "$(rbenv init -)" + eval "$(rbenv init -)" - rbenv install -s ${RUBY_VERSION} - rbenv global ${RUBY_VERSION} + rbenv install -s ${RUBY_VERSION} + rbenv global ${RUBY_VERSION} - if ! gem spec bundler > /dev/null 2>&1; then\ - echo "bundler gem is not installed!";\ - -sudo gem install bundler;\ - fi + if ! gem spec bundler > /dev/null 2>&1; then\ + echo "bundler gem is not installed!";\ + -sudo gem install bundler;\ + fi - bundle install + bundle install - xcodegen + xcodegen - $(call install_pods) + $(call install_pods) - bundle exec fastlane install_plugins + bundle exec fastlane install_plugins - $(call install_dev_certs) + $(call install_dev_certs) - $(call open_project) + $(call open_project) - git config --local core.hooksPath .githooks - + git config --local core.hooksPath .githooks + ## Устанавливает поды pod: - $(call install_pods) + $(call install_pods) ## Устанавливает сертификат и профили для запуска на девайсе dev_certs: - $(call install_dev_certs) + $(call install_dev_certs) ## Открывает папку для ручного редактирования сертификатов и профайлов update_certs: - bundle exec fastlane ManuallyUpdateCodeSigning + bundle exec fastlane ManuallyUpdateCodeSigning ## Поднимает версию приложения (параметр "X.Y.Z") bumpAppVersion: - ifeq ($(version),undefined) - @echo "Version parameter is missing (ex: x.y.z)" $(target) - else - bundle exec fastlane run increment_version_number version_number:$(version) - endif + ifeq ($(version),undefined) + @echo "Version parameter is missing (ex: x.y.z)" $(target) + else + bundle exec fastlane run increment_version_number version_number:$(version) + endif ## Позволяет быстро открыть workspace проекта start: - $(call open_project) + $(call open_project) ## Очищает содержимое папки DerivedData clean: - rm -rf ~/Library/Developer/Xcode/DerivedData/* + rm -rf ~/Library/Developer/Xcode/DerivedData/* From 4d7182fd675bc267c76a8eb24572f85305fb6a6f Mon Sep 17 00:00:00 2001 From: Roman Pelmegov Date: Fri, 3 Mar 2023 14:33:55 +0000 Subject: [PATCH 07/11] issue-333 last commit date --- scripts/export_src.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/export_src.sh b/scripts/export_src.sh index 11a5290..86e8e9f 100755 --- a/scripts/export_src.sh +++ b/scripts/export_src.sh @@ -19,8 +19,12 @@ if [ -z "${GIT_BRANCH}" ]; then GIT_BRANCH="master" fi +if [ -z "${EXPORT_DATE}" ]; then + EXPORT_DATE=$(env -i git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d') +fi + PROJECT_NAME=$1 -SRC_FOLDER_NAME="${PROJECT_NAME}-src-$(date +%F)" +SRC_FOLDER_NAME="${PROJECT_NAME}-src-${EXPORT_DATE}" SRC_DIR="./${SRC_FOLDER_NAME}" COMMAND_LINE_ARGUMENTS=$@ From c5b794752600b22e23500d89f395ce8e954d6116 Mon Sep 17 00:00:00 2001 From: Roman Pelmegov Date: Fri, 3 Mar 2023 14:52:02 +0000 Subject: [PATCH 08/11] issue-333 use git archive --- scripts/export_src.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/export_src.sh b/scripts/export_src.sh index 86e8e9f..f9b8c07 100755 --- a/scripts/export_src.sh +++ b/scripts/export_src.sh @@ -48,6 +48,6 @@ do done find . -name ".git*" -print0 | xargs -0 rm -rf -zip -r -q ${SRC_FOLDER_NAME}.zip . +git archive -o ${SRC_FOLDER_NAME}.zip HEAD open . From 84db8a0e092a54d49f2149fc5206c8a4da8444d5 Mon Sep 17 00:00:00 2001 From: Roman Pelmegov Date: Fri, 3 Mar 2023 15:13:10 +0000 Subject: [PATCH 09/11] issue-333 fix --- scripts/export_src.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/export_src.sh b/scripts/export_src.sh index f9b8c07..5ad69e8 100755 --- a/scripts/export_src.sh +++ b/scripts/export_src.sh @@ -47,7 +47,6 @@ do fi done -find . -name ".git*" -print0 | xargs -0 rm -rf git archive -o ${SRC_FOLDER_NAME}.zip HEAD open . From 216c2288982b022601acb16155768b17239507cd Mon Sep 17 00:00:00 2001 From: Roman Pelmegov Date: Tue, 7 Mar 2023 11:07:27 +0000 Subject: [PATCH 10/11] last commit date --- scripts/export_src.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/export_src.sh b/scripts/export_src.sh index 5ad69e8..f09b432 100755 --- a/scripts/export_src.sh +++ b/scripts/export_src.sh @@ -19,12 +19,9 @@ if [ -z "${GIT_BRANCH}" ]; then GIT_BRANCH="master" fi -if [ -z "${EXPORT_DATE}" ]; then - EXPORT_DATE=$(env -i git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d') -fi - +LAST_COMMIT_DATE="" PROJECT_NAME=$1 -SRC_FOLDER_NAME="${PROJECT_NAME}-src-${EXPORT_DATE}" +SRC_FOLDER_NAME="${PROJECT_NAME}-src" SRC_DIR="./${SRC_FOLDER_NAME}" COMMAND_LINE_ARGUMENTS=$@ @@ -32,8 +29,17 @@ COMMAND_LINE_ARGUMENTS=$@ clone_platform() { PROJECT_NAME=$1 PLATFORM=$2 - - git clone --recurse-submodules -j8 "git@github.com:TouchInstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}" + + if git clone --recurse-submodules -j8 "git@gitlab.ti:touchinstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}"; then + cd ${PROJECT_NAME}-${PLATFORM} + + COMMIT_DATE=`git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d'` + if [[ $LAST_COMMIT_DATE < $COMMIT_DATE ]]; then + LAST_COMMIT_DATE="${COMMIT_DATE}" + fi + + cd .. + fi } mkdir -p "${SRC_DIR}" @@ -47,6 +53,11 @@ do fi done -git archive -o ${SRC_FOLDER_NAME}.zip HEAD +if [ -z "${EXPORT_DATE}" ]; then + EXPORT_DATE="${LAST_COMMIT_DATE}" +fi + +find . -name ".git*" -print0 | xargs -0 rm -rf +zip -r -q "${SRC_FOLDER_NAME}-${EXPORT_DATE}".zip . open . From 0400dbe36db6f6f12118f09f54b2022e880ad7dd Mon Sep 17 00:00:00 2001 From: Roman Pelmegov Date: Tue, 7 Mar 2023 16:26:54 +0000 Subject: [PATCH 11/11] issue-333 break on git clone error --- scripts/export_src.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/export_src.sh b/scripts/export_src.sh index f09b432..0267c66 100755 --- a/scripts/export_src.sh +++ b/scripts/export_src.sh @@ -39,6 +39,8 @@ clone_platform() { fi cd .. + else + exit 1 fi }