The leader of the ACT Greens and former attorney-general Shane Rattenbury has announced he is leaving politics after more than 17 years in the Legislative Assembly.