Q:

Building software safely for malware-free distribution

I wrote a program. I want to publish a compiled executable for downloading by the public. 
How can I compile and distribute it without contact with my (presumably insecure and infected) operating system? How do software vendors ensure that their software packages are malware-free?
The absence of relevant information on the web is pretty disturbing. It’s as if nobody in the world except me cared about safe and responsible distribution of software. Why are there no clean compilation services on the web? I’m not going to buy a separate computer only to compile and upload one little application.

A:

It's important to think about what kind of threat you are trying to protect against. Your questions could be taken to imply two different threat levels:

A general virus that just injects itself into any executables it happends to stumble over.
Malware designed specifically to infect your build process and embed itself in freashly compiled executables.

To protect yourself against the first category, schroeder has a good suggestion - just check the filesize. Your compiler probably already outputs that. Or have your compiler output a hash and use that, or sign the file in the build flow.
If you are up against a theat of the second type, the above is no good. If the attacker is sofisticated enought, nothing can help you at that point. As soon as your system is compromised, you are owned. 
In the end, it comes down to how advanced threats you want to protect yourself against. Using a separate machine could help, and so could a VM (or a "trusted third party", even though I am not sure I would trust one). But a sufficiently advanced attacker could overcome those obstacles as well.

