If you have iMovie ’13 (which came with Mac OS 10.9), follow the steps below.
If you have iMovie ’11 (which came with Mac OS 10.7 and 10.8), follow these steps instead: HOW TO – Export a Web-Ready Video from iMovie ’11
Here’s a quick guide to exporting a web-ready video out of iMovie ’13:
You can also try publishing directly to YouTube or Vimeo, but I’ve never had much luck with those options.
The best resource for learning more about iMovie ’13 is Apple’s iMovie help pages. Here’s the page on Exporting Online.
The option I recommend AGAINST is exporting to QuickTime. Use that only if you plan to import your movie into other video editing apps or to burn it to CD, NOT for uploading to the web.
The option I use is Share to iTunes, but I set my Mac to open all m4v files in QuickTime Player instead of iTunes. For instructions on how to do that, see: How to Change the Default App that Opens Files on a Mac