Skip to content

Commit

Permalink
unify
Browse files Browse the repository at this point in the history
  • Loading branch information
hazae41 committed Mar 9, 2024
1 parent 730fb16 commit fc6cbc5
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 78 deletions.
46 changes: 28 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ]]"
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
Expand Down
41 changes: 0 additions & 41 deletions scripts/ipfs.mjs

This file was deleted.

40 changes: 40 additions & 0 deletions scripts/postbuild2.mjs
Original file line number Diff line number Diff line change
@@ -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"))
Expand Down Expand Up @@ -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/`)
}

0 comments on commit fc6cbc5

Please sign in to comment.