A man who killed another man with a single punch in an "unprovoked attack" outside a pub has been sentenced to three years.