@@ -50,21 +50,30 @@ public function handle(): int
50
50
51
51
$ buildData = $ response ->json ();
52
52
53
- if (! isset ($ buildData ['download_url ' ])) {
53
+ if (! isset ($ buildData ['data ' ][ ' download_url ' ])) {
54
54
$ this ->error ('Bundle download URL not found in response. ' );
55
55
56
56
return static ::FAILURE ;
57
57
}
58
58
59
- $ this ->displayBundleInfo ($ buildData );
59
+ $ this ->displayBundleInfo ($ buildData[ ' data ' ] );
60
60
61
61
$ bundlePath = $ this ->prepareBundlePath ();
62
62
63
- if (! $ this ->downloadBundle ($ buildData ['download_url ' ], $ bundlePath )) {
63
+ if (! $ this ->downloadBundle ($ buildData ['data ' ][ ' download_url ' ], $ bundlePath )) {
64
64
return static ::FAILURE ;
65
65
}
66
66
67
- $ this ->displaySuccessInfo ($ bundlePath );
67
+ // Download GPG signature if available
68
+ $ signaturePath = null ;
69
+ if (isset ($ buildData ['data ' ]['signature_url ' ])) {
70
+ $ signaturePath = $ bundlePath . '.asc ' ;
71
+ if (! $ this ->downloadSignature ($ buildData ['data ' ]['signature_url ' ], $ signaturePath )) {
72
+ $ this ->warn ('Failed to download GPG signature file. ' );
73
+ }
74
+ }
75
+
76
+ $ this ->displaySuccessInfo ($ bundlePath , $ signaturePath );
68
77
69
78
return static ::SUCCESS ;
70
79
} catch (Exception $ e ) {
@@ -143,7 +152,27 @@ private function cleanupFailedDownload(string $bundlePath): void
143
152
}
144
153
}
145
154
146
- private function displaySuccessInfo (string $ bundlePath ): void
155
+ private function downloadSignature (string $ signatureUrl , string $ signaturePath ): bool
156
+ {
157
+ $ this ->line ('' );
158
+ $ this ->info ('Downloading GPG signature... ' );
159
+
160
+ try {
161
+ $ downloadResponse = Http::get ($ signatureUrl );
162
+
163
+ if ($ downloadResponse ->failed ()) {
164
+ return false ;
165
+ }
166
+
167
+ file_put_contents ($ signaturePath , $ downloadResponse ->body ());
168
+
169
+ return true ;
170
+ } catch (Exception $ e ) {
171
+ return false ;
172
+ }
173
+ }
174
+
175
+ private function displaySuccessInfo (string $ bundlePath , ?string $ signaturePath = null ): void
147
176
{
148
177
$ this ->line ('' );
149
178
$ this ->info ('Bundle downloaded successfully! ' );
@@ -153,6 +182,13 @@ private function displaySuccessInfo(string $bundlePath): void
153
182
$ sizeInMB = number_format (filesize ($ bundlePath ) / 1024 / 1024 , 2 );
154
183
$ this ->line ("Size: {$ sizeInMB } MB " );
155
184
}
185
+
186
+ if ($ signaturePath && file_exists ($ signaturePath )) {
187
+ $ this ->line ('GPG Signature: ' .$ signaturePath );
188
+ $ this ->line ('' );
189
+ $ this ->info ('To verify the bundle integrity: ' );
190
+ $ this ->line ('gpg --verify ' .basename ($ signaturePath ).' ' .basename ($ bundlePath ));
191
+ }
156
192
}
157
193
158
194
private function handleApiError ($ response ): void
0 commit comments