Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sign windows exe #65

Merged
merged 3 commits into from
Sep 26, 2024
Merged

fix: sign windows exe #65

merged 3 commits into from
Sep 26, 2024

Conversation

cazala
Copy link
Member

@cazala cazala commented Sep 25, 2024

This PR fixes the issue we currently have where the Windows .exe file is being signed after the artifacts are published, so they are not being part of the GitHub release and auto-updater.

The issue with electron-builder is that it cannot generate the artifacts and publish them later, the process cannot be 'paused' in the middle, so we can't run the eSigner GitHub Action to sign it in between.

The electron-builder configuration provides an escape hatch to sign the executables in a custom way before publishing them, so what I did is the following:

  1. Changed the electron-builder.yml into an electron-builder.cjs file so we can define the custom win.sign function.
  2. Checked out the SSLcom/esigner-codesign repo in an earlier step into the root.
  3. Within the win.sign function I execute a sync child process that runs the GitHub Action's script using node.
  4. Removed the step that signs the windows .exe afterwards.

The eSigner GitHub Action is not intended to be used programatically, so I had to do some ugly wiring for it to pick up the configuration (pass some values into the process.env) but it works, and it takes care of downloading Java, the CodeSignTool, and perform the signing just fine.

I followed this approach from the comment on this issue: electron-userland/electron-builder#6158 (comment)

# Due to this issue https://github.com/electron-userland/electron-builder/issues/6411 the build with npx when rebuilding native dependencies hangs forever
# see https://github.com/cawa-93/vite-electron-builder/pull/953
command: ./node_modules/.bin/electron-builder --config electron-builder.yml -c.extraMetadata.version=${{ github.event.inputs.version }} -c.mac.notarize.teamId=${{ env.APPLE_TEAM_ID }} --publish always
command: npx electron-builder --config electron-builder.cjs -c.extraMetadata.version=${{ github.event.inputs.version }} -c.mac.notarize.teamId=${{ env.APPLE_TEAM_ID }} --publish always
Copy link
Member Author

@cazala cazala Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue that electron-builder had with npx has been fixed in npm v10.1.0

Reference: electron-userland/electron-builder#6411 (comment)

@cazala cazala merged commit f9491fa into main Sep 26, 2024
9 checks passed
@cazala cazala deleted the fix/sign-windows-exe branch September 26, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants