The whole debacle began when Fox News reported classified details from two anonymous sources about how American intelligence had determined the North Korean military moved anti-ship cruise missiles to a patrol boat.
When asked to comment on the report in a subsequent interview, United Nations Ambassador Nikki Haley wisely declined to discuss the matter. She also condemned whoever had leaked classified intelligence to the media.
Unknown to Haley, however, Trump tweeted the original Fox story, quite possibly because it was discussed on the pro-Trump program "Fox and Friends," which Trump is known to watch live in the Oval Office nearly every day (forget about national business when his favorite show is on).
This, of course, is the same Trump who condemns anonymous sources in any news story about him that he doesn't like. But when he thinks the piece makes him look good, he's more than happy to wave it around for all to see, anonymous sources included.
And, of course, it's the same Trump who has whined endlessly, often on Twitter, about the meanies who keep leaking about his inept actions (which typically are not a crime when no national security secrets are involved). The President still has not learned that his constant fuck-ups are not national security secrets nor classified intelligence.
This is not the first time Trump has recklessly revealed national security secrets. In May, he blabbed top secret information from another government to the Russians, something the foreign intelligence source had specifically mandated not occur as terms for sharing the material.
A current President is the one individual who cannot be prosecuted for leaking national security secrets, as a matter of law, no matter how sensitive.
So while it might not be illegal every time Trump opens his loose lips like this, it certainly isn't prudent nor wise. And it is something that can be used against him in impeachment proceedings, since that is a political and not a legal process.