Skip to content

Commit c5e5ca9

Browse files
Add UBR (patch level) as fourth component to OS version string, and added github action build for pr (#16)
* Add UBR (patch level) as fourth component to OS version string Reads UBR from the registry alongside productName and includes it in the version output as major.minor.build.ubr. Defaults to 0 on older Windows versions that do not have the UBR registry value. * Update ChangeLog * Potential fix for code scanning alert no. 2: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent f25eed5 commit c5e5ca9

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

.github/workflows/pr-build.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: PR Build and Artifact
2+
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
7+
on:
8+
pull_request:
9+
# Triggers on all PR events (opened, synchronize, reopened, etc.)
10+
11+
jobs:
12+
build:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Cygwin
20+
uses: cygwin/cygwin-install-action@master
21+
with:
22+
packages: make zip gcc-core gcc-g++ binutils
23+
24+
- name: Setup MinGW-w64
25+
uses: msys2/setup-msys2@v2
26+
with:
27+
msystem: MINGW64
28+
update: true
29+
install: >-
30+
mingw-w64-x86_64-gcc
31+
mingw-w64-x86_64-make
32+
mingw-w64-i686-gcc
33+
mingw-w64-i686-make
34+
make
35+
36+
- name: Debug workspace contents (Windows)
37+
shell: cmd
38+
run: |
39+
echo Current working directory:
40+
cd
41+
echo Workspace directory: ${{ github.workspace }}
42+
echo Contents of workspace:
43+
dir "${{ github.workspace }}"
44+
echo Looking for Makefile:
45+
dir "${{ github.workspace }}\Makefile"
46+
47+
- name: Build MrBig
48+
shell: msys2 {0}
49+
run: |
50+
export PATH="/mingw64/bin:/mingw32/bin:/usr/bin:$PATH"
51+
echo "Checking available compilers:"
52+
which gcc || echo "gcc not found"
53+
which x86_64-w64-mingw32-gcc || echo "x86_64-w64-mingw32-gcc not found"
54+
which i686-w64-mingw32-gcc || echo "i686-w64-mingw32-gcc not found"
55+
echo "Running make..."
56+
make
57+
58+
- name: Upload build artifacts
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: mrbig-binaries
62+
path: |
63+
X64/mrbig64.exe
64+
X86/mrbig.exe
65+
if-no-files-found: warn
66+
67+
- name: Comment artifact link on PR
68+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
69+
uses: actions/github-script@v7
70+
with:
71+
script: |
72+
const pr = context.payload.pull_request;
73+
if (pr) {
74+
const runId = process.env.GITHUB_RUN_ID;
75+
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
76+
github.rest.issues.createComment({
77+
issue_number: pr.number,
78+
owner: context.repo.owner,
79+
repo: context.repo.repo,
80+
body: `🔗 Download the build artifacts from this PR run: [Artifacts & Logs](${artifactUrl})`
81+
});
82+
}

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
260225 Add ubr (Update Build Revision) for clientlog as fourth value.
2+
13
251517 Added Clientlog module, which writes a big log of rows,
24
containg information about the Windows machine. Most info
35
modules are recreations of Linux command line utilities.

clientlog/osversion.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ void clog_osversion(clog_Arena scratch) {
6565
CHAR productName[64];
6666
DWORD typeProduct;
6767
DWORD lenProduct = 64;
68+
DWORD ubr = 0;
6869
if (productStatus == ERROR_SUCCESS) {
6970
productStatus = RegGetValue(hKey, NULL, "productName", RRF_RT_REG_SZ, &typeProduct, productName, &lenProduct);
71+
DWORD typeUbr;
72+
DWORD lenUbr = sizeof(DWORD);
73+
RegGetValue(hKey, NULL, "UBR", RRF_RT_REG_DWORD, &typeUbr, &ubr, &lenUbr);
7074
}
7175
RegCloseKey(hKey);
7276

@@ -137,7 +141,7 @@ void clog_osversion(clog_Arena scratch) {
137141
}
138142

139143
CHAR osVersion[64];
140-
snprintf(osVersion, 64, "version %lu.%lu.%lu (%s)", osVersionInfo.dwMajorVersion, osVersionInfo.dwMinorVersion, osVersionInfo.dwBuildNumber, win.version);
144+
snprintf(osVersion, 64, "version %lu.%lu.%lu.%lu (%s)", osVersionInfo.dwMajorVersion, osVersionInfo.dwMinorVersion, osVersionInfo.dwBuildNumber, ubr, win.version);
141145

142146
clog_ArenaAppend(&scratch, "\n%s, %s", osName, osVersion);
143147

0 commit comments

Comments
 (0)