@@ -16,36 +16,36 @@ function patchVersion() {
1616
1717 poetry version $version
1818 local bumpVersionResult=$?
19- if [ $bumpVersionResult -ne 0 ]; then
19+ if [ " $bumpVersionResult " -ne " 0 " ]; then
2020 echo " Failed to bump version of $package to $version "
21- exit 1
21+ return 1
2222 fi
2323
24- if [ " ${# deps[@]} " -ne " 0" ]; then
25- if [ " ${deps[0]} " != " " ]; then
24+ if [ " ${# deps[@]} " -ne " 0" ]; then # -ne is integer inequality
25+ if [ " ${deps[0]} " != " " ]; then # != is string inequality
2626 for dep in " ${deps[@]} " ; do
2727 poetry add $dep @$version
2828 local addDepResult=$?
29- if [ $addDepResult -ne 0 ]; then
29+ if [ " $addDepResult " -ne " 0 " ]; then
3030 echo " Failed to add $dep @$version to $package "
31- exit 1
31+ return 1
3232 fi
3333 done
3434 fi
3535 fi
3636
3737 poetry lock
3838 local lockResult=$?
39- if [ $lockResult -ne 0 ]; then
39+ if [ " $lockResult " -ne " 0 " ]; then
4040 echo " Failed to lock $package "
41- exit 1
41+ return 1
4242 fi
4343
4444 poetry install
4545 local installResult=$?
46- if [ $installResult -ne 0 ]; then
46+ if [ " $installResult " -ne " 0 " ]; then
4747 echo " Failed to install $package "
48- exit 1
48+ return 1
4949 fi
5050
5151 cd $pwd
@@ -60,27 +60,54 @@ function publishPackage() {
6060
6161 cd packages/$package
6262
63+ isPackagePublished $package $version
64+ local isPackagePublishedResult=$?
65+ echo " isPackagePublishedResult: $isPackagePublishedResult "
66+ if [ " $isPackagePublishedResult " -eq " 0" ]; then
67+ echo " Skip publish: Package $package with version $version is already published"
68+ return 0
69+ fi
70+
6371 poetry publish --build --username $username --password $password
6472 local publishResult=$?
65- if [ $publishResult -ne 0 ]; then
73+ if [ " $publishResult " -ne " 0 " ]; then
6674 echo " Failed to publish $package "
67- exit 1
75+ return 1
6876 fi
6977
7078 cd $pwd
7179}
7280
81+ # This will only work for the latest version of the package
82+ function isPackagePublished() {
83+ local package=$1
84+ local version=$2
85+
86+ poetry search $package | grep " $package ($version )"
87+ echo $( poetry search $package | grep " $package ($version )" )
88+ local exit_code=$?
89+ echo " exit_code: $exit_code "
90+
91+ if [ " $exit_code " -eq " 0" ]; then
92+ echo " Package $package with version $version is published"
93+ return 0
94+ else
95+ echo " Package $package with version $version is not published"
96+ return 1
97+ fi
98+ }
99+
73100function waitForPackagePublish() {
74101 local package=$1
75102 local version=$2
76103 local seconds=0
77104
78- while [ $seconds -lt 600 ] # Wait for 10 minutes
105+ while [ " $seconds " -lt " 600" ] # Wait for 10 minutes
79106 do
80- poetry search $package | grep " $package \( $ version\) "
107+ isPackagePublished $package $ version
81108 local exit_code=$?
82109
83- if [ $exit_code -eq 0 ]; then
110+ if [ " $exit_code " -eq " 0 " ]; then
84111 echo " Package $package with version $version is published"
85112 break
86113 fi
@@ -89,59 +116,61 @@ function waitForPackagePublish() {
89116 echo " Waiting for $seconds seconds for the $package to be published"
90117 done
91118
92- if [ $seconds -eq 600 ]; then
119+ if [ " $seconds " -eq " 600" ]; then
93120 echo " Package $package with version $version is not published"
94- exit 1
121+ return 1
95122 fi
96123}
97124
98125
99126# Patching Verion of polywrap-msgpack
100127echo " Patching Version of polywrap-msgpack to $1 "
101128patchVersion polywrap-msgpack $1
102- local patchVersionResult=$?
103- if [ $patchVersionResult -ne 0 ]; then
129+ patchVersionResult=$?
130+ if [ " $patchVersionResult " -ne " 0 " ]; then
104131 echo " Failed to bump version of polywrap-msgpack to $1 "
105132 exit 1
106133fi
107134
108135echo " Publishing polywrap-msgpack"
109136publishPackage polywrap-msgpack $2 $3
110- local publishResult=$?
111- if [ $publishResult -ne 0 ]; then
137+ publishResult=$?
138+ echo " publishResult: $publishResult "
139+ echo [ " $publishResult " -ne " 0" ]
140+ if [ " $publishResult " -ne " 0" ]; then
112141 echo " Failed to publish polywrap-msgpack"
113142 exit 1
114143fi
115144
116145echo " Waiting for the package to be published"
117146waitForPackagePublish polywrap-msgpack $1
118- local waitForPackagePublishResult=$?
119- if [ $waitForPackagePublishResult -ne 0 ]; then
147+ waitForPackagePublishResult=$?
148+ if [ " $waitForPackagePublishResult " -ne " 0 " ]; then
120149 echo " Failed to publish polywrap-msgpack"
121150 exit 1
122151fi
123152
124153# Patching Verion of polywrap-result
125154echo " Patching Version of polywrap-result to $1 "
126155patchVersion polywrap-result $1
127- local patchVersionResult=$?
128- if [ $patchVersionResult -ne 0 ]; then
156+ patchVersionResult=$?
157+ if [ " $patchVersionResult " -ne " 0 " ]; then
129158 echo " Failed to bump version of polywrap-result to $1 "
130159 exit 1
131160fi
132161
133162echo " Publishing polywrap-result"
134163publishPackage polywrap-result $2 $3
135- local publishResult=$?
136- if [ $publishResult -ne 0 ]; then
164+ publishResult=$?
165+ if [ " $publishResult " -ne " 0 " ]; then
137166 echo " Failed to publish polywrap-result"
138167 exit 1
139168fi
140169
141170echo " Waiting for the package to be published"
142171waitForPackagePublish polywrap-result $1
143- local waitForPackagePublishResult=$?
144- if [ $waitForPackagePublishResult -ne 0 ]; then
172+ waitForPackagePublishResult=$?
173+ if [ " $waitForPackagePublishResult " -ne " 0 " ]; then
145174 echo " Failed to publish polywrap-result"
146175 exit 1
147176fi
150179echo " Patching Version of polywrap-manifest to $1 "
151180deps=(polywrap-msgpack polywrap-result)
152181patchVersion polywrap-manifest $1 deps
153- local patchVersionResult=$?
154- if [ $patchVersionResult -ne 0 ]; then
182+ patchVersionResult=$?
183+ if [ " $patchVersionResult " -ne " 0 " ]; then
155184 echo " Failed to bump version of polywrap-manifest to $1 "
156185 exit 1
157186fi
158187
159188echo " Publishing polywrap-manifest"
160189publishPackage polywrap-manifest $2 $3
161- local publishResult=$?
162- if [ $publishResult -ne 0 ]; then
190+ publishResult=$?
191+ if [ " $publishResult " -ne " 0 " ]; then
163192 echo " Failed to publish polywrap-manifest"
164193 exit 1
165194fi
166195
167196echo " Waiting for the package to be published"
168197waitForPackagePublish polywrap-manifest $1
169- local waitForPackagePublishResult=$?
170- if [ $waitForPackagePublishResult -ne 0 ]; then
198+ waitForPackagePublishResult=$?
199+ if [ " $waitForPackagePublishResult " -ne " 0 " ]; then
171200 echo " Failed to publish polywrap-manifest"
172201 exit 1
173202fi
176205echo " Patching Version of polywrap-core to $1 "
177206deps=(polywrap-result polywrap-manifest)
178207patchVersion polywrap-core $1 deps
179- local patchVersionResult=$?
180- if [ $patchVersionResult -ne 0 ]; then
208+ patchVersionResult=$?
209+ if [ " $patchVersionResult " -ne " 0 " ]; then
181210 echo " Failed to bump version of polywrap-core to $1 "
182211 exit 1
183212fi
184213
185214echo " Publishing polywrap-core"
186215publishPackage polywrap-core $2 $3
187- local publishResult=$?
188- if [ $publishResult -ne 0 ]; then
216+ publishResult=$?
217+ if [ " $publishResult " -ne " 0 " ]; then
189218 echo " Failed to publish polywrap-core"
190219 exit 1
191220fi
192221
193222echo " Waiting for the package to be published"
194223waitForPackagePublish polywrap-core $1
195- local waitForPackagePublishResult=$?
196- if [ $waitForPackagePublishResult -ne 0 ]; then
224+ waitForPackagePublishResult=$?
225+ if [ " $waitForPackagePublishResult " -ne " 0 " ]; then
197226 echo " Failed to publish polywrap-core"
198227 exit 1
199228fi
202231echo " Patching Version of polywrap-wasm to $1 "
203232deps=(polywrap-msgpack polywrap-result polywrap-manifest polywrap-core)
204233patchVersion polywrap-wasm $1 deps
205- local patchVersionResult=$?
206- if [ $patchVersionResult -ne 0 ]; then
234+ patchVersionResult=$?
235+ if [ " $patchVersionResult " -ne " 0 " ]; then
207236 echo " Failed to bump version of polywrap-wasm to $1 "
208237 exit 1
209238fi
210239
211240echo " Publishing polywrap-wasm"
212241publishPackage polywrap-wasm $2 $3
213- local publishResult=$?
214- if [ $publishResult -ne 0 ]; then
242+ publishResult=$?
243+ if [ " $publishResult " -ne " 0 " ]; then
215244 echo " Failed to publish polywrap-wasm"
216245 exit 1
217246fi
218247
219248echo " Waiting for the package to be published"
220249waitForPackagePublish polywrap-wasm $1
221- local waitForPackagePublishResult=$?
222- if [ $waitForPackagePublishResult -ne 0 ]; then
250+ waitForPackagePublishResult=$?
251+ if [ " $waitForPackagePublishResult " -ne " 0 " ]; then
223252 echo " Failed to publish polywrap-wasm"
224253 exit 1
225254fi
228257echo " Patching Version of polywrap-plugin to $1 "
229258deps=(polywrap-msgpack polywrap-result polywrap-manifest polywrap-core)
230259patchVersion polywrap-plugin $1 deps
231- local patchVersionResult=$?
232- if [ $patchVersionResult -ne 0 ]; then
260+ patchVersionResult=$?
261+ if [ " $patchVersionResult " -ne " 0 " ]; then
233262 echo " Failed to bump version of polywrap-plugin to $1 "
234263 exit 1
235264fi
236265
237266echo " Publishing polywrap-plugin"
238267publishPackage polywrap-plugin $2 $3
239- local publishResult=$?
240- if [ $publishResult -ne 0 ]; then
268+ publishResult=$?
269+ if [ " $publishResult " -ne " 0 " ]; then
241270 echo " Failed to publish polywrap-plugin"
242271 exit 1
243272fi
244273
245274echo " Waiting for the package to be published"
246275waitForPackagePublish polywrap-plugin $1
247- local waitForPackagePublishResult=$?
248- if [ $waitForPackagePublishResult -ne 0 ]; then
276+ waitForPackagePublishResult=$?
277+ if [ " $waitForPackagePublishResult " -ne " 0 " ]; then
249278 echo " Failed to publish polywrap-plugin"
250279 exit 1
251280fi
254283echo " Patching Version of polywrap-uri-resolvers to $1 "
255284deps=(polywrap-result polywrap-wasm polywrap-core)
256285patchVersion polywrap-uri-resolvers $1 deps
257- local patchVersionResult=$?
258- if [ $patchVersionResult -ne 0 ]; then
286+ patchVersionResult=$?
287+ if [ " $patchVersionResult " -ne " 0 " ]; then
259288 echo " Failed to bump version of polywrap-uri-resolvers to $1 "
260289 exit 1
261290fi
262291
263292echo " Publishing polywrap-uri-resolvers"
264293publishPackage polywrap-uri-resolvers $2 $3
265- local publishResult=$?
266- if [ $publishResult -ne 0 ]; then
294+ publishResult=$?
295+ if [ " $publishResult " -ne " 0 " ]; then
267296 echo " Failed to publish polywrap-uri-resolvers"
268297 exit 1
269298fi
270299
271300echo " Waiting for the package to be published"
272301waitForPackagePublish polywrap-uri-resolvers $1
273- local waitForPackagePublishResult=$?
274- if [ $waitForPackagePublishResult -ne 0 ]; then
302+ waitForPackagePublishResult=$?
303+ if [ " $waitForPackagePublishResult " -ne " 0 " ]; then
275304 echo " Failed to publish polywrap-uri-resolvers"
276305 exit 1
277306fi
280309echo " Patching Version of polywrap-client to $1 "
281310deps=(polywrap-result polywrap-msgpack polywrap-manifest polywrap-core polywrap-uri-resolvers)
282311patchVersion polywrap-client $1 deps
283- local patchVersionResult=$?
284- if [ $patchVersionResult -ne 0 ]; then
312+ patchVersionResult=$?
313+ if [ " $patchVersionResult " -ne " 0 " ]; then
285314 echo " Failed to bump version of polywrap-client to $1 "
286315 exit 1
287316fi
288317
289318echo " Publishing polywrap-client"
290319publishPackage polywrap-client $2 $3
291- local publishResult=$?
292- if [ $publishResult -ne 0 ]; then
320+ publishResult=$?
321+ if [ " $publishResult " -ne " 0 " ]; then
293322 echo " Failed to publish polywrap-client"
294323 exit 1
295324fi
296325
297326echo " Waiting for the package to be published"
298327waitForPackagePublish polywrap-client $1
299- local waitForPackagePublishResult=$?
300- if [ $waitForPackagePublishResult -ne 0 ]; then
328+ waitForPackagePublishResult=$?
329+ if [ " $waitForPackagePublishResult " -ne " 0 " ]; then
301330 echo " Failed to publish polywrap-client"
302331 exit 1
303332fi
0 commit comments