diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ae7e804..8dc7f789 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,27 +13,37 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 20.x - # Create ./unzipped - - run: "mkdir ./unzipped" - # Unzip committed zip files into ./unzipped - - run: "unzip ./dist/chrome.zip -d ./unzipped/chrome" - - run: "unzip ./dist/firefox.zip -d ./unzipped/firefox" - - run: "unzip ./dist/website.zip -d ./unzipped/website" + + # Create ./tmp + - run: "mkdir ./tmp" + + # Unzip committed zip files into ./tmp + - run: "unzip ./dist/chrome.zip -d ./tmp/chrome" + - run: "unzip ./dist/firefox.zip -d ./tmp/firefox" + - run: "unzip ./dist/website.zip -d ./tmp/website" + + # Copy IPFS hashes into ./tmp + - run: "cp ./dist/.ipfs.md ./tmp/.ipfs.md" + - run: "cp ./dist/.website.ipfs.md ./tmp/.website.ipfs.md" + # Rebuild - run: "npm ci && npm run build" - # Compare unzipped committed zip files and built folders - - run: "diff -r ./unzipped/chrome ./dist/chrome" - - run: "diff -r ./unzipped/firefox ./dist/firefox" - - run: "diff -r ./unzipped/website ./dist/website" - # Delete ./unzipped - - run: "rm -rf ./unzipped" + + # Compare zip content + - run: "diff -r ./tmp/chrome ./dist/chrome" + - run: "diff -r ./tmp/firefox ./dist/firefox" + - run: "diff -r ./tmp/website ./dist/website" + + # Compare IPFS hashes + - run: "diff ./tmp/.ipfs.md ./dist/.ipfs.md" + - run: "diff ./tmp/.website.ipfs.md ./dist/.website.ipfs.md" + + # Delete ./tmp + - run: "rm -rf ./tmp" + # Restore build files - run: "git restore ./dist" - # Recompute IPFS hashes - - run: "node ./scripts/ipfs.mjs" - # Display IPFS hashes - - run: "cat ./dist/.ipfs.md" - - run: "cat ./dist/.website.ipfs.md" - # Compare all files + + # Compare other files - run: "git status --porcelain" - run: "[[ -z $(git status --porcelain) ]]" \ No newline at end of file diff --git a/README.md b/README.md index 41de487f..8f3b5432 100644 --- a/README.md +++ b/README.md @@ -105,35 +105,36 @@ https://github.com/brumewallet/wallet/actions/workflows/release.yml You can check the comparison yourself by running the following ```bash -# Create ./unzipped -mkdir ./unzipped +# Create ./tmp +mkdir ./tmp -# Unzip committed zip files into ./unzipped -unzip ./dist/chrome.zip -d ./unzipped/chrome -unzip ./dist/firefox.zip -d ./unzipped/firefox -unzip ./dist/website.zip -d ./unzipped/website +# Unzip committed zip files into ./tmp +unzip ./dist/chrome.zip -d ./tmp/chrome +unzip ./dist/firefox.zip -d ./tmp/firefox +unzip ./dist/website.zip -d ./tmp/website + +# Copy IPFS hashes into ./tmp +cp ./dist/.ipfs.md ./tmp/.ipfs.md +cp ./dist/.website.ipfs.md ./tmp/.website.ipfs.md # Rebuild npm ci && npm run build -# Compare unzipped committed zip files and built folders -diff -r ./unzipped/chrome ./dist/chrome -diff -r ./unzipped/firefox ./dist/firefox -diff -r ./unzipped/website ./dist/website +# Compare zip content +diff -r ./tmp/chrome ./dist/chrome +diff -r ./tmp/firefox ./dist/firefox +diff -r ./tmp/website ./dist/website + +# Compare IPFS hashes +diff ./tmp/.ipfs.md ./dist/.ipfs.md +diff ./tmp/.website.ipfs.md ./dist/.website.ipfs.md -# Delete ./unzipped -rm -rf ./unzipped +# Delete ./tmp +rm -rf ./tmp # Restore build files git restore ./dist/ -# Recompute IPFS hashes -node ./scripts/ipfs.mjs - -# Display IPFS hashes -cat ./dist/.ipfs.md -cat ./dist/.website.ipfs.md - # Compare all files [[ -z $(git status --porcelain) ]] && echo "OK" || echo "NOT OK" ``` diff --git a/scripts/ipfs.mjs b/scripts/ipfs.mjs deleted file mode 100644 index afb7927f..00000000 --- a/scripts/ipfs.mjs +++ /dev/null @@ -1,41 +0,0 @@ -import { MemoryBlockstore } from "blockstore-core/memory"; -import { readFile, writeFile } from "fs/promises"; -import { importer } from "ipfs-unixfs-importer"; -import path from "path"; -import { walkSync } from "./libs/walkSync.mjs"; - -{ - const blockstore = new MemoryBlockstore() - - const source = new Array() - - source.push({ path: "website.zip", content: await readFile("./dist/website.zip") }) - source.push({ path: "chrome.zip", content: await readFile("./dist/chrome.zip") }) - source.push({ path: "firefox.zip", content: await readFile("./dist/firefox.zip") }) - source.push({ path: "android.apk", content: await readFile("./dist/android.apk") }) - source.push({ path: "ios-and-ipados.ipa", content: await readFile("./dist/ios-and-ipados.ipa") }) - source.push({ path: "macos.zip", content: await readFile("./dist/macos.zip") }) - - let last - - for await (const file of importer(source, blockstore, { wrapWithDirectory: true })) - last = file - - await writeFile("./dist/.ipfs.md", `https://${last.cid.toString()}.ipfs.nftstorage.link/`) -} - -{ - const blockstore = new MemoryBlockstore() - - const source = new Array() - - for (const filePath of walkSync("./dist/website")) - source.push({ path: path.relative("./dist/website", filePath), content: await readFile(filePath) }) - - let last - - for await (const file of importer(source, blockstore, { wrapWithDirectory: true })) - last = file - - await writeFile("./dist/.website.ipfs.md", `https://${last.cid.toString()}.ipfs.nftstorage.link/`) -} \ No newline at end of file diff --git a/scripts/postbuild2.mjs b/scripts/postbuild2.mjs index 0b5c6187..767681aa 100644 --- a/scripts/postbuild2.mjs +++ b/scripts/postbuild2.mjs @@ -1,4 +1,8 @@ +import { MemoryBlockstore } from "blockstore-core/memory"; import fs from "fs"; +import { readFile, writeFile } from "fs/promises"; +import { importer } from "ipfs-unixfs-importer"; +import path from "path"; import { walkSync } from "./libs/walkSync.mjs"; const thepackage = JSON.parse(fs.readFileSync("./package.json", "utf8")) @@ -166,4 +170,40 @@ if (fs.existsSync("./dist/apple")) { fs.writeFileSync(filePath, replaced, "utf8") } } +} + +{ + const blockstore = new MemoryBlockstore() + + const source = new Array() + + source.push({ path: "website.zip", content: await readFile("./dist/website.zip") }) + source.push({ path: "chrome.zip", content: await readFile("./dist/chrome.zip") }) + source.push({ path: "firefox.zip", content: await readFile("./dist/firefox.zip") }) + source.push({ path: "android.apk", content: await readFile("./dist/android.apk") }) + source.push({ path: "ios-and-ipados.ipa", content: await readFile("./dist/ios-and-ipados.ipa") }) + source.push({ path: "macos.zip", content: await readFile("./dist/macos.zip") }) + + let last + + for await (const file of importer(source, blockstore, { wrapWithDirectory: true })) + last = file + + await writeFile("./dist/.ipfs.md", `https://${last.cid.toString()}.ipfs.nftstorage.link/`) +} + +{ + const blockstore = new MemoryBlockstore() + + const source = new Array() + + for (const filePath of walkSync("./dist/website")) + source.push({ path: path.relative("./dist/website", filePath), content: await readFile(filePath) }) + + let last + + for await (const file of importer(source, blockstore, { wrapWithDirectory: true })) + last = file + + await writeFile("./dist/.website.ipfs.md", `https://${last.cid.toString()}.ipfs.nftstorage.link/`) } \ No newline at end of file