Skip to content

Commit

Permalink
🤖 Chocolatey script checks hash
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa committed Jan 8, 2024
1 parent c2bbdbc commit 7a762ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build-config/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
$packageName = 'electronim'
$file = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)\electronim-win-x64.zip"
$hash: 1337
$unzipLocation = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)\electronim"


Install-ChocolateyZipPackage `
-PackageName $packageName `
-File $file `
-UnzipLocation $unzipLocation `
-Checksum $hash: AB32A2282C65DBEE325FAE31770CD848B3A3A84FE2798D306FC2EAE2BA0D93B5
-ChecksumType 'SHA256' `

Install-BinFile -Name $packageName -Path 'electronim.exe'
13 changes: 13 additions & 0 deletions utils/prepare-electron-builder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
/* eslint-disable no-console */
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const errorHandler = require('./error-handler');
Expand All @@ -18,9 +19,21 @@ const licenseForChocolatey = () => {
fs.copyFileSync(packageLicense, packageLicenseTxt);
};

const calculateHashForChocolatey = () => {
const fileBuffer = fs.readFileSync(path.join(__dirname, '..', 'dist', 'electronim-win-x64.zip'));
const hashSum = crypto.createHash('sha256');
hashSum.update(fileBuffer);
const hash = hashSum.digest('hex').toUpperCase();
const chocolateyInstall = path.resolve(__dirname, '..', 'build-config', 'chocolateyInstall.ps1');
fs.writeFileSync(chocolateyInstall, fs.readFileSync(chocolateyInstall).toString()
.replace(/\$hash.+$/gm, `$hash: ${hash}`)
);
}

Check failure on line 31 in utils/prepare-electron-builder.js

View workflow job for this annotation

GitHub Actions / Tests

Missing semicolon

const prepareElectronBuilder = () => {
electronToDevDependencies();
licenseForChocolatey();
calculateHashForChocolatey();
};

process.on('unhandledRejection', errorHandler);
Expand Down

0 comments on commit 7a762ce

Please sign in to comment.