From 10c26266e803e884b76dfb78ce1934d798159397 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Tue, 27 Aug 2024 16:28:59 -0400 Subject: [PATCH 1/9] chore(gitignore): Ignore 'build' folder to prevent release packages from being committed --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 212189d9..eeb1ed0c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ coverage /src/recap.zip /recap-chrome.iml /.idea/ -.vscode/ \ No newline at end of file +.vscode/ +build/ From 0ea726049ac117bf1223f900ddf0f1faab7779cc Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Tue, 27 Aug 2024 16:31:33 -0400 Subject: [PATCH 2/9] feat(assets): Add 'favicon.ico' to assets for use in Firefox --- src/assets/images/favicon.ico | Bin 0 -> 5430 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/assets/images/favicon.ico diff --git a/src/assets/images/favicon.ico b/src/assets/images/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..fd6bbbf6d1eb7a91fdf92afad6f8f05169e080cc GIT binary patch literal 5430 zcmc&&X-rc=5MGbp#=q(xei)A+YBWX#iYP<{6U8Imq7e;560by~F-8TWMg?o)9lZrlkueWS0!uQy;Hmq+hn)vu=&1H9dIA0&A8{% zy8c5Ro(0AJ^1tvYuB@+l1*XH+(0tf)u$a-7z4@>)RUzP$d z(|&-_2o5)`ZV=8!RmkaJ#k=#c-eFuz0mmXrt#G8yy{fj`a=F9rZ;Cr?#&7TJcNou7 zKx0#{P53J}WzfQ3?EuqZ-OgND8F9}W z*}TWk8f52*;mD0Wi2KUqK6vs~QZB}ezJ3D?4;vw1Q zc%#9Po4aU58Vn2=0KbE!YhDXD7~>n7dYEqEM@xipIa&7dl3q14oah_X0?r|N9@xG$ z_9*>tgf;f!?>$t^uo}MifQM=%ZzwI-v9XiqKRGO4NiW>%mbN~Iw=Jvyg7+1$KKdT| zpwfD0@NeC(W0>(Tz5~WpZ0g%JF2P3q@gIS?!NA}!i#5G{2Jj3>cNsqFfZrK!4`pJa zGxl3dMuaIApbl%c=eX2%)Q5iuh`(g@pI9KKtHPLQ4ydpOLJkxmG;0pvBeq@ncgTLH z;A8%MRmoN{{%+^stLH3!IfcsCiDAf%`LD}>=$kc+7Wk*y<9}LShkE!V`Pid_oPG*C zE!Mo|HLz(P@GQ_D?D9zkOzvxHta&+hHX-9q;}wC68)9ZtY`mwS*Anc8Lb#`(cNm^j zBP8CYE=-<4?Te+8>z9EzS2k>8DNxn25@qe>P zS79yIq&!dK@k8v1HJDhvaPCT_*mTjcQy0ptY`k=>iq!?Vg&pvj);L&CU_OVn0#fk@ z4HUi8u>N^eZkydZLoZez-3&!TMLh#eiPOok1S<%3g;_5 z{nloHuIo=ej Date: Tue, 27 Aug 2024 16:33:53 -0400 Subject: [PATCH 3/9] feat(package.json): Add 'build' script to automate release package creation --- package.json | 4 +++- scripts/build.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 scripts/build.sh diff --git a/package.json b/package.json index 9c1a5f9f..9ff62b0d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ }, "scripts": { "test": "./node_modules/.bin/karma start --single-run", - "postinstall": "vendor-copy" + "postinstall": "vendor-copy", + "release-chrome": "./scripts/build.sh chrome", + "release-firefox": "./scripts/build.sh firefox" }, "repository": { "type": "git", diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..bcc221fc --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,47 @@ +# Create a browser extension release package + +# 1. Capture browser type from argument +browserType=$1 + +# 2. Construct release zip filename +zipName=$browserType-release.zip + +# 3. Ensure release directory exists (create if needed) +mkdir -p build/release/ + +# 4. Clean up any existing release zip +rm -f build/release/$browserType-release.zip + +# 5. Rename base manifest file +cd src/ && mv manifest.json manifest.base.json +if [[ "$browserType" == "firefox" ]]; then + faviconUrl='assets/images/favicon.icon' + # Remove unnecessary properties for Firefox manifest + jq 'del(.background.service_worker, .background.type)' manifest.base.json >manifest.json +else + faviconUrl='https://www.courtlistener.com/static/ico/favicon.ico' + # Remove unnecessary property for Chrome/Chromium manifest + jq 'del(.background.scripts, .applications)' manifest.base.json >manifest.json +fi + +# 6. Add search provider configuration to manifest +jq --arg favicon "$faviconUrl" '.chrome_settings_overrides.search_provider += { + "name": "RECAP Archive", + "search_url": "https://www.courtlistener.com/?type=r&q={searchTerms}&order_by=score+desc", + "favicon_url": $favicon, + "keyword": "recap", + "encoding": "UTF-8", + "is_default": false +}' manifest.json >manifest.tmp && mv manifest.tmp manifest.json + +# 7. Create release package +# - Include all files except the base manifest +zip -rq $zipName * -x "*.base.json" + +# 8. Move package to release directory +mv $zipName ../build/release + +# 9. Remove Browser-Specific Manifest File +rm manifest.json +# Rename base manifest back to main manifest +mv manifest.base.json manifest.json From 053c5f2d5bc79ea250c5340c4bb0dfa68d2dae48 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Tue, 27 Aug 2024 16:42:58 -0400 Subject: [PATCH 4/9] docs(readme): Update releasing instructions to reflect new build steps --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 630e96d1..5f4a3dcf 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,6 @@ When a new version is needed, the release process is: 1. Do the [manual QA tests][qa] 1. Update `package.json` and `manifest.json` with a new release version. -1. Run `web-ext lint` to ensure no regressions. 1. Update CHANGES.md 1. Commit the code. 1. Tag the code with something like: @@ -86,13 +85,16 @@ When a new version is needed, the release process is: git push --tags -f 1. Make sure you don't have any working/testing code in your tree that could get zipped up in the next step. -1. Zip up the archive with the rather archaic: +1. Run the following commands in your terminal from the project root directory to create release packages for Chrome and Firefox in the `build` folder: - cd src && zip -FSr recap.zip * + npm run release-chrome + npm run release-firefox -1. Make a new release on [Github announcing the release][ghtags] that includes the .zip file. -1. Upload that to the [Chrome Market][market]. -1. Upload that to addons.mozilla.org + The `build.sh` script relies on the [jq][jq] command-line JSON processor. Make sure you have it installed before proceeding. + +1. Make a new release on [Github announcing the release][ghtags] that includes the .zip files in the release assets. +1. Upload the `chrome-release.zip` file to the [Chrome Web Store.][market]. +1. Upload the `firefox-release.zip` file to addons.mozilla.org. Copyright @@ -131,3 +133,4 @@ RECAP for Chrome. If not, see: http://www.gnu.org/licenses/ [recap-issues]: https://github.com/freelawproject/recap/issues [commits]: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines [qa]: https://github.com/freelawproject/recap/wiki/QA-Testing +[jq]: https://jqlang.github.io/jq/ From e92ac271ea84cc70527504fb713384ef3233ec1d Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Tue, 27 Aug 2024 17:03:27 -0400 Subject: [PATCH 5/9] feat(docs): Updates the chages.md file --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index e398a8b6..cb3aeb97 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,7 +14,7 @@ Fixes: - None yet For developers: - - Nothing yet + - Adds script to automate release package creation ([388](https://github.com/freelawproject/recap-chrome/pull/388)) ## 2.7.2 (2024-07-21) From d6502789567370b84caacd6dc6fb6bb389cbb989 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Tue, 27 Aug 2024 18:49:07 -0400 Subject: [PATCH 6/9] feat(build): Adds pre-build check to ensure jq is installed --- scripts/build.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index bcc221fc..35bb919a 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,4 +1,12 @@ +#!/bin/bash # Create a browser extension release package +set -e + +# Checks if jq is installed +if ! command -v jq >/dev/null 2>&1; then + echo "jq is not installed. Please install jq before continuing." + exit 1 +fi # 1. Capture browser type from argument browserType=$1 @@ -10,7 +18,7 @@ zipName=$browserType-release.zip mkdir -p build/release/ # 4. Clean up any existing release zip -rm -f build/release/$browserType-release.zip +rm build/release/$browserType-release.zip # 5. Rename base manifest file cd src/ && mv manifest.json manifest.base.json From 1a3b54ac2e19f914620271eb63b2f26f98ddf6be Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Tue, 27 Aug 2024 19:09:46 -0400 Subject: [PATCH 7/9] refactor(build): Reorganize bash script commands --- scripts/build.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 35bb919a..3b990bb8 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -14,13 +14,7 @@ browserType=$1 # 2. Construct release zip filename zipName=$browserType-release.zip -# 3. Ensure release directory exists (create if needed) -mkdir -p build/release/ - -# 4. Clean up any existing release zip -rm build/release/$browserType-release.zip - -# 5. Rename base manifest file +# 3. Rename base manifest file cd src/ && mv manifest.json manifest.base.json if [[ "$browserType" == "firefox" ]]; then faviconUrl='assets/images/favicon.icon' @@ -32,7 +26,7 @@ else jq 'del(.background.scripts, .applications)' manifest.base.json >manifest.json fi -# 6. Add search provider configuration to manifest +# 4. Add search provider configuration to manifest jq --arg favicon "$faviconUrl" '.chrome_settings_overrides.search_provider += { "name": "RECAP Archive", "search_url": "https://www.courtlistener.com/?type=r&q={searchTerms}&order_by=score+desc", @@ -42,10 +36,16 @@ jq --arg favicon "$faviconUrl" '.chrome_settings_overrides.search_provider += { "is_default": false }' manifest.json >manifest.tmp && mv manifest.tmp manifest.json -# 7. Create release package +# 5. Create release package # - Include all files except the base manifest zip -rq $zipName * -x "*.base.json" +# 6. Ensure release directory exists (create if needed) +mkdir -p ../build/release/ + +# 7. Clean up any existing release zip +rm -f ../build/release/$browserType-release.zip + # 8. Move package to release directory mv $zipName ../build/release From 8d8f77a92998ff2ad00d32bb9bf2d8d7ba220b4d Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Tue, 27 Aug 2024 19:14:24 -0400 Subject: [PATCH 8/9] efactor(build): Enhance safety by removing -f flag from rm command --- scripts/build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 3b990bb8..a33f00b8 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -44,7 +44,10 @@ zip -rq $zipName * -x "*.base.json" mkdir -p ../build/release/ # 7. Clean up any existing release zip -rm -f ../build/release/$browserType-release.zip +file="../build/release/$browserType-release.zip" +if [ -f "$file" ] ; then + rm "$file" +fi # 8. Move package to release directory mv $zipName ../build/release From c24b78e752f6e0e7b7afe40a29ca6586ba51943c Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Tue, 27 Aug 2024 19:18:02 -0400 Subject: [PATCH 9/9] refactor(build): Streamlines browser-specific manifest cleaning step --- scripts/build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index a33f00b8..d624addd 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -53,6 +53,5 @@ fi mv $zipName ../build/release # 9. Remove Browser-Specific Manifest File -rm manifest.json # Rename base manifest back to main manifest mv manifest.base.json manifest.json