I have this WebExtension addon. It's not very important. Just a web extension that does some hacks to GitHub pages when I open them in Firefox. The web extension is a folder with a manifest.json
, icons/icon-48.png
, tricks.js
, README.md
etc. To upload it to addons.mozilla.org I first have to turn the whole thing into a .zip
file that I can upload.
So I discovered a neat way to make that zip file. It looks like this:
#!/bin/bash DESTINATION=build-`cat manifest.json | jq -r .version`.zip git archive --format=zip master > $DESTINATION echo "Created..." ls -lh $DESTINATION
You run it and it creates a build-1.0.zip
file containing all the files that are checked into the git repo. So it discards my local "junk" such as backup files or other things that are mentioned in .gitignore
(and .git/info/exclude
).
I bet someone's going to laugh and say "Duhh! Of course!" but I didn't know you can do that easily. Hopefully posting this it'll help someone trying to do something similar.
Note; this depends on jq which is an amazing little program.
Comments
Neat. Have you seen the "web-ext build" command?
No. But without looking it up I bet it does exactly this?
The power of blogging and looking a fool :)
Thank you!
Actually, `web-ext build` will include non-git files. In particular the Add-ons validator now complained that my .zip file contained a `build.sh~` file. Bug?