If I upload source code of a virus I have developed so that the larger software community could benefit from developing solutions to tackle the virus, and if somebody else uses my source code to harm other people, am I liable?
Your liability would be analogous to your liability for publicizing any other dangerous fact. The source code for numerous viruses has been made public e.g. on Github for exactly this purpose, though the examples which I found were viruses for which there are cures, such as the CIH virus. Publicizing a system weakness that enables a virus to be promulgated, or actually publicizing code that demonstrates the weakness, is similar to publishing bomb-making instructions. First Amendment considerations in the US weigh against any regulations. Aiding and abetting law requires more than just providing information that can be used in the commission of a crime, but that is a possible avenue for liability (see Rice v. Paladin). In that case, a central issue was whether the publication was communication of ideas, but the final appellate decision was that "The book directly and unmistakably urges concrete violations of the laws against murder and murder for hire and coldly instructs on the commission of these crimes. The Supreme Court has never protected as abstract advocacy speech so explicit in its palpable entreaties to violent crimes".
Unless you wrote that virus yourself and own the copyright, you start with committing copyright infringement.
Your explanation "the larger software community could benefit from developing solutions to tackle the virus" is rubbish. If that was your intention, then you would post a notice that you can make the source code available, and then give it to people who identify themselves and can demonstrate that they are trustworthy. What you are doing makes the source code available to every **** hacker in the world.
So DON'T DO IT. Whether it's legal or not, it is a stupid dick move. Everyone who could ever employ you for legal work will not be impressed one bit by this. Nobody needing to trust their employees will hire you. And especially in the USA, the biggest question is not whether it is legal, but whether someone is going to sue you. Anyone affected by this virus can claim that it happened because you published the code and take you to court, which will cost time and money even if there is no judgement against you.