Skip to content

Commit e14cc15

Browse files
committed
Updates! (Updating the build scripts for Vcpkg)
1 parent 7749c58 commit e14cc15

File tree

17 files changed

+151
-77
lines changed

17 files changed

+151
-77
lines changed

.github/workflows/Build-Documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
cd DiscordCoreAPI-Docs
4141
sudo git add .
4242
sudo git commit -m "Updates!" || true
43-
sudo git push origin main || true
43+
sudo git push origin main || true

.github/workflows/Build-DiscordCoreAPI-Linux-Main.yml renamed to .github/workflows/Construct-Vcpkg-Info.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: Prepare release for VCPKG
22

33
on:
4-
push:
4+
release:
5+
types: [published]
56
workflow_dispatch:
67

78
jobs:
@@ -28,6 +29,7 @@ jobs:
2829
sudo vcpkg update
2930

3031
- name: Run vcpkg release builder
31-
run: git fetch -avt &&
32+
run: dir /home/runner/work/DiscordCoreAPI/DiscordCoreAPI &&
33+
git fetch -avt &&
3234
cd BuildTools &&
33-
php make_vcpkg.php "${{ github.repository_owner }}" "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
35+
php make_vcpkg.php "${{ github.repository_owner }}" "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/DeleteRuns.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Delete old workflow runs
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
days:
6+
description: 'Number of days.'
7+
required: true
8+
default: "0"
9+
minimum_runs:
10+
description: 'The minimum runs to keep for each workflow.'
11+
required: true
12+
default: "1"
13+
delete_workflow_pattern:
14+
description: 'The name or filename of the workflow. if not set then it will target all workflows.'
15+
required: false
16+
delete_workflow_by_state_pattern:
17+
description: 'Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually'
18+
required: true
19+
default: "All"
20+
type: choice
21+
options:
22+
- "All"
23+
- active
24+
- deleted
25+
- disabled_inactivity
26+
- disabled_manually
27+
delete_run_by_conclusion_pattern:
28+
description: 'Remove workflow by conclusion: action_required, cancelled, failure, skipped, success'
29+
required: true
30+
default: "All"
31+
type: choice
32+
options:
33+
- "All"
34+
- action_required
35+
- cancelled
36+
- failure
37+
- skipped
38+
- success
39+
dry_run:
40+
description: 'Only log actions, do not perform any delete operations.'
41+
required: false
42+
43+
jobs:
44+
del_runs:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Delete workflow runs
48+
uses: Mattraks/delete-workflow-runs@v2
49+
with:
50+
token: ${{ github.token }}
51+
repository: ${{ github.repository }}
52+
retain_days: ${{ github.event.inputs.days }}
53+
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
54+
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
55+
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }}
56+
delete_run_by_conclusion_pattern: ${{ github.event.inputs.delete_run_by_conclusion_pattern }}
57+
dry_run: ${{ github.event.inputs.dry_run }}

BuildTools/Vendor/Composer/autoload_classmap.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

BuildTools/Vendor/Composer/autoload_psr4.php

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace DiscordCoreAPI\Packager;
3+
namespace discordcoreapi\Packager;
44

55
use \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
142141
vcpkg_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
148148
vcpkg_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;

BuildTools/composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "RealTimeChris/discordcoreapi",
3+
"description": "Jsoniifer Build Tools",
4+
"type": "project",
5+
"license": "Apache 2.0",
6+
"autoload": {
7+
"psr-4": {
8+
"DiscordCoreAPI\\": "classes/"
9+
}
10+
},
11+
"authors": [
12+
{
13+
"name": "chris"
14+
}
15+
],
16+
"require": {}
17+
}

BuildTools/make_vcpkg.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22

33
/**
4-
* Copied from Dpp: https://github.com/brainboxdotcc/dpp
5-
* CI process for generating new vcpkg releases.
4+
* Automatic CI process for generating new vcpkg releases.
65
* Based loosely on RealTimeChris's shell script version.
76
*
87
* This updates the content of ./vcpkg directory within the DPP
@@ -28,7 +27,7 @@
2827
* the script, failing the CI action.
2928
*/
3029

31-
require __DIR__ . '/Vendor/autoload.php';
30+
require __DIR__ . '/vendor/autoload.php';
3231
use DiscordCoreAPI\Packager\Vcpkg;
3332

3433
$vcpkg = new Vcpkg();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// autoload.php @generated by Composer
44

55
if (PHP_VERSION_ID < 50600) {
6-
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "Composer self-update --2.2". Aborting.'.PHP_EOL;
6+
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
77
exit(1);
88
}
99

10-
require_once __DIR__ . '/Composer/autoload_real.php';
10+
require_once __DIR__ . '/composer/autoload_real.php';
1111

1212
return ComposerAutoloaderInit0e8415491642f27914717986db49b1db::getLoader();

0 commit comments

Comments
 (0)