3 ms·
From the post: To register and publish your plugin, you’ll need to push your code to a public repository on GitHub, and add our post-recieve webhook URL (http:
by JangoSteve 14y ago
From the post:
To register and publish your plugin, you’ll need to push your code to a public repository on GitHub, and add our post-recieve webhook URL (http://plugins.jquery.com/postreceive-hook http://plugins.jquery.com/postreceive-hook) to your repository. The next time you push a semver tag, we’ll take care of registering the plugin name and updating its page on the site. When you’re ready to release the next version of your plugin, just tag and push again!
I'm curious how exactly they're doing this.
I created a similar site (but for all javascript plugins, not just jQuery), called http://jspkg.com http://jspkg.com. I built Github-import integration to add new projects from Github, and I wanted to do the same "automatically update when you push a new version tag" functionality, but Github doesn't fire the post-receive hook when you push tags, only when you push commits. It used to say that in the "When hooks are fired" section of the help page [1], but they've since updated that page to say almost nothing at all. I had also talked with a couple Github folks at the time, who confirmed this was the case, and that it'd cause problems for this exact use-case.
I started thinking of a few workarounds, but never settled on any of them, as none of them seemed like they'd work just right...
One workaround I thought of was to post to jspkg when the post-receive hook is fired, and allow jspkg to poll the git repo for the next couple minutes to see if it finds any new tags within that window. This seems like an ugly hack to me (not to mention, it would add a lot of unnecessary work on the server's end), and would still not be totally effective, if you waited longer than the window to push your new tags to github. I'm guessing it'd work fine the majority of the time, but as a developer, it wouldn't make my life that much easier if I still had to check jspkg.com every time just to make sure it worked.
So, then I started thinking of another option. Perhaps, instead of importing tags directly, maybe I have a post-receive hook that just looks to see if the package.json was modified, and if so, see if the version was bumped. And if it was, import that snapshot of the master branch. The issue with this is that you can't use the post-receive if you don't have a package.json (though maybe that's not entirely a bad thing). It also means that it might create snapshots when you don't expect. For example, if I change my package.json and then do a couple more commits and then tag the release, the distribution on jspkg will be from when the package.json was updated, not when the tag was created.
Another option I was considering is just writing a really simple git hook (not a github hook) that uses jspkg's restful api to upload a zip file from the users machine when they create a new version tag. Then it wouldn't rely on github even, but it would require the user to install the commit hook locally.
At any rate, I guess I'll have to check out the source code for the plugin registry to see what they settled on.
[1] http://help.github.com/test-webhooks/ http://help.github.com/test-webhooks/
- streeter 14y agoHere's the code for how they're fetching and parsing tags [1] with the GitHub post-receive hook. [1]: https://github.com/jquery/plugins.jquery.com/blob/master/lib/service/github.js https://github.com/jquery/plugins.jquery.com/blob/master/lib...