Skip to content

Commit

Permalink
Merge pull request #388 from freelawproject/feat-add-script-to-create…
Browse files Browse the repository at this point in the history
…-release-packages

feat(build): Adds automated release package creation script
  • Loading branch information
mlissner authored Aug 27, 2024
2 parents c1990aa + c24b78e commit 7fd4579
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage
/src/recap.zip
/recap-chrome.iml
/.idea/
.vscode/
.vscode/
build/
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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/
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
57 changes: 57 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/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

# 2. Construct release zip filename
zipName=$browserType-release.zip

# 3. 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

# 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",
"favicon_url": $favicon,
"keyword": "recap",
"encoding": "UTF-8",
"is_default": false
}' manifest.json >manifest.tmp && mv manifest.tmp manifest.json

# 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
file="../build/release/$browserType-release.zip"
if [ -f "$file" ] ; then
rm "$file"
fi

# 8. Move package to release directory
mv $zipName ../build/release

# 9. Remove Browser-Specific Manifest File
# Rename base manifest back to main manifest
mv manifest.base.json manifest.json
Binary file added src/assets/images/favicon.ico
Binary file not shown.

0 comments on commit 7fd4579

Please sign in to comment.