Skip to content

Commit

Permalink
Per 3435 | Update Win exe metadata and icon (#1618)
Browse files Browse the repository at this point in the history
* update Binary Metadata

* Update code to use resedit npm package

* Update metadata values
  • Loading branch information
pankaj443 authored Jun 17, 2024
1 parent 55b9723 commit 05c0113
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/executable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Build Executables
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 14
Expand Down Expand Up @@ -39,10 +39,19 @@ jobs:
name: Sign Win Executable
runs-on: windows-latest
steps:
- name: Download a single artifact
- uses: actions/checkout@v3
- name: Download win artifact
uses: actions/download-artifact@v4
with:
name: win-exe
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install resedit
run: npm install resedit
- name: Update exe metadata
run: node ./scripts/win-metadata-update.js
- name: Sign binary
uses: lando/code-sign-action@v2
with:
Expand Down
Binary file added scripts/files/percy.ico
Binary file not shown.
36 changes: 36 additions & 0 deletions scripts/win-metadata-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fs from 'fs';
import * as ResEdit from 'resedit';

function windowsPostBuild(output) {
const exe = ResEdit.NtExecutable.from(fs.readFileSync(output));
const res = ResEdit.NtExecutableResource.from(exe);
const iconFile = ResEdit.Data.IconFile.from(fs.readFileSync('./scripts/files/percy.ico'));

ResEdit.Resource.IconGroupEntry.replaceIconsForResource(
res.entries,
1,
1033,
iconFile.icons.map(item => item.data)
);

const vi = ResEdit.Resource.VersionInfo.fromEntries(res.entries)[0];

vi.setStringValues(
{ lang: 1033, codepage: 1200 },
{
ProductName: 'PercyCLI',
FileDescription: 'Percy CLI Binary',
CompanyName: 'BrowserStack Inc.',
LegalCopyright: 'Copyright BrowserStack Limited',
OriginalFilename: 'PercyCLI',
InternalName: 'PercyCLI'
}
);
vi.setFileVersion(1, 28, 8);
vi.setProductVersion(1, 28, 8);
vi.outputToResourceEntries(res.entries);
res.outputResource(exe);
fs.writeFileSync(output, Buffer.from(exe.generate()));
}

windowsPostBuild('percy.exe');

0 comments on commit 05c0113

Please sign in to comment.