Maybe I was lucky... I have straddled both IC and management and was allowed to move between these freely. I've been an engineer, architect, VP (60+ team), and architect again (we have VP, SVP, EVP level architect roles).
I've also worked in many areas. I've automated physical things like oil refineries, worked business appservers, databases, networking, distributed system, and highly scalable data systems, et al.
Need to stay flexible and open to learning and changing. That is exactly what is so much fun working in software! There is always something new to pick up, some new to learn, something new to figure out. The stuff I'm thinking about now did not exist 5 years ago, and what I will be working on in 5 years likely does not exist, yet. Maybe my roles now are not exactly dev, but definitely IC.
While I had my usual ups and downs during my over 30 years in software, I love what I do and will do this as long as I can.