Repository navigation
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·114 lines (102 loc) · 3.32 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·114 lines (102 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/zsh
# Check if the 'fzf' command is available in the system
if ! command -v fzf &> /dev/null; then
tput setaf 1; echo "fzf is not installed."; tput sgr0;
exit 1;
fi
local option_list=(
"fastlane run_all"
"fastlane lint_swift"
"fastlane tests"
"fastlane build_spm"
"fastlane build_carthage"
"fastlane gen_docs"
"fastlane set_version"
"fastlane bump_version"
" "
"Xcode - Initialize project"
"Xcode - Clean all build cache"
" "
"Carthage - Update all platforms"
" "
"Github - Update tag"
"Github - Fetch remote tag"
)
local fastlane_command() {
bundle exec $1
}
local xcode_clean() {
xcodebuild clean || \
xcodebuild -alltargets clean || \
xcrun --kill-cache || \
xcrun simctl erase all || \
rm -rf ~/Library/Developer/Xcode/DerivedData/*;
}
local xcode_init() {
bundle_init;
xcode_clean;
rm -rf ./Carthage/*;
carthage_update;
psl_download;
}
local carthage_update() {
carthage update --platform macos;
carthage update --platform ios;
carthage update --platform tvos;
carthage update --platform watchos;
carthage update --platform visionos;
}
local github_update_tag() {
# Enable error handling and exit the script on pipe failures
set -eo pipefail
# Check if the current branch is 'main'
if [[ $(git rev-parse --abbrev-ref HEAD) != "main" ]]; then
echo "Warning: You are not on the main branch. Please switch to the main branch and run again."
exit 1
fi
# Find the project name
project_name=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj)
# Retrieve build settings and execute a command to filter MARKETING_VERSION
current_version=$(grep -m1 'MARKETING_VERSION' "${project_name}.xcodeproj/project.pbxproj" | sed 's/.*= //;s/;//')
echo "Current version: $current_version"
# If the current version is found
if [[ $current_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Tags are immutable: never delete or overwrite an existing version tag
if git tag -l | grep -q "^${current_version}$"; then
echo "Error: Tag $current_version already exists. Bump the version instead of retagging."
exit 1
fi
# Create a new tag for the current version and push it to the remote repository
# Pushing this tag triggers the Release workflow (GitHub Release creation)
git tag "$current_version"
git push origin "$current_version"
else
# If the version could not be retrieved, display an error message
echo "Error: Could not retrieve the version."
fi
}
local github_fetch_remote_tag() {
git fetch --tags --force;
}
local psl_download() {
python update-psl.py;
}
local bundle_init() {
rm -rf .bundle;
rm -rf Gemfile.lock;
gem install bundler;
bundle install;
bundle update;
bundle exec fastlane add_plugin versioning;
}
local selected_option=$(printf "%s\n" "${option_list[@]}" | fzf --ansi --prompt="Select a job to execute > ")
case "$selected_option" in
fastlane*) fastlane_command $selected_option;;
"Xcode - Initialize project") xcode_init;;
"Xcode - Clean all build cache") xcode_clean;;
"Carthage - Update all platforms") carthage_update;;
"Github - Update tag") github_update_tag;;
"Github - Fetch remote tag") github_fetch_remote_tag;;
*) echo "Invalid option $selected_option" && exit 1;;
esac
exit 0;