4 REPODIR
="$(git rev-parse --show-toplevel)"
5 PASSDIR
="$REPODIR/applications/pass-extension"
6 VERSION
="$(jq -r .version <"$PASSDIR/manifest-chrome.json
")"
7 ARTEFACTSDIR
="$REPODIR/build"
9 COMMIT
="$(git rev-parse --short HEAD)"
10 BUILD_ID
="ProtonPass-${VERSION}-${COMMIT}"
14 cd "$PASSDIR" && rm -rf dist
18 rm -rf "${OUTDIR:-}/*"
20 printf "\t✅ %s\n" "$arg"
24 function set_manifest_key
{
25 local key
=$
(jq
-r ".[\"$2\"]" "$PASSDIR/manifest-keys.json")
26 jq
--indent 4 --arg key
"$key" '. + {"key": $key}' "$1" >manifest.json.tmp
&& mv manifest.json.tmp
"$1"
29 function build_chromium_black
{
30 on_enter
"Chromium (Black)"
31 BUILD_TARGET
=chrome MANIFEST_KEY
="" yarn run build
:extension
:dev
>/dev
/null
35 # QA Black Chrome Build
36 set_manifest_key
"./manifest.json" "chrome:production"
37 zip -rqX "$ARTEFACTSDIR/chrome/$BUILD_ID.black.zip" "."
40 set_manifest_key
"./manifest.json" "edge:production"
41 zip -rqX "$ARTEFACTSDIR/edge/$BUILD_ID.black.zip" "."
43 on_leave
"chrome/$BUILD_ID.black.zip" "edge/$BUILD_ID.black.zip"
46 function build_chromium_prod
{
47 on_enter
"Chromium (Prod)"
49 # store versions should not have a `key` in the manifest
50 RELEASE
=true BUILD_TARGET
=chrome MANIFEST_KEY
="" yarn run build
:extension
>/dev
/null
54 # Chromium store version for release
55 zip -rqX "$ARTEFACTSDIR/release/$BUILD_ID-chromium.zip" "."
57 # QA Production Chrome build
58 set_manifest_key
"./manifest.json" "chrome:production"
59 zip -rqX "$ARTEFACTSDIR/chrome/$BUILD_ID.zip" "."
61 # QA Production Edge build
62 set_manifest_key
"./manifest.json" "edge:production"
63 zip -rqX "$ARTEFACTSDIR/edge/$BUILD_ID.zip" "."
65 on_leave
"release/$BUILD_ID-chromium.zip" "chrome/$BUILD_ID.zip" "edge/$BUILD_ID.zip"
68 function build_firefox_black
{
69 on_enter
"Firefox (Black)"
70 BUILD_TARGET
=firefox yarn run build
:extension
:dev
>/dev
/null
72 zip -rqX "$ARTEFACTSDIR/firefox/$BUILD_ID.black.zip" "."
74 on_leave
"firefox/$BUILD_ID.black.zip"
77 function build_firefox_prod
{
78 on_enter
"Firefox (Sources)"
79 BUILD_TARGET
=firefox NODE_ENV
=production yarn run config
80 # Preserve config.ts because the `yarn` postinstall script will overwrite it
81 cp src
/app
/config.ts src
/app
/config.ff-release.ts
84 zip -rqX "$OUTDIR/$BUILD_ID-FF-sources.zip" \
85 "applications/pass-extension" \
95 -x "*/node_modules/*" \
96 -x "packages/config/*" \
97 -x "applications/pass-extension/dist/*" \
98 -x "applications/pass-extension/*.md" \
99 -x ".yarn/install-state.gz" \
103 zip -uqX "$OUTDIR/$BUILD_ID-FF-sources.zip" "FIREFOX_REVIEWERS.md"
104 mv "$OUTDIR/$BUILD_ID-FF-sources.zip" "$ARTEFACTSDIR/release"
105 on_leave
"release/$BUILD_ID-FF-sources.zip"
107 on_enter
"Firefox (Prod)"
108 mkdir
-p "$OUTDIR/$BUILD_ID-FF-sources"
109 cd "$OUTDIR/$BUILD_ID-FF-sources"
110 unzip -q "$ARTEFACTSDIR/release/$BUILD_ID-FF-sources.zip"
111 yarn
install --no-immutable >/dev
/null
112 cd applications
/pass-extension
113 RELEASE
=true yarn run build
:extension
:ff
>/dev
/null
115 zip -rqX "$ARTEFACTSDIR/release/$BUILD_ID-FF.zip" "."
116 on_leave
"release/$BUILD_ID-FF.zip"
120 echo "Building for all platforms... This may take a while."
121 printf "\tNode\t%s (%s)\n" "$(node --version)" "$(which node)"
122 printf "\tnpm\tv%s (%s)\n" "$(npm --version)" "$(which npm)"
123 printf "\tYarn\tv%s (%s)\n" "$(yarn --version)" "$(which yarn)"
124 for var
in "REPODIR" "PASSDIR" "VERSION" "ARTEFACTSDIR" "OUTDIR" "COMMIT" "BUILD_ID"; do
125 printf "\t%s = %s\n" "${var}" "${!var}"
128 # Validate dependencies
129 echo "Validating yarn.lock..."
130 if [ -z ${CI+n} ]; then
132 yarn
install --immutable --immutable-cache >/dev
/null
133 printf "\t✅ %s\n" "OK"
135 printf "\t⚠️ Skipped, \$CI var is already set\n"
138 # Set up clean artefacts location
139 rm -rf "${ARTEFACTSDIR:-}" && mkdir
-p "$ARTEFACTSDIR"
140 mkdir
-p "$ARTEFACTSDIR/chrome"
141 mkdir
-p "$ARTEFACTSDIR/edge"
142 mkdir
-p "$ARTEFACTSDIR/firefox"
143 mkdir
-p "$ARTEFACTSDIR/safari"
144 mkdir
-p "$ARTEFACTSDIR/release"
146 # Execute individual builds