Skip to content

Commit

Permalink
Rewrite package scripts to produce deterministic zip files
Browse files Browse the repository at this point in the history
  • Loading branch information
killergerbah committed Apr 21, 2024
1 parent eec3d43 commit 4cc3aeb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
7 changes: 3 additions & 4 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"scripts": {
"buildDev": "NODE_OPTIONS=--openssl-legacy-provider webpack --config webpack.config.js --mode development",
"buildProd": "yarn workspace root run verify && NODE_OPTIONS=--openssl-legacy-provider webpack --config webpack.config.js --mode production",
"package": "cd dist/$PLATFORM && zip -r ../asbplayer-extension-$(jq -r .version manifest.json)-$PLATFORM.zip * && cd ../..",
"packageDev": "yarn buildDev && PLATFORM=chromium yarn package",
"packageProd": "yarn buildProd && PLATFORM=chromium yarn package",
"packageProdFirefox": "yarn buildProd --env firefox && PLATFORM=firefox yarn package"
"packageDev": "yarn buildDev && ../scripts/package chromium",
"packageProd": "yarn buildProd && ../scripts/package chromium",
"packageProdFirefox": "yarn buildProd --env firefox && ../scripts/package firefox"
},
"dependencies": {
"@fontsource/roboto": "^4.5.0",
Expand Down
32 changes: 32 additions & 0 deletions scripts/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

usage() {
echo "usage: $0 {chromium,firefox,firefoxandroid}"
}

if [[ -z "$1" ]]; then
usage
exit 1
fi

PLATFORM=$1
SCRIPTPATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
DISTPATH=$SCRIPTPATH/../extension/dist

pushd $DISTPATH

NAME="asbplayer-extension-$(jq -r .version $PLATFORM/manifest.json)-$PLATFORM.zip"

# Remove old zip file
rm -f $NAME

# Force file timestamps to constant so that final zip is deterministic
find $PLATFORM -mindepth 1 | xargs touch -ad "1970-01-01T00:00:00"
find $PLATFORM -mindepth 1 | xargs touch -md "1970-01-01T00:00:00"

# Zip everything up
find $PLATFORM -mindepth 1 | xargs zip -X $NAME $PLATFORM/*

popd

0 comments on commit 4cc3aeb

Please sign in to comment.