Merge branch 'master' into testing
This commit is contained in:
commit
8b066c3692
74
scripts/build-and-deploy.sh
Normal file
74
scripts/build-and-deploy.sh
Normal file
@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
# env variables to set:
|
||||
#
|
||||
# FORCE_BUILD set this variable to "true" if you wanna force build, even if build was
|
||||
# triggered without any commits pushed to the directory
|
||||
#
|
||||
# BUILD_SCRIPT build-testing or build-nightly, could be any other from package.json tho
|
||||
#
|
||||
# RELEASE_SERVER target server (where to push built zips after they've been built)
|
||||
# RELEASE_DIRECTORY base directory on the target server
|
||||
# BUILD_CHANNEL_DIRECTORY directory for uploads, inside the release directory
|
||||
#
|
||||
# AMO_API_KEY needed if you want to sign and push extension to addons.mozilla.org
|
||||
# AMO_API_SECRET -||-
|
||||
|
||||
# don't build if nothing has changed, unless overriden via env variable
|
||||
if [ ! -z "$GIT_COMMIT" && ! -z "$GIT_PREVIOUS_COMMIT" ] ; then
|
||||
if [ "$GIT_COMMIT" == "$GIT_PREVIOUS_COMMIT" ] ; then
|
||||
if [ $FORCE_BUILD == "true" ] ; then
|
||||
echo "--------------------------------------------"
|
||||
echo " Nothing has changed. Aborting build."
|
||||
echo "--------------------------------------------"
|
||||
exit 0;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
npm ci
|
||||
|
||||
rm -rf /dist-zip || true # no big deal if ./dist-zip doesn't exist
|
||||
|
||||
#
|
||||
# build firefox
|
||||
#
|
||||
npm run "${BUILD_SCRIPT}"
|
||||
node scripts/build-zip.js ff
|
||||
if [ ! -z "${AMO_API_KEY}" ] ; then
|
||||
if [ ! -z "${AMO_API_SECRET}" ] ; then
|
||||
web-ext sign --source-dir ./dist --api-key "${AMO_API_KEY}" --api-secret "${AMO_API_SECRET}"
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# build chrome
|
||||
#
|
||||
npm run "${BUILD_SCRIPT}-chrome"
|
||||
node scripts/build-zip.js chrome
|
||||
|
||||
#
|
||||
#./scripts/build-crx.sh
|
||||
#
|
||||
|
||||
######################################
|
||||
# UPLOAD TO WEB SERVER
|
||||
######################################
|
||||
|
||||
# add ssh key, if not added
|
||||
if [ -z "$SSH_AUTH_SOCK" ] ; then
|
||||
eval `ssh-agent -s`
|
||||
ssh-add
|
||||
fi
|
||||
|
||||
# push all built stuff to the server
|
||||
scp -r ./build-zip/* "ultrawidify-uploader@${RELEASE_SERVER}:${RELEASE_DIRECTORY}${BUILD_CHANNEL_DIRECTORY}"
|
||||
|
||||
|
||||
|
||||
######################################
|
||||
# Build finished message
|
||||
######################################
|
||||
|
||||
echo "--------------------------------------------"
|
||||
echo " Nothing has changed. Aborting build."
|
||||
echo "--------------------------------------------"
|
@ -17,9 +17,9 @@ const extractExtensionData = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const makeDestZipDirIfNotExists = () => {
|
||||
if(!fs.existsSync(DEST_ZIP_DIR)) {
|
||||
fs.mkdirSync(DEST_ZIP_DIR);
|
||||
const makeDirIfNotExists = (dir) => {
|
||||
if(!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,13 +42,26 @@ const buildZip = (src, dist, zipFilename) => {
|
||||
|
||||
const main = () => {
|
||||
const browser = process.argv[2];
|
||||
const testingOrNightly = process.argv[3];
|
||||
|
||||
const {name, version} = extractExtensionData();
|
||||
const zipFilename = `${name.replace(/[ -]+/g, '')}-${version}-${browser}.zip`;
|
||||
|
||||
makeDestZipDirIfNotExists();
|
||||
|
||||
buildZip(DEST_DIR, DEST_ZIP_DIR, zipFilename)
|
||||
// collapse spaces and dashes into single dash
|
||||
const baseFilename = `${name.replace(/[ -]+/g, '-')}-${version}`;
|
||||
|
||||
let realZipDir;
|
||||
|
||||
if (!!testingOrNightly) {
|
||||
realZipDir = path.join(DEST_ZIP_DIR, baseFilename);
|
||||
} else {
|
||||
realZipDir = DEST_ZIP_DIR;
|
||||
}
|
||||
|
||||
const zipFilename = `${baseFilename}-${browser}.zip`;
|
||||
|
||||
makeDirIfNotExists(realZipDir);
|
||||
|
||||
buildZip(DEST_DIR, realZipDir, zipFilename)
|
||||
.then(() => console.info('OK'))
|
||||
.catch(console.err);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user