@@ -20,10 +20,14 @@ local option_list=(
20
20
" "
21
21
" Xcode - Initialize project"
22
22
" Xcode - Clean all build cache"
23
- # " "
24
- # "Carthage - Update all platforms"
25
- # "Cocoapods - Clean all cache"
26
- # "Public Suffix List - Download latest data"
23
+ " "
24
+ " Carthage - Update all platforms"
25
+ " Cocoapods - Clean all cache"
26
+ " Cocoapods - Trunk push"
27
+ " "
28
+ " Github - Update tag"
29
+ " "
30
+ " Public Suffix List - Download latest data"
27
31
)
28
32
29
33
local fastlane_command () {
@@ -45,14 +49,6 @@ local xcode_init() {
45
49
# psl_download;
46
50
}
47
51
48
- local cocoapods_clean () {
49
- pod cache clean --all;
50
- }
51
-
52
- local psl_download () {
53
- python update-psl.py;
54
- }
55
-
56
52
local carthage_update () {
57
53
carthage update --platform macos;
58
54
carthage update --platform ios;
@@ -61,6 +57,75 @@ local carthage_update() {
61
57
carthage update --platform visionos;
62
58
}
63
59
60
+ local cocoapods_clean () {
61
+ pod cache clean --all;
62
+ }
63
+
64
+ local cocoapods_trunk_push () {
65
+ # Enable error handling and exit the script on pipe failures
66
+ set -eo pipefail
67
+ # Check if the current branch is 'main'
68
+ if [[ $( git rev-parse --abbrev-ref HEAD) != " main" ]]; then
69
+ echo " Warning: You are not on the main branch. Please switch to the main branch and run again."
70
+ exit 1
71
+ fi
72
+ # Find the project name and podspec name
73
+ project_name=$( find . -maxdepth 1 -name " *.xcodeproj" -exec basename {} .xcodeproj \; )
74
+ podspec_name=$( find . -maxdepth 1 -name " *.podspec" -exec basename {} .podspec \; )
75
+ # Retrieve the current version from the project file
76
+ current_version=$( grep -m1 ' MARKETING_VERSION' " ${project_name} .xcodeproj/project.pbxproj" | sed ' s/.*= //;s/;//' )
77
+ echo " Current version: $current_version "
78
+ # Check if the current version is a valid semantic version
79
+ if [[ ! " $current_version " =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
80
+ echo " Error: Invalid version number"
81
+ exit 1
82
+ fi
83
+ # Check if the current version already exists in the CocoaPods trunk
84
+ if pod trunk info ${podspec_name} | grep -q " $current_version " ; then
85
+ echo " Start deleting $current_version "
86
+ # Delete the existing version from the CocoaPods trunk
87
+ echo " y" | pod trunk delete ${podspec_name} $current_version || true
88
+ fi
89
+ echo " Start pushing $current_version "
90
+ # Push the new version to the CocoaPods trunk
91
+ pod trunk push ${podspec_name} .podspec --allow-warnings
92
+ }
93
+
94
+ local github_update_tag () {
95
+ # Enable error handling and exit the script on pipe failures
96
+ set -eo pipefail
97
+ # Check if the current branch is 'main'
98
+ if [[ $( git rev-parse --abbrev-ref HEAD) != " main" ]]; then
99
+ echo " Warning: You are not on the main branch. Please switch to the main branch and run again."
100
+ exit 1
101
+ fi
102
+ # Find the project name and podspec name
103
+ project_name=$( find . -maxdepth 1 -name " *.xcodeproj" -exec basename {} .xcodeproj)
104
+ podspec_name=$( find . -maxdepth 1 -name " *.podspec" -exec basename {} .podspec)
105
+ # Retrieve build settings and execute a command to filter MARKETING_VERSION
106
+ current_version=$( grep -m1 ' MARKETING_VERSION' " ${project_name} .xcodeproj/project.pbxproj" | sed ' s/.*= //;s/;//' )
107
+ echo " Current version: $current_version "
108
+ # If the current version is found
109
+ if [[ $current_version =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
110
+ # Check if a tag for the current version already exists
111
+ if git tag -l | grep -q " $current_version " ; then
112
+ # If the tag exists, delete it from both local and remote
113
+ git tag -d " $current_version "
114
+ git push origin " :refs/tags/$current_version "
115
+ fi
116
+ # Create a new tag for the current version and push it to the remote repository
117
+ git tag " $current_version "
118
+ git push origin " $current_version "
119
+ else
120
+ # If the version could not be retrieved, display an error message
121
+ echo " Error: Could not retrieve the version."
122
+ fi
123
+ }
124
+
125
+ local psl_download () {
126
+ python update-psl.py;
127
+ }
128
+
64
129
local bundle_init () {
65
130
rm -rf .bundle;
66
131
rm -rf Gemfile.lock;
@@ -75,8 +140,10 @@ case "$selected_option" in
75
140
fastlane* ) fastlane_command $selected_option ;;
76
141
" Xcode - Initialize project" ) xcode_init;;
77
142
" Xcode - Clean all build cache" ) xcode_clean;;
78
- " Cocoapods - Clean all cache" ) cocoapods_clean;;
79
143
" Carthage - Update all platforms" ) carthage_update;;
144
+ " Cocoapods - Clean all cache" ) cocoapods_clean;;
145
+ " Cocoapods - Trunk push" ) cocoapods_trunk_push;;
146
+ " Github - Update tag" ) github_update_tag;;
80
147
" Public Suffix List - Download latest data" ) psl_download;;
81
148
* ) echo " Invalid option $selected_option " && exit 1;;
82
149
esac
0 commit comments