How can I animate a stroke around a rectangle?

It’s a simple idea I’m trying to wrap my head around, an animation that draws itself around a rectangle by using smart animate within Figma.

The rectangle begins without a stroke, then the stroke starts filling around the border until it fills a full circle and returns to the beginning where it started autofilling.

Simple, but I couldn’t execute it.

I tried masks, but it didn’t work.

I know it’s supposed to be easy but I’ll love to hear some ideas.

Thanks in advance!