Former Swansea City striker and Premier League cult hero Bafetimbi Gomis has announced his retirement from football aged 39.