I have read in textbooks (such as Griffiths electrodynamics) that magnetic forces do no work. Then i don't see how a magnetic force does no work when a magnet is attracting or repelling another magnet. Can anybody explain me this?
A magnetic field does not do work on an electric charge because the Lorentz force is always perpendicular to the velocity of a charged particle so that the velocity only changes direction but not absolute value. Thus a charged particle does not gain or lose speed and thus energy while flying in a magnetic field.
You are citing Griffiths regarding the statement that "magnetic forces do no work". Shortly after this statements he also gives a very good explanation why it sometimes seems that magnetic forces do work and what is actually doing the work in such situations.