Skip to content

Commit 3c0883d

Browse files
authored
Merge pull request #236 from Krypton-Suite/gold
Gold
2 parents afd3f3f + f8b27db commit 3c0883d

8,665 files changed

Lines changed: 1089339 additions & 57687 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
# New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE)
2+
# Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, tobitege et al. 2026 - 2026. All rights reserved.
3+
#
4+
# Syncs alpha to alpha-backup when alpha has commits in the last 24 hours by creating
5+
# a PR from alpha into alpha-backup. Creates alpha-backup branch if it does not exist.
6+
# Enable auto-merge on the repo for these PRs to make the backup fully automated.
7+
#
8+
# KILL-SWITCH: To disable this workflow, set repository variable ALPHA_BACKUP_SYNC_DISABLED=true
9+
# Location: Repository Settings → Secrets and variables → Actions → Variables tab
10+
# To re-enable: Set ALPHA_BACKUP_SYNC_DISABLED=false or delete the variable
11+
#
12+
# Discord: Set secret DISCORD_WEBHOOK_ALPHA_BACKUP to send notifications (optional).
13+
#
14+
# Separate repo backup: Set variable BACKUP_REPO (e.g. Krypton-Suite/Standard-Toolkit-Backup) and
15+
# secret BACKUP_REPO_TOKEN (PAT with push access). Backups go into dated dirs: "Standard Toolkit Backup - YYYY-MM-DD".
16+
# Optional: BACKUP_DIR_PREFIX (default "Standard Toolkit Backup"), BACKUP_BRANCH (default "main").
17+
18+
name: Alpha to Alpha-Backup Sync
19+
20+
on:
21+
schedule:
22+
# Run at midnight UTC daily
23+
- cron: '0 0 * * *'
24+
workflow_dispatch:
25+
26+
permissions:
27+
contents: write
28+
pull-requests: write
29+
30+
jobs:
31+
sync:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Alpha Backup Sync Kill Switch Check
35+
id: kill_switch
36+
run: |
37+
disabled="${{ vars.ALPHA_BACKUP_SYNC_DISABLED }}"
38+
if [ "$disabled" = "true" ]; then
39+
echo "::warning:: Alpha Backup Sync workflow is currently DISABLED via kill switch (ALPHA_BACKUP_SYNC_DISABLED=true)"
40+
echo "To re-enable: Go to Repository Settings -> Secrets and Variables -> Actions -> Variables -> Set ALPHA_BACKUP_SYNC_DISABLED to 'false'."
41+
echo "enabled=false" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "Alpha Backup Sync kill switch check has passed, continuing..."
44+
echo "enabled=true" >> "$GITHUB_OUTPUT"
45+
fi
46+
47+
- name: Checkout
48+
if: steps.kill_switch.outputs.enabled == 'true'
49+
uses: actions/checkout@v6
50+
with:
51+
ref: alpha
52+
fetch-depth: 0
53+
54+
- name: Check for changes on alpha in last 24 hours
55+
if: steps.kill_switch.outputs.enabled == 'true'
56+
id: check_changes
57+
run: |
58+
yesterday=$(date -u -d '24 hours ago' '+%Y-%m-%d %H:%M:%S')
59+
commit_count=$(git rev-list --count --since="$yesterday" alpha 2>/dev/null || echo "0")
60+
echo "Commits on alpha in last 24 hours: $commit_count"
61+
if [ "${commit_count:-0}" -gt 0 ]; then
62+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
63+
else
64+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
65+
fi
66+
67+
- name: Ensure alpha-backup exists
68+
if: steps.kill_switch.outputs.enabled == 'true' && steps.check_changes.outputs.has_changes == 'true'
69+
uses: actions/github-script@v8
70+
id: ensure_backup
71+
with:
72+
github-token: ${{ secrets.GITHUB_TOKEN }}
73+
script: |
74+
const { owner, repo } = context.repo;
75+
try {
76+
await github.rest.repos.getBranch({ owner, repo, branch: 'alpha-backup' });
77+
console.log('Branch alpha-backup already exists.');
78+
return 'exists';
79+
} catch (err) {
80+
if (err.status !== 404) throw err;
81+
}
82+
const { data: ref } = await github.rest.git.getRef({ owner, repo, ref: 'heads/alpha' });
83+
await github.rest.git.createRef({
84+
owner,
85+
repo,
86+
ref: 'refs/heads/alpha-backup',
87+
sha: ref.object.sha
88+
});
89+
console.log('Created branch alpha-backup from alpha.');
90+
return 'created';
91+
92+
- name: Create PR from alpha to alpha-backup
93+
if: steps.kill_switch.outputs.enabled == 'true' && steps.check_changes.outputs.has_changes == 'true'
94+
id: create_pr
95+
uses: actions/github-script@v8
96+
with:
97+
github-token: ${{ secrets.GITHUB_TOKEN }}
98+
script: |
99+
const { owner, repo } = context.repo;
100+
let result = { pr_created: false, pr_number: '', pr_url: '', pr_node_id: '' };
101+
const { data: compare } = await github.rest.repos.compareCommitsWithBasehead({
102+
owner,
103+
repo,
104+
basehead: 'alpha-backup...alpha'
105+
});
106+
if (compare.ahead_by === 0) {
107+
console.log('alpha-backup is already up to date with alpha; no PR needed.');
108+
return result;
109+
}
110+
const { data: prs } = await github.rest.pulls.list({
111+
owner,
112+
repo,
113+
state: 'open',
114+
head: `${owner}:alpha`,
115+
base: 'alpha-backup'
116+
});
117+
if (prs.length > 0) {
118+
console.log('Open PR from alpha to alpha-backup already exists: #' + prs[0].number);
119+
result.pr_number = prs[0].number;
120+
result.pr_url = prs[0].html_url;
121+
result.pr_node_id = prs[0].node_id;
122+
return result;
123+
}
124+
const { data: pr } = await github.rest.pulls.create({
125+
owner,
126+
repo,
127+
title: 'chore: sync alpha → alpha-backup (automated)',
128+
head: 'alpha',
129+
base: 'alpha-backup',
130+
body: 'Automated PR: alpha has had commits in the last 24 hours. Merge to update alpha-backup.\n\n*Triggered by Alpha to Alpha-Backup Sync workflow.*'
131+
});
132+
console.log('Created PR #' + pr.number + ' from alpha to alpha-backup.');
133+
result.pr_created = true;
134+
result.pr_number = pr.number;
135+
result.pr_url = pr.html_url;
136+
result.pr_node_id = pr.node_id;
137+
return result;
138+
139+
- name: Enable auto-merge on PR
140+
if: steps.kill_switch.outputs.enabled == 'true' && steps.check_changes.outputs.has_changes == 'true'
141+
uses: actions/github-script@v8
142+
env:
143+
PR_NODE_ID: ${{ fromJson(steps.create_pr.outputs.result).pr_node_id }}
144+
with:
145+
github-token: ${{ secrets.GITHUB_TOKEN }}
146+
script: |
147+
const nodeId = process.env.PR_NODE_ID;
148+
if (!nodeId) {
149+
console.log('No PR to enable auto-merge on.');
150+
return;
151+
}
152+
try {
153+
await github.graphql(`
154+
mutation($pullRequestId: ID!, $mergeMethod: PullRequestMergeMethod) {
155+
enablePullRequestAutoMerge(input: { pullRequestId: $pullRequestId, mergeMethod: $mergeMethod }) {
156+
pullRequest { autoMergeRequest { enabledAt } }
157+
}
158+
}
159+
`, { pullRequestId: nodeId, mergeMethod: 'MERGE' });
160+
console.log('Auto-merge enabled on PR.');
161+
} catch (err) {
162+
console.warn('Could not enable auto-merge (repo may not have Allow auto-merge enabled):', err.message);
163+
}
164+
165+
- name: Push alpha to backup repository (dated directory)
166+
if: steps.kill_switch.outputs.enabled == 'true' && steps.check_changes.outputs.has_changes == 'true'
167+
id: backup_repo
168+
env:
169+
BACKUP_REPO: ${{ vars.BACKUP_REPO }}
170+
BACKUP_REPO_TOKEN: ${{ secrets.BACKUP_REPO_TOKEN }}
171+
BACKUP_DIR_PREFIX: ${{ vars.BACKUP_DIR_PREFIX }}
172+
BACKUP_BRANCH: ${{ vars.BACKUP_BRANCH }}
173+
run: |
174+
if [ -z "$BACKUP_REPO_TOKEN" ] || [ -z "$BACKUP_REPO" ]; then
175+
echo "BACKUP_REPO (variable) or BACKUP_REPO_TOKEN (secret) not set - skipping backup repo push"
176+
echo "pushed=false" >> "$GITHUB_OUTPUT"
177+
exit 0
178+
fi
179+
prefix="${BACKUP_DIR_PREFIX:-Standard Toolkit Backup}"
180+
branch="${BACKUP_BRANCH:-main}"
181+
today=$(date -u +%Y-%m-%d)
182+
dir_name="$prefix - $today"
183+
echo "dir_name=$dir_name" >> "$GITHUB_OUTPUT"
184+
git config user.name "github-actions[bot]"
185+
git config user.email "github-actions[bot]@users.noreply.github.com"
186+
git clone --depth 1 "https://x-access-token:$BACKUP_REPO_TOKEN@github.com/$BACKUP_REPO.git" backup-repo
187+
cd backup-repo
188+
git checkout -b "$branch" 2>/dev/null || git checkout "$branch" 2>/dev/null || true
189+
mkdir -p "$dir_name"
190+
rsync -a --exclude='.git' ../. "$dir_name/"
191+
git add "$dir_name"
192+
git commit -m "chore: backup alpha to $dir_name (automated)"
193+
git push origin "$branch"
194+
echo "pushed=true" >> "$GITHUB_OUTPUT"
195+
echo "Pushed alpha to $BACKUP_REPO ($dir_name)"
196+
197+
- name: Discord notification
198+
if: steps.kill_switch.outputs.enabled == 'true' && steps.check_changes.outputs.has_changes == 'true'
199+
env:
200+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_ALPHA_BACKUP }}
201+
BRANCH_CREATED: ${{ steps.ensure_backup.outputs.result == 'created' }}
202+
PR_RESULT: ${{ steps.create_pr.outputs.result }}
203+
BACKUP_PUSHED: ${{ steps.backup_repo.outputs.pushed }}
204+
BACKUP_REPO: ${{ vars.BACKUP_REPO }}
205+
BACKUP_DIR: ${{ steps.backup_repo.outputs.dir_name }}
206+
run: |
207+
if [ -z "$DISCORD_WEBHOOK" ]; then
208+
echo "DISCORD_WEBHOOK_ALPHA_BACKUP not set - skipping Discord notification"
209+
exit 0
210+
fi
211+
pr_link=""
212+
if [ -n "$PR_RESULT" ]; then
213+
pr_url=$(echo "$PR_RESULT" | jq -r '.pr_url // empty')
214+
pr_number=$(echo "$PR_RESULT" | jq -r '.pr_number // empty')
215+
if [ -n "$pr_url" ]; then
216+
pr_link="\n• [PR #$pr_number]($pr_url)"
217+
fi
218+
fi
219+
backup_line=""
220+
if [ "$BACKUP_PUSHED" = "true" ] && [ -n "$BACKUP_REPO" ]; then
221+
backup_line="\n• Pushed to backup repo: $BACKUP_REPO"
222+
if [ -n "$BACKUP_DIR" ]; then
223+
backup_line="$backup_line ($BACKUP_DIR)"
224+
fi
225+
fi
226+
branch_msg="alpha-backup branch already existed"
227+
if [ "$BRANCH_CREATED" = "true" ]; then
228+
branch_msg="alpha-backup branch was created (did not exist)"
229+
fi
230+
payload=$(jq -n \
231+
--arg branch "$branch_msg" \
232+
--arg pr_link "$pr_link" \
233+
--arg backup_line "$backup_line" \
234+
--arg run_url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
235+
'{
236+
embeds: [{
237+
title: "📦 Alpha → Alpha-Backup Sync",
238+
description: ("Alpha had commits in the last 24 hours. Sync workflow ran.\n\n• " + $branch + $pr_link + $backup_line + "\n• [Workflow run](" + $run_url + ")"),
239+
color: 3447003,
240+
timestamp: (now | todate),
241+
footer: { text: "Alpha Backup Sync" }
242+
}]
243+
}')
244+
curl -sS -X POST "$DISCORD_WEBHOOK" -H "Content-Type: application/json" -d "$payload"

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
${{ runner.os }}-nuget-
6767
6868
- name: Restore
69-
run: dotnet restore "Source/Krypton Components/Krypton Toolkit Suite.slnx"
69+
run: dotnet restore "Source/Current/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.slnx"
7070

7171
- name: Build
7272
run: msbuild "Scripts/Build/nightly.proj" /t:Rebuild /p:Configuration=Release /p:Platform="Any CPU"
@@ -144,19 +144,19 @@ jobs:
144144
}
145145
if (-not $latestVersion) { $latestVersion = "1.0.3595.46" }
146146
Write-Host "Using WebView2 SDK version: $latestVersion"
147-
dotnet add "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package Microsoft.Web.WebView2 --version $latestVersion
148-
dotnet restore "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj"
147+
dotnet add "Source/Current/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package Microsoft.Web.WebView2 --version $latestVersion
148+
dotnet restore "Source/Current/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj"
149149
$nugetBasePath = "$env:USERPROFILE\.nuget\packages\microsoft.web.webview2\$latestVersion"
150150
$coreDll = Get-ChildItem -Path $nugetBasePath -Recurse -Name "Microsoft.Web.WebView2.Core.dll" | Select-Object -First 1
151151
Copy-Item (Join-Path $nugetBasePath $coreDll) "WebView2SDK\"
152152
$winFormsDll = Get-ChildItem -Path $nugetBasePath -Recurse -Name "Microsoft.Web.WebView2.WinForms.dll" | Select-Object -First 1
153153
Copy-Item (Join-Path $nugetBasePath $winFormsDll) "WebView2SDK\"
154154
$loaderDll = Get-ChildItem -Path $nugetBasePath -Recurse -Name "WebView2Loader.dll" | Select-Object -First 1
155155
Copy-Item (Join-Path $nugetBasePath $loaderDll) "WebView2SDK\"
156-
dotnet remove "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package Microsoft.Web.WebView2
156+
dotnet remove "Source/Current/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package Microsoft.Web.WebView2
157157
158158
- name: Restore
159-
run: dotnet restore "Source/Krypton Components/Krypton Toolkit Suite.slnx"
159+
run: dotnet restore "Source/Current/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.slnx"
160160

161161
- name: Build Release
162162
run: msbuild "Scripts/Build/build.proj" /t:Build /p:Configuration=Release /p:Platform="Any CPU"
@@ -167,7 +167,7 @@ jobs:
167167
- name: Get Version
168168
id: get_version
169169
run: |
170-
$version = (dotnet build "Source/Krypton Components/Krypton.Toolkit/Krypton.Toolkit.csproj" --no-restore --verbosity quiet | Select-String "Version" | ForEach-Object { $_.Line.Split('=')[1].Trim() })
170+
$version = (dotnet build "Source/Current/Krypton Components/Krypton.Toolkit/Krypton.Toolkit.csproj" --no-restore --verbosity quiet | Select-String "Version" | ForEach-Object { $_.Line.Split('=')[1].Trim() })
171171
if (-not $version) {
172172
$version = "100.25.1.1" # Fallback version
173173
}

.github/workflows/nightly.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,20 @@ jobs:
188188
}
189189
if (-not $latestVersion) { $latestVersion = "1.0.3595.46" }
190190
Write-Host "Using WebView2 SDK version: $latestVersion"
191-
dotnet add "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package Microsoft.Web.WebView2 --version $latestVersion
192-
dotnet restore "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj"
191+
dotnet add "Source/Current/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package Microsoft.Web.WebView2 --version $latestVersion
192+
dotnet restore "Source/Current/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj"
193193
$nugetBasePath = "$env:USERPROFILE\.nuget\packages\microsoft.web.webview2\$latestVersion"
194194
$coreDll = Get-ChildItem -Path $nugetBasePath -Recurse -Name "Microsoft.Web.WebView2.Core.dll" | Select-Object -First 1
195195
Copy-Item (Join-Path $nugetBasePath $coreDll) "WebView2SDK\"
196196
$winFormsDll = Get-ChildItem -Path $nugetBasePath -Recurse -Name "Microsoft.Web.WebView2.WinForms.dll" | Select-Object -First 1
197197
Copy-Item (Join-Path $nugetBasePath $winFormsDll) "WebView2SDK\"
198198
$loaderDll = Get-ChildItem -Path $nugetBasePath -Recurse -Name "WebView2Loader.dll" | Select-Object -First 1
199199
Copy-Item (Join-Path $nugetBasePath $loaderDll) "WebView2SDK\"
200-
dotnet remove "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package Microsoft.Web.WebView2
200+
dotnet remove "Source/Current/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package Microsoft.Web.WebView2
201201
202202
- name: Restore
203203
if: steps.nightly_release_kill_switch.outputs.enabled == 'true' && steps.check_changes.outputs.has_changes == 'true'
204-
run: dotnet restore "Source/Krypton Components/Krypton Toolkit Suite.slnx"
204+
run: dotnet restore "Source/Current/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.slnx"
205205

206206
- name: Prepare Code Signing Certificate (Optional)
207207
if: steps.nightly_release_kill_switch.outputs.enabled == 'true' && steps.check_changes.outputs.has_changes == 'true'
@@ -311,7 +311,7 @@ jobs:
311311
# Fallback: Try to read from csproj XML
312312
if (-not $version) {
313313
try {
314-
$proj = 'Source/Krypton Components/Krypton.Toolkit/Krypton.Toolkit.csproj'
314+
$proj = 'Source/Current/Krypton Components/Krypton.Toolkit/Krypton.Toolkit.csproj'
315315
[xml]$projXml = Get-Content $proj
316316
$versionNode = $projXml.SelectSingleNode("//Version")
317317
if ($versionNode) {

0 commit comments

Comments
 (0)