11<?php
22
3- namespace DiscordCoreAPI \Packager ;
3+ namespace discordcoreapi \Packager ;
44
55use \RuntimeException ;
66
@@ -46,13 +46,12 @@ public function __construct()
4646 if (count ($ argv ) < 2 ) {
4747 throw new RuntimeException (RED . "Missing github repository owner and access token \n" . WHITE );
4848 }
49- echo GREEN . "Starting Vcpkg updater... \n" . WHITE ;
49+ echo GREEN . "Starting vcpkg updater... \n" . WHITE ;
5050
5151 /* Get the latest tag from the version of the repository checked out by default into the action */
5252 $ this ->latestTag = preg_replace ("/ \n/ " , "" , shell_exec ("git describe --tags `git rev-list --tags --max-count=1` " ));
5353 $ this ->version = preg_replace ('/^v/ ' , '' , $ this ->getTag ());
5454 echo GREEN . "Latest tag: " . $ this ->getTag () . " version: " . $ this ->getVersion () . "\n" . WHITE ;
55- echo GREEN . trim (`which sudo `) . WHITE ;
5655
5756 $ this ->git = trim (`which git `);
5857 $ this ->sudo = trim (`which sudo `);
@@ -80,12 +79,12 @@ public function getTag(): string
8079
8180 private function git (string $ parameters , bool $ sudo = false ): void
8281 {
83- system (($ sudo ? ' sudo ' : '' ) . $ this ->git . ' ' . $ parameters );
82+ system (($ sudo ? $ this -> sudo . ' ' : '' ) . $ this ->git . ' ' . $ parameters );
8483 }
8584
86- private function sudo (string $ command ): void
85+ private function sudo (string $ command ): void
8786 {
88- system (' sudo ' . $ command );
87+ system ($ this -> sudo . ' ' . $ command );
8988 }
9089
9190 /**
@@ -103,13 +102,13 @@ function checkoutRepository(string $tag = ""): bool
103102 /* Empty tag means use the main branch */
104103 $ tag = `{$ this ->git } config --get init.defaultBranch || echo main `;
105104 }
106- $ repositoryUrl = 'https:// ' . urlencode ($ argv [1 ]) . ': ' . urlencode ($ argv [2 ]) . '@github.com/realtimechris/DiscordCoreAPI ' ;
105+ $ repositoryUrl = 'https:// ' . urlencode ($ argv [1 ]) . ': ' . urlencode ($ argv [2 ]) . '@github.com/realtimechris/discordcoreapi ' ;
107106
108107 echo GREEN . "Check out repository: $ tag (user: " . $ argv [1 ] . " branch: " . $ tag . ") \n" . WHITE ;
109108
110109 chdir (getenv ('HOME ' ));
111110 system ('rm -rf ./discordcoreapi ' );
112- $ this ->git ('config --global user.email "noreply@discordcoreapi .com" ' );
111+ $ this ->
git (
'config --global user.email "[email protected] .com" ' );
113112 $ this ->git ('config --global user.name "realtimechris" ' );
114113 $ this ->git ('clone ' . escapeshellarg ($ repositoryUrl ) . ' ./discordcoreapi --depth=1 ' );
115114
@@ -126,7 +125,7 @@ function checkoutRepository(string $tag = ""): bool
126125 * build the branch that is cloned at ~/discordcoreapi
127126 *
128127 * @param string $sha512 The SHA512 sum of the tagged download, or initially
129- * zero, which means that the Vcpkg install command should obtain it the
128+ * zero, which means that the vcpkg install command should obtain it the
130129 * second time around.
131130 * @return string The portfile content
132131 */
@@ -142,7 +141,8 @@ function constructPortAndVersionFile(string $sha512 = "0"): string
142141vcpkg_from_github(
143142 OUT_SOURCE_PATH SOURCE_PATH
144143 REPO RealTimeChris/DiscordCoreAPI
145- REF "v${VERSION}"
144+ REF 4e08675
145+ SHA512 ' . $ sha512 . 'HEAD_REF main
146146)
147147
148148vcpkg_cmake_configure(
@@ -167,7 +167,7 @@ function constructPortAndVersionFile(string $sha512 = "0"): string
167167 // ./Vcpkg/ports/discordcoreapi/vcpkg.json
168168 $ versionFileContent = '{
169169 "name": "discordcoreapi",
170- "version": "1.3.0 ",
170+ "version-date ": "2022-03-03 ",
171171 "description": "A Discord bot library written in C++ using custom asynchronous coroutines.",
172172 "homepage": "https://discordcoreapi.com",
173173 "license": "LGPL-2.1-or-later",
@@ -187,15 +187,14 @@ function constructPortAndVersionFile(string $sha512 = "0"): string
187187 "host": true
188188 }
189189 ]
190- }
191- ' ;
190+ } ' ;
192191 echo GREEN . "Writing portfile... \n" . WHITE ;
193192 file_put_contents ('./Vcpkg/ports/discordcoreapi/vcpkg.json ' , $ versionFileContent );
194193 return $ portFileContent ;
195194 }
196195
197196 /**
198- * Attempt the first build of the Vcpkg port. This will always fail, as it is given
197+ * Attempt the first build of the vcpkg port. This will always fail, as it is given
199198 * an SHA512 sum of 0. When it fails the output contains the SHA512 sum, which is then
200199 * extracted from the error output using a regular expression, and saved for a second
201200 * attempt.
@@ -215,7 +214,7 @@ function firstBuild(string $portFileContent): string
215214 file_put_contents ('/tmp/portfile ' , $ portFileContent );
216215 $ this ->sudo ('cp -v -R /tmp/portfile /usr/local/share/vcpkg/ports/discordcoreapi/portfile.cmake ' );
217216 unlink ('/tmp/portfile ' );
218- $ buildResults = shell_exec (' sudo ' . ' /usr/local/share/vcpkg/vcpkg install discordcoreapi:x64-linux ' );
217+ $ buildResults = shell_exec ($ this -> sudo . ' /usr/local/share/vcpkg/vcpkg install discordcoreapi:x64-linux ' );
219218 $ matches = [];
220219 if (preg_match ('/Actual hash:\s+([0-9a-fA-F]+)/ ' , $ buildResults , $ matches )) {
221220 echo GREEN . "Obtained SHA512 for first build: " . $ matches [1 ] . "\n" . WHITE ;
@@ -228,8 +227,8 @@ function firstBuild(string $portFileContent): string
228227
229228 /**
230229 * Second build using a valid SHA512 sum. This attempt should succeed, allowing us to push
231- * the changed Vcpkg portfiles into the master branch, where they can be used in a PR to
232- * microsoft/Vcpkg repository later.
230+ * the changed vcpkg portfiles into the master branch, where they can be used in a PR to
231+ * microsoft/vcpkg repository later.
233232 *
234233 * @param string $portFileContent the contents of the portfile, containing a valid SHA512
235234 * sum from the first build attempt.
@@ -250,31 +249,31 @@ function secondBuild(string $portFileContent): bool
250249 $ this ->sudo ('cp -v -R ./Vcpkg/ports/discordcoreapi/portfile.cmake /usr/local/share/vcpkg/ports/discordcoreapi/portfile.cmake ' );
251250 $ this ->sudo ('cp -v -R ./Vcpkg/ports/* /usr/local/share/vcpkg/ports/ ' );
252251
253- echo GREEN . "Vcpkg x-add-version... \n" . WHITE ;
252+ echo GREEN . "vcpkg x-add-version... \n" . WHITE ;
254253 chdir ('/usr/local/share/vcpkg ' );
255- $ this ->sudo ('./Vcpkg format-manifest ./ports/discordcoreapi/vcpkg.json ' );
254+ $ this ->sudo ('./vcpkg format-manifest ./ports/discordcoreapi/vcpkg.json ' );
256255 /* Note: We commit this in /usr/local, but we never push it (we can't) */
257256 $ this ->git ('add . ' , true );
258- $ this ->git ('git commit -m "[bot] VCPKG info update" ' , true );
257+ $ this ->git ('commit -m "VCPKG info update" ' , true );
259258 $ this ->sudo ('/usr/local/share/vcpkg/vcpkg x-add-version discordcoreapi ' );
260259
261260 echo GREEN . "Copy back port files from /usr/local/share... \n" . WHITE ;
262261 chdir (getenv ('HOME ' ) . '/discordcoreapi ' );
263262 system ('cp -v -R /usr/local/share/vcpkg/ports/discordcoreapi/vcpkg.json ./Vcpkg/ports/discordcoreapi/vcpkg.json ' );
264263 system ('cp -v -R /usr/local/share/vcpkg/versions/baseline.json ./Vcpkg/versions/baseline.json ' );
265- system ('cp -v -R /usr/local/share/vcpkg/versions/d -/discordcoreapi.json ./Vcpkg/versions/d -/discordcoreapi.json ' );
264+ system ('cp -v -R /usr/local/share/vcpkg/versions/j -/discordcoreapi.json ./Vcpkg/versions/j -/discordcoreapi.json ' );
266265
267- echo GREEN . "Commit and push changes to master branch \n" . WHITE ;
266+ echo GREEN . "Commit and push changes to main branch \n" . WHITE ;
268267 $ this ->git ('add . ' );
269- $ this ->git ('commit -m "[bot] VCPKG info update [skip ci]" ' );
268+ $ this ->git ('commit -m "VCPKG info update [skip ci]" ' );
270269 $ this ->git ('config pull.rebase false ' );
271270 $ this ->git ('pull ' );
272- $ this ->git ('push origin master ' );
271+ $ this ->git ('push origin main ' );
273272
274- echo GREEN . "Vcpkg install... \n" . WHITE ;
273+ echo GREEN . "vcpkg install... \n" . WHITE ;
275274 $ resultCode = 0 ;
276275 $ output = [];
277- exec ($ this ->sudo . ' /usr/local/share/vcpkg/Vcpkg install discordcoreapi:x64-linux ' , $ output , $ resultCode );
276+ exec ($ this ->sudo . ' /usr/local/share/vcpkg/vcpkg install discordcoreapi:x64-linux ' , $ output , $ resultCode );
278277
279278 if ($ resultCode != 0 ) {
280279 echo RED . "There were build errors! \n\nBuild log: \n" . WHITE ;
0 commit comments