-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·34 lines (28 loc) · 1.46 KB
/
Copy pathpackage.sh
File metadata and controls
executable file
·34 lines (28 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# Build the Chrome Web Store upload zip.
#
# The store assigns the production extension id, so the dev `key` (which pins a
# stable id for unpacked multi-machine testing) is stripped from the packaged
# manifest. Output: dist/truepin-<version>.zip with manifest.json at the root.
set -euo pipefail
cd "$(dirname "$0")"
VER=$(node -e "console.log(require('./extension/manifest.json').version)")
OUT="dist/truepin-$VER.zip"
rm -rf dist/build
mkdir -p dist/build
cp -R extension/. dist/build/
# Strip the dev-only `key` so the Web Store owns the production id.
node -e "const fs=require('fs');const p='dist/build/manifest.json';const m=JSON.parse(fs.readFileSync(p));delete m.key;fs.writeFileSync(p,JSON.stringify(m,null,2)+'\n')"
find dist/build -name '.DS_Store' -delete
# One zip in dist, ever: a stale zip of an older version has already been
# hand-uploaded once (see the dist-rebuild lesson in the knowledge base).
rm -f dist/truepin-*.zip
( cd dist/build && zip -rqX "../truepin-$VER.zip" . )
rm -rf dist/build
# Guard: the packaged manifest must carry the source version and no dev key.
ZIPVER=$(unzip -p "$OUT" manifest.json | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>{const m=JSON.parse(s);if(m.key){console.error('dev key leaked into the package');process.exit(1)}console.log(m.version)})")
if [ "$ZIPVER" != "$VER" ]; then
echo "version mismatch: zip=$ZIPVER manifest=$VER" >&2
exit 1
fi
echo "built $OUT (v$VER, dev key stripped)"