He said in the same sermon:
Let your light shine before men, that they may see your good deeds and praise your Father in heaven (Matthew 5:17).
Be careful not to do your acts of righteousness before men, to be seen by them. If you do, you will have no reward from your Father in heaven (Matthew 6:1).
Huh?...What gives? Which teaching supersedes the other? Possibly, we misunderstand the kinds of good deeds Jesus is referring to in the first saying. We find the saying in context with the Beatitudes. I like to think of Jesus' "salt" and "light" analogy a comment on the last Beatitude (which I like to call the "Be-Radical" Beatitude):
Blessed are you when people insult you, persecute you and falsely say all kinds of evil against you because of me. Rejoice and be glad, for great is your reward in heaven, because in the same way they persecuted the prophets who were before you. You are the salt of the earth. But if the salt loses its saltiness, how can it be made salty again? It is no longer good for anything, except to be thrown out and trampled by men. You are the light of the world. A city on a hill cannot be hidden. Neither do people light a lamp and put it under a bowl. Instead they put it on its stand, and it gives light to everyone in the house. In the same way, let your light shine before men, that they may see your good deeds and praise your Father in heaven (Matthew 5:11-16).
Further support for this reading is suggested by the cultural background. The land of Israel in Jesus' day got its salt from the Dead Sea (called "Salt Sea" in Hebrew). Jesus may therefore have made a critique against the Qumran sectarians who dwelt on the cliffs overlooking the Salt Sea. These separatists referred to their kind as the "sons of light", and they adhered to strict codes of separation from the realm of the "sons of darkness". They not only guarded their religious practices and wisdom (the "Mysteries of God") jealously, but withheld from conducting any sort of dealings with others outside of their sect. The Essenes wanted as much as possible to refrain from becoming encumbered from any burdensome relations with outsiders. Their attitude was to squirrel away into monastic seclusion until the end of the world arrived, when God would use the remaining elect to conquer the world. In the meantime, they would concern themselves only with purifying their minds, bodies and souls, thus vigilantly awaiting the immanent last battle between the sons of light and sons of darkness.
With the analogies to salt and light in Jesus' saying, it is highly plausible that Jesus' audience, familiar with the introverted piety of the Qumran sectarians, would have picked up on a sly dig at the sectarians, realizing he was criticizing the ineffective, in not misanthropic, sectarian strategy of withdrawal from the present problems of the world.
Here are some images that I think reveal the kind of "good deeds" Jesus would magnify: