chore(workflow): fix desktop sums
This commit is contained in:
1
.github/workflows/desktop.release.reuse.yml
vendored
1
.github/workflows/desktop.release.reuse.yml
vendored
@@ -150,6 +150,7 @@ jobs:
|
|||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: assets
|
name: assets
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
echo 'Compiling components from' $(pwd)
|
echo 'Compiling components from' $(pwd)
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,9 @@ import { fileURLToPath } from 'url'
|
|||||||
const __filename = fileURLToPath(import.meta.url)
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
const ScriptsDir = path.dirname(__filename)
|
const ScriptsDir = path.dirname(__filename)
|
||||||
|
|
||||||
import { doesFileExist } from '../../../scripts/ScriptUtils.mjs'
|
import { doesFileExist, listDirFiles } from '../../../scripts/ScriptUtils.mjs'
|
||||||
|
|
||||||
function sha256(filePath) {
|
function sha256(filePath) {
|
||||||
if (!doesFileExist(filePath)) {
|
|
||||||
console.log('Attempting to hash non-existing file', filePath)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
try {
|
try {
|
||||||
fs.createReadStream(filePath)
|
fs.createReadStream(filePath)
|
||||||
@@ -31,43 +26,6 @@ function sha256(filePath) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFileNames() {
|
|
||||||
const packageJson = await fs.promises.readFile(path.join(ScriptsDir, '../package.json'))
|
|
||||||
const version = JSON.parse(packageJson).version
|
|
||||||
return [
|
|
||||||
`standard-notes-${version}-mac-x64.zip`,
|
|
||||||
`standard-notes-${version}-mac-x64.dmg`,
|
|
||||||
`standard-notes-${version}-mac-x64.dmg.blockmap`,
|
|
||||||
|
|
||||||
`standard-notes-${version}-mac-arm64.zip`,
|
|
||||||
`standard-notes-${version}-mac-arm64.dmg`,
|
|
||||||
`standard-notes-${version}-mac-arm64.dmg.blockmap`,
|
|
||||||
|
|
||||||
`standard-notes-${version}-linux-i386.AppImage`,
|
|
||||||
`standard-notes-${version}-linux-x86_64.AppImage`,
|
|
||||||
`standard-notes-${version}-linux-amd64.snap`,
|
|
||||||
|
|
||||||
`standard-notes-${version}-linux-arm64.deb`,
|
|
||||||
`standard-notes-${version}-linux-arm64.AppImage`,
|
|
||||||
|
|
||||||
`standard-notes-${version}-win-x64.exe`,
|
|
||||||
`standard-notes-${version}-win-x64.exe.blockmap`,
|
|
||||||
|
|
||||||
`standard-notes-${version}-win.exe`,
|
|
||||||
`standard-notes-${version}-win.exe.blockmap`,
|
|
||||||
|
|
||||||
`standard-notes-${version}-win-ia32.exe`,
|
|
||||||
`standard-notes-${version}-win-ia32.exe.blockmap`,
|
|
||||||
|
|
||||||
'latest-linux-ia32.yml',
|
|
||||||
'latest-linux.yml',
|
|
||||||
'latest-linux-arm64.yml',
|
|
||||||
'latest-mac.yml',
|
|
||||||
'latest.yml',
|
|
||||||
'builder-effective-config.yaml',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
process.on('uncaughtException', function (err) {
|
process.on('uncaughtException', function (err) {
|
||||||
console.log('Caught exception: ' + err)
|
console.log('Caught exception: ' + err)
|
||||||
})
|
})
|
||||||
@@ -75,26 +33,37 @@ process.on('uncaughtException', function (err) {
|
|||||||
console.log('Writing SHA256 sums to dist/SHA256SUMS')
|
console.log('Writing SHA256 sums to dist/SHA256SUMS')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const files = await getFileNames()
|
const distDir = path.join(ScriptsDir, '../dist')
|
||||||
|
const fileNames = listDirFiles(distDir)
|
||||||
|
const filePaths = fileNames.map((fileName) => path.join(distDir, fileName))
|
||||||
|
|
||||||
let hashes = await Promise.all(
|
const entries = []
|
||||||
files.map(async (fileName) => {
|
|
||||||
const filePath = path.join(ScriptsDir, `../dist/${fileName}`)
|
|
||||||
try {
|
|
||||||
const hash = await sha256(filePath)
|
|
||||||
const entry = `${hash} ${fileName}`
|
|
||||||
return entry
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Unable to hash file', filePath)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
||||||
hashes = hashes.join('\n')
|
for (const filePath of filePaths) {
|
||||||
|
if (!doesFileExist(filePath)) {
|
||||||
|
console.log('Attempting to hash non-existing file', filePath)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (fs.lstatSync(filePath).isDirectory()) {
|
||||||
|
console.log('Attempting to hash directory', filePath)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const hash = await sha256(filePath)
|
||||||
|
const fileName = path.basename(filePath)
|
||||||
|
const entry = `${hash} ${fileName}`
|
||||||
|
entries.push(entry)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Unable to hash file', filePath)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const hashes = entries.join('\n')
|
||||||
await fs.promises.writeFile(path.join(ScriptsDir, '../dist/SHA256SUMS'), hashes)
|
await fs.promises.writeFile(path.join(ScriptsDir, '../dist/SHA256SUMS'), hashes)
|
||||||
console.log(`Successfully wrote SHA256SUMS:\n${hashes}`)
|
console.log(`Successfully wrote SHA256SUMS:\n${hashes}`)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error('Error generating checksums', err)
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -19,3 +19,7 @@ export const emptyExistingDir = (dir) => {
|
|||||||
fs.rmSync(dir, { recursive: true })
|
fs.rmSync(dir, { recursive: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const listDirFiles = (dir) => {
|
||||||
|
return fs.readdirSync(dir)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user