A bit longer ago than 7 -8 years but this sounds a lot like the 2001 film Impostor with Gary Sinise.
Points that match:
it's a sci-fi movie but not with aliens like we know:
The movie takes place in the year 2079. Forty-five years earlier, Earth was attacked by a hostile and implacable alien civilization from Alpha Centauri.
-- actually I don't remember any alien.
The Centaurians have never been physically seen.
He is like someone that works in security for the government
Gary Sinise plays Spencer Olham, a designer of top secret government weapons
and has been called for duty because of some suspicious things that happens.
The ESA intercepted an alien transmission which cryptanalysts decoded as programming Olham's target to be the Chancellor, whom he was scheduled to meet.
There's a big part in this movie where he is in some kind of a chase in some city underground & there's a scene where he meet some man that helps him.
As he's about to drill out his chest to find the bomb, Olham breaks loose and escapes, accidentally killing his friend Nelson in the process. With the help of underground stalker Cale, Olham avoids capture and sneaks into the hospital where his wife Maya is an administrator.
In the end of the movie, there's some twist
when he finds out that the aliens fooled him & made him one of them.
In Impostor
such replicants are perfect biological copies of existing humans, complete with transplanted memories, and do not know they are replicants. Each has a powerful "u-bomb" in their chest, which can only be detected by dissection or a high-tech medical scan, since it only assembles itself when it gets in proximity to its target. Detection via the special scan works by comparing against a previous scan, if there was one.
and
At that moment, Olham realizes aloud that he really is a replicant,
Finally you indicated
just a few seconds after he realize that he understands that and simultaneously he understands that Earth is going to be destroyed in a few seconds and that's how the movie ends.
and in the movie not quite as widespread as you indicated but
the secondary trigger (his awareness of what he truly is) detonates his u-bomb, destroying himself, Hathaway, his troops, and everything else in a wide area, in a fiery nuclear explosion.