Both are correct.
In (1) half a mile = half of a mile.
In (2) a half mile = a half-mile. "half mile" or "half-mile" is a compound noun meaning a distance unit of half a mile". if "I run a mile every day" is correct, so is "I run a half mile every day", as both "mile" and "half mile" are measurement units of distance.