Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion doc/DEVELOPMENT.org
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ Some tips:
- To debug flaky tests, it's useful to use =--count=N= flag (via =pytest-repeat=).

* Releasing extension

- bump extension =version= and =version_name= in =extension/package.json=
- commit your changes (the build script expects a clean git state)

** AMO (addons.mozilla.org)

: cd extension
: npm install # (if necessary)
: ./build --firefox --v2 --lint --release --publish
: source ./webext_secrets.sh # puts api key/secret in the environment
: ./build --firefox --lint --release --publish listed

Note that this command will go in a busy loop waiting for the extension to be approved on AMO.
(you will see it on https://addons.mozilla.org/en-US/developers/addon/grasp/versions)
Expand Down
87 changes: 83 additions & 4 deletions extension/build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,80 @@ TARGETS = [
THISDIR = Path(__file__).absolute().parent


# FFS json doesn't allow newlines, need to put \n, which makes everything unreadable
AMO_METADATA = {
"summary": {
"en-US": "A reliable way of capturing and tagging web pages and content"
},
"description": {
"en-US": """
Grasp implements org-capture for Chrome. It adds button and keybindings to capture current page title and url, possibly selected text, additional comments or tags and sends it into your Org Mode file.

To use it:
- Install the extension from and setup hotkeys if necessary
- You'll also need a running 'backend' to communicate with extension, see instructions [here](https://github.com/karlicoss/grasp#setup)
"""
},
"requires_payment": False,
"categories": {
"firefox": ["bookmarks"]
},
"support_email": {
"en-US": "karlicoss.dev@gmail.com"
},
"homepage": {
"en-US": "https://github.com/karlicoss/grasp"
},
"version": {
"license": "MIT",
"approval_notes": """
You can find up-to-date extension code here https://github.com/karlicoss/grasp/tree/master/extension

The build instructions assume that the zip file with source code is in =/path/to/extension-source-firefox.zip= (on the HOST system).
*Make sure to replace it with the actual path to the source code zip file.*

To build you need *Ubuntu 24.04/Noble* and *Node 24*. The easiest way to build cleanly would be a Docker container:

```
# on the HOST system: cleanup previous container -- if it didn't exist in the first place, it will show an error, ignore it
docker rm -f extension_build

# on the HOST system: create the container
docker create --name extension_build -it ubuntu:noble /bin/bash

# on the HOST system: put the sources into the container
docker cp /path/to/extension-source-firefox.zip extension_build:/extension-source-firefox.zip

# on the HOST system: start the container
docker start -i extension_build
```

After that build the addon (run these commands INSIDE the container if you choose to do it with Docker):

```
$ apt update && apt install -y git curl unzip
$ curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
$ DEBIAN_FRONTEND=noninteractive apt install -y nodejs
$ unzip extension-source-firefox.zip -d extension
$ cd extension
$ npm install
$ ./build --firefox --release --lint --publish=skip
```


The final artifact will be in =/extension/dist/artifacts/firefox/grasp-<version>.zip= (INSIDE the container).

If you need to get it back onto the HOST system (e.g. to test in the browser), run on the HOST system (e.g. in a separate terminal):

docker cp extension_build:/extension/dist/artifacts/firefox/grasp-<version>.zip

This will copy it into the current directory on the HOST system.
"""
}
}



npm = "npm.cmd" if sys.platform == "win32" else "npm"


Expand Down Expand Up @@ -123,18 +197,23 @@ def main() -> None:
check_call(['git', 'archive', 'HEAD', '--output', source_zip], cwd=THISDIR) # cwd so we only package the extension

if 'firefox' in target:
from firefox_dev_secrets import API_KEY, API_SECRET
amo_metadata = THISDIR / 'amo-metadata.json'
amo_metadata.write_text(json.dumps(AMO_METADATA, indent=2))

# see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#web-ext-sign
assert ('WEB_EXT_API_KEY' in os.environ) and ('WEB_EXT_API_SECRET' in os.environ), "WEB_EXT_API_KEY and WEB_EXT_API_SECRET environment variables must be set for publishing to AMO"
check_call([
npm, 'run', 'web-ext',
'--',
'sign',
'--channel', args.publish,
'--source-dir', str(ext_dir),
'--artifacts-dir', str(artifacts_dir),
'--api-key' , API_KEY,
'--api-secret' , API_SECRET,
# this will be passed automatically from env
# '--api-key' , ...,
# '--api-secret' , ...,
# seems like webext sign requires addon id to be in manifest now
'--amo-metadata' , THISDIR / 'amo-metadata.json',
'--amo-metadata' , amo_metadata,
'--upload-source-code', source_zip,
])
elif target == 'chrome':
Expand Down
4 changes: 2 additions & 2 deletions extension/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grasp",
"version": "1.0.0",
"version_name": "released on 2024.04.24",
"version": "1.0.2.0",
"version_name": "released on 2026.01.03",
"description": "Reliably capture links and webpage content in a plaintext file (org-mode/markdown)",
"main": "dist/background.js",
"scripts": {
Expand Down