Skip to content

Commit

Permalink
Automate checksum generation for standalone CLI (#14081)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace authored Aug 1, 2024
1 parent 9824cb6 commit 28bd90e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ jobs:
standalone-cli/dist/tailwindcss-macos-x64
standalone-cli/dist/tailwindcss-windows-x64.exe
standalone-cli/dist/tailwindcss-windows-arm64.exe
standalone-cli/dist/sha256sums.txt
3 changes: 2 additions & 1 deletion standalone-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"scripts": {
"build": "pkg . --compress Brotli --no-bytecode --public-packages \"*\" --public",
"prebuild": "rimraf dist",
"postbuild": "move-file dist/tailwindcss-standalone-macos-x64 dist/tailwindcss-macos-x64 && move-file dist/tailwindcss-standalone-macos-arm64 dist/tailwindcss-macos-arm64 && move-file dist/tailwindcss-standalone-win-x64.exe dist/tailwindcss-windows-x64.exe && move-file dist/tailwindcss-standalone-win-arm64.exe dist/tailwindcss-windows-arm64.exe && move-file dist/tailwindcss-standalone-linuxstatic-x64 dist/tailwindcss-linux-x64 && move-file dist/tailwindcss-standalone-linuxstatic-arm64 dist/tailwindcss-linux-arm64 && move-file dist/tailwindcss-standalone-linuxstatic-armv7 dist/tailwindcss-linux-armv7",
"postbuild": "move-file dist/tailwindcss-standalone-macos-x64 dist/tailwindcss-macos-x64 && move-file dist/tailwindcss-standalone-macos-arm64 dist/tailwindcss-macos-arm64 && move-file dist/tailwindcss-standalone-win-x64.exe dist/tailwindcss-windows-x64.exe && move-file dist/tailwindcss-standalone-win-arm64.exe dist/tailwindcss-windows-arm64.exe && move-file dist/tailwindcss-standalone-linuxstatic-x64 dist/tailwindcss-linux-x64 && move-file dist/tailwindcss-standalone-linuxstatic-arm64 dist/tailwindcss-linux-arm64 && move-file dist/tailwindcss-standalone-linuxstatic-armv7 dist/tailwindcss-linux-armv7 && npm run generate-checksums",
"generate-checksums": "node ./scripts/checksum.mjs",
"test": "jest"
},
"devDependencies": {
Expand Down
27 changes: 27 additions & 0 deletions standalone-cli/scripts/checksum.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createHash } from 'node:crypto'
import { readFile, writeFile } from 'node:fs/promises'
import * as path from 'node:path'

const files = [
'./tailwindcss-linux-arm64',
'./tailwindcss-linux-armv7',
'./tailwindcss-linux-x64',
'./tailwindcss-macos-arm64',
'./tailwindcss-macos-x64',
'./tailwindcss-windows-arm64.exe',
'./tailwindcss-windows-x64.exe',
]

const __dirname = path.dirname(new URL(import.meta.url).pathname)

const lines = await Promise.all(
files.map(async (file) => {
let sum = createHash('sha256')
.update(await readFile(path.resolve(__dirname, '../dist', file)))
.digest('hex')

return `${sum} ${file}`
})
)

await writeFile(path.resolve(__dirname, '../dist', 'sha256sums.txt'), lines.join('\n') + '\n')

0 comments on commit 28bd90e

Please sign in to comment.