Always is a strong word. Also, would it be fair if you created something, but another took credit (and profit) from your hard work?
It should certainly be legal. My game is released under a creative commons licence and the source code is public domain.