Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build tools for AMO submissions #441

Merged
merged 7 commits into from Aug 26, 2019

AMO Builder: replace sed substitutions with jq for manifest.json. Cle…

…an up exlcudes
  • Loading branch information
christophertino committed Aug 23, 2019
commit 445bb9c409c54fd778f479baa2a27956b6ad66fd
@@ -14,9 +14,9 @@
set -e

# Set directory paths for both projects
GHOSTERY_SOURCE_ZIP=`find . -name "ghostery-extension-*.zip"`
GHOSTERY_SOURCE_ZIP=$(find . -name "ghostery-extension-*.zip")
GHOSTERY_SOURCE_DIR="${GHOSTERY_SOURCE_ZIP%.zip*}"
CLIQZ_SOURCE_ZIP=`find . -name "browser-core-*.zip"`
CLIQZ_SOURCE_ZIP=$(find . -name "browser-core-*.zip")
CLIQZ_SOURCE_DIR="${CLIQZ_SOURCE_ZIP%.zip*}"

# Extract
@@ -32,10 +32,10 @@ fi
cd $CLIQZ_SOURCE_DIR

# Clean any previous builds
rm -fr build
rm -rf build

# Clean all the exiting node_modules for a more reproducible build
rm -fr node_modules
rm -rf node_modules

# Install the exact versions from package-lock.json
npm ci
@@ -51,58 +51,59 @@ cd ..
cd $GHOSTERY_SOURCE_DIR

VERSION_FILE=manifest.json
MANIFEST=`cat $VERSION_FILE`
CWD=$(pwd)
VERSION=`cat $VERSION_FILE | jq '.version'`
MANIFEST_BACKUP=$(cat $VERSION_FILE)
RAW_VERSION=$(cat $VERSION_FILE | jq '.version')
VERSION=${RAW_VERSION//\"} # remove ""
BUILD_DIR=build
ZIP_FILE="$BUILD_DIR/ghostery-extension-v$VERSION.zip"
TMP_FILE=$(mktemp)

# Install yarn
# Check for yarn
if ! type yarn > /dev/null; then
if ! type brew > /dev/null; then
brew install yarn
else
curl -o- -L https://yarnpkg.com/install.sh | bash
fi
abort "Please install yarn: https://yarnpkg.com/lang/en/docs/install/"
fi

# Install jq
# Check for jq
if ! type jq > /dev/null; then
if ! type brew > /dev/null; then
brew install jq
else
abort "Please install jq: https://stedolan.github.io/jq/download/"
fi
abort "Please install jq: https://stedolan.github.io/jq/download/"
fi

# Check for nvm
. /usr/local/opt/nvm/nvm.sh
if ! command -v nvm | grep -q 'nvm'; then
abort "Please install nvm: https://github.com/nvm-sh/nvm"
fi

# Clean any previous builds
rm -fr build
rm -rf build

# Clean all the exiting node_modules for a more reproducible build
rm -fr node_modules
rm -rf node_modules

# Set node version
nvm use

# Install local npm packages
yarn install --frozen-lockfile

# Build for production
yarn build.prod

# Clean up manifest.json
sed -i '' '/^\([[:space:]]*"debug": \).*$/d' $VERSION_FILE
sed -i '' '/^\([[:space:]]*"log": \).*$/d' $VERSION_FILE
sed -i '' '/^\([[:space:]]*"options_page": \).*$/d' $VERSION_FILE
sed -i '' '/^\([[:space:]]*"minimum_edge_version": \).*$/d' $VERSION_FILE
sed -i '' '/^\([[:space:]]*"minimum_chrome_version": \).*$/d' $VERSION_FILE
sed -i '' '/^\([[:space:]]*"minimum_opera_version": \).*$/d' $VERSION_FILE
# Clean up properties from manifest.json
cat $VERSION_FILE | jq 'del(.version_name, .debug, .log, .options_page, .minimum_edge_version, .minimum_chrome_version, .minimum_opera_version, .permissions[7,8], .background.persistent)' > ${TMP_FILE}
cat ${TMP_FILE} > $VERSION_FILE # copy into manifest.json
rm -f ${TMP_FILE}

# Zip final build files
echo "Zipping to $BUILD_DIR/ directory"
echo "Zipping to $(pwd)/$BUILD_DIR/"
test -d $BUILD_DIR || mkdir $BUILD_DIR && \
zip --quiet -R "$ZIP_FILE" "*" -x \
^.*\
.* \
.*/\* \
app/content-scripts/\* \
app/data-images/\* \
app/panel/\* \
app/panel-android/\* \
app/setup/\* \
app/scss/\* \
app/licenses/\* \
@@ -116,8 +117,8 @@ test -d $BUILD_DIR || mkdir $BUILD_DIR && \
src/\* \
test/\* \
tools/\* \
*.log$ \
*.md$ \
*.log \
*.md \
babel.config.js \
CODEOWNERS \
Dockerfile \
@@ -128,13 +129,8 @@ test -d $BUILD_DIR || mkdir $BUILD_DIR && \
package-lock.json \
yarn.lock \
webpack.* \
*.DS_Store* \
&& \
cd "$CWD" || \
{
abort "Error occurred creating ghostery-extension zip"
}
*.DS_Store*
echo "Zipped successfully into $BUILD_DIR/$ZIP_FILE"

# Reset manifest
echo $MANIFEST > $VERSION_FILE
echo $MANIFEST_BACKUP > $VERSION_FILE
ProTip! Use n and p to navigate between commits in a pull request.