After I saw your response, I spent some time looking at lists of Golden Age comic book superheroes from various companies. I couldn't remember, right away, if any DC or Marvel (or Fawcett or Quality) heroes from that era had started out with secret identities and then later "went public" regarding their real names, but I figured seeing lists of their names might jog my memory.
As I looked at a DC Golden Age Heroes list, I suddenly remembered something about DC's first Robotman character. (They've reused the name since then.) So I did a little online research to pin down certain details.
The original Robotman first appeared in Star-Spangled Comics #7 (April, 1942), in a story written by Jerry Siegel. (The same writer who had co-created Superman, years earlier.)
Here's the basic origin story: Brilliant scientist Robert Crane, with the help of his friend and lab assistant, Chuck Grayson, is working hard on a special robot project. The metal body was meant as a sort of life-support system for worst-case scenarios. In other words, if someone were so badly injured that his body was dying from massive trauma, but his brain was still in good shape, then the human brain could hastily be removed from the man's skull and transplanted inside the metal head of the robot, where special equipment would, in theory, keep that brain alive and well, indefinitely, while allowing it to start directing the robot body the same way it used to direct the flesh-and-blood body it had been born with.
(You see it coming, don't you?)
One night, just as Robert and Chuck had been putting on the finishing touches for their prototype, a gang of criminals broke into their lab to steal the valuable robot. Robert refused to cooperate with them, and was fatally wounded by gunfire. The criminals then ran away, leaving Chuck to quickly remove his boss's brain and insert it into the robot body in an attempt to save Robert's life.
So that was their first field test . . . and everything worked exactly the way it was supposed to!
For the next several months, "Robotman" (as Robert Crane started calling himself) was using his new super-strong, bulletproof body to fight crime . . . but most people thought he was literally just a robot, instead of "a real person." One reason they thought this was because Robotman didn't say anything to contradict the idea. For some reason, he was keeping the "Robert Crane" part secret, even though he no longer used that identity.
The truth came out eight issues later, in a story titled "The Trial of Robotman" (also written by Jerry Siegel), published in Star-Spangled Comics #15 (December, 1942). A lawyer named Sam Slattery dragged Robotman into court, insisting that Robotman was just a big hunk of valuable equipment which belonged to the estate of his deceased creator, the brilliant scientist Dr. Robert Crane. (I believe Robert's battered corpse had been found by the police in that lab after the criminal assault, and had received a nice funeral. So, in the eyes of the law, Robert was dead.)
Robotman finally realized he had to come clean in order to be treated as a real person. He admitted he was, in fact, Robert Crane's brain stored in an artifical body. So that fact went onto the public record.
However! Robotman did not reveal the fact that he had been experimenting with another secret identity. By pulling a latex mask over his metal head, and doing something similar with flesh-colored gloves over his metal hands, Robotman could dress up in normal clothes and pass as a regular guy called "Paul Dennis." He apparently kept that a secret (except from a few friends) for the remainder of his Golden Age career.(His last Golden Age story was published in 1953, so his Golden Age run lasted 11 years.)
I haven't read the original version of that story about defending himself in court, but I do own a copy of a retelling of it in All-Star Squadron #17 (January, 1983), written by Roy Thomas.

So let's take inventory from your list of criteria:
Heroes who never had a secret identity don't count (for example the
Fantastic Four)
Robotman actually had two secret identities -- his old one, and his new one. He only publicly revealed the old one (which he wasn't really using any more, now that he no longer possesed that face and body).
They have to make it public, so giving away the secret to a few people
does not count
He testified in court about his old secret identity -- that certainly made it public!
They have to reveal it by themselves, so if a villain makes it public
it does not count
Robotman was under pressure (because he wanted the court to agree that he was a person with all the usual civil rights, instead of just property), but he did, in fact, choose to reveal that he'd been born and raised as Robert Crane, instead of having someone else disclose the information.
I am only interested in heroes from either DC or Marvel
Robotman is a DC character.
So the question is: Does it really count, the way you look at it, if he only publicly revealed a secret identity which, while it was the name on his birth certificate, the real name he'd used for the first twenty-odd years (or however old he was), was not the other secret identity he actually intended to use for the remainder of his superheroic career so that he could have some privacy when he wasn't out fighting crime?
Only you can answer that question. I won't get mad if you decide the answer is: "Nope! Close, but no cigar!" :-)