@@ -48,13 +48,18 @@ public function __construct()
4848 ->param ('message ' , null , new Nullable (new Text (256 )), 'Commit Message ' , optional: true )
4949 ->param ('release ' , null , new Nullable (new WhiteList (['yes ' , 'no ' ])), 'Should we create releases? ' , optional: true )
5050 ->param ('commit ' , null , new Nullable (new WhiteList (['yes ' , 'no ' ])), 'Actually create releases (yes) or dry-run (no)? ' , optional: true )
51+ ->param ('sdks ' , null , new Nullable (new Text (256 )), 'Selected SDKs ' , optional: true )
5152 ->callback ($ this ->action (...));
5253 }
5354
54- public function action (?string $ selectedPlatform , ?string $ selectedSDK , ?string $ version , ?string $ git , ?string $ production , ?string $ message , ?string $ release , ?string $ commit ): void
55+ public function action (?string $ selectedPlatform , ?string $ selectedSDK , ?string $ version , ?string $ git , ?string $ production , ?string $ message , ?string $ release , ?string $ commit, ? string $ sdks ): void
5556 {
56- $ selectedPlatform ??= Console::confirm ('Choose Platform (" ' . APP_PLATFORM_CLIENT . '", " ' . APP_PLATFORM_SERVER . '", " ' . APP_PLATFORM_CONSOLE . '" or "*" for all): ' );
57- $ selectedSDK ??= \strtolower (Console::confirm ('Choose SDK ("*" for all): ' ));
57+ if (!$ sdks ){
58+ $ selectedPlatform ??= Console::confirm ('Choose Platform (" ' . APP_PLATFORM_CLIENT . '", " ' . APP_PLATFORM_SERVER . '", " ' . APP_PLATFORM_CONSOLE . '" or "*" for all): ' );
59+ $ selectedSDK ??= \strtolower (Console::confirm ('Choose SDK ("*" for all): ' ));
60+ } else {
61+ $ sdks = explode (', ' , $ sdks );
62+ }
5863 $ version ??= Console::confirm ('Choose an Appwrite version ' );
5964
6065 $ createRelease = ($ release === 'yes ' );
@@ -104,12 +109,12 @@ public function action(?string $selectedPlatform, ?string $selectedSDK, ?string
104109
105110 $ platforms = Config::getParam ('platforms ' );
106111 foreach ($ platforms as $ key => $ platform ) {
107- if ($ selectedPlatform !== $ key && $ selectedPlatform !== '* ' ) {
112+ if ($ selectedPlatform !== $ key && $ selectedPlatform !== '* ' && ( $ sdks === null ) ) {
108113 continue ;
109114 }
110115
111116 foreach ($ platform ['sdks ' ] as $ language ) {
112- if ($ selectedSDK !== $ language ['key ' ] && $ selectedSDK !== '* ' ) {
117+ if ($ selectedSDK !== $ language ['key ' ] && $ selectedSDK !== '* ' && ( $ sdks === null || ! \in_array ( $ language [ ' key ' ], $ sdks )) ) {
113118 continue ;
114119 }
115120
@@ -472,38 +477,60 @@ public function action(?string $selectedPlatform, ?string $selectedSDK, ?string
472477 $ errorMessage = implode ("\n" , $ prOutput );
473478 if (strpos ($ errorMessage , 'already exists ' ) !== false ) {
474479 Console::warning ("Pull request already exists for {$ language ['name ' ]} SDK, updating title and body... " );
475-
476- $ updateCommand = 'cd ' . $ target . ' && \
477- gh pr edit " ' . $ gitBranch . '" \
480+ $ prNumberCommand = 'cd ' . $ target . ' && \
481+ gh pr list \
478482 --repo " ' . $ repoName . '" \
479- --title " ' . $ prTitle . '" \
480- --body " ' . $ prBody . '" \
483+ --head " ' . $ gitBranch . '" \
484+ --json number \
485+ --jq ".[0].number" \
481486 2>&1 ' ;
482487
483- $ updateOutput = [];
484- $ updateReturnCode = 0 ;
485- \exec ($ updateCommand , $ updateOutput , $ updateReturnCode );
486-
487- if ($ updateReturnCode === 0 ) {
488- Console::success ("Successfully updated pull request for {$ language ['name ' ]} SDK " );
489-
490- $ prUrlCommand = 'cd ' . $ target . ' && \
491- gh pr view " ' . $ gitBranch . '" \
492- --repo " ' . $ repoName . '" \
493- --json url \
494- --jq .url \
488+ $ prNumberOutput = [];
489+ $ prNumberReturnCode = 0 ;
490+ \exec ($ prNumberCommand , $ prNumberOutput , $ prNumberReturnCode );
491+
492+ if ($ prNumberReturnCode === 0 && !empty ($ prNumberOutput [0 ])) {
493+ $ prNumber = trim ($ prNumberOutput [0 ]);
494+
495+ // Use API directly to update PR to avoid deprecated projectCards field
496+ $ updateCommand = 'cd ' . $ target . ' && \
497+ gh api \
498+ --method PATCH \
499+ -H "Accept: application/vnd.github+json" \
500+ -H "X-GitHub-Api-Version: 2022-11-28" \
501+ /repos/ ' . $ repoName . '/pulls/ ' . $ prNumber . ' \
502+ -f title=" ' . $ prTitle . '" \
503+ -f body=" ' . $ prBody . '" \
495504 2>&1 ' ;
496505
497- $ prUrlOutput = [];
498- $ prUrlReturnCode = 0 ;
499- \exec ($ prUrlCommand , $ prUrlOutput , $ prUrlReturnCode );
500-
501- if ($ prUrlReturnCode === 0 && !empty ($ prUrlOutput )) {
502- $ prUrls [$ language ['name ' ]] = $ prUrlOutput [0 ];
506+ $ updateOutput = [];
507+ $ updateReturnCode = 0 ;
508+ \exec ($ updateCommand , $ updateOutput , $ updateReturnCode );
509+
510+ if ($ updateReturnCode === 0 ) {
511+ Console::success ("Successfully updated pull request for {$ language ['name ' ]} SDK " );
512+
513+ $ prUrlCommand = 'cd ' . $ target . ' && \
514+ gh pr list \
515+ --repo " ' . $ repoName . '" \
516+ --head " ' . $ gitBranch . '" \
517+ --json url \
518+ --jq ".[0].url" \
519+ 2>&1 ' ;
520+
521+ $ prUrlOutput = [];
522+ $ prUrlReturnCode = 0 ;
523+ \exec ($ prUrlCommand , $ prUrlOutput , $ prUrlReturnCode );
524+
525+ if ($ prUrlReturnCode === 0 && !empty ($ prUrlOutput )) {
526+ $ prUrls [$ language ['name ' ]] = trim ($ prUrlOutput [0 ]);
527+ }
528+ } else {
529+ $ updateErrorMessage = implode ("\n" , $ updateOutput );
530+ Console::error ("Failed to update pull request for {$ language ['name ' ]} SDK: " . $ updateErrorMessage );
503531 }
504532 } else {
505- $ updateErrorMessage = implode ("\n" , $ updateOutput );
506- Console::error ("Failed to update pull request for {$ language ['name ' ]} SDK: " . $ updateErrorMessage );
533+ Console::error ("Failed to get PR number for {$ language ['name ' ]} SDK " );
507534 }
508535 } else {
509536 Console::error ("Failed to create pull request for {$ language ['name ' ]} SDK: " . $ errorMessage );
0 commit comments