Can you draw a weapon as part of a spell attack?

This is inspired by the following question which seems to only ask about steel wind strike, while this question is more general:

  • Can I draw a weapon as a part of a Melee Spell Attack?

The rules on "Other Activity on Your Turn" state (emphasis mine):

[…] You can also interact with one object or feature of the environment for free, during either your move or your action. For example, you could open a door during your move as you stride toward a foe, or you could draw your weapon as part of the same action you use to attack. […]

Similarly, the rules on the "Use an Object" action state (emphasis mine):

You normally interact with an object while doing something else, such as when you draw a sword as part of an attack. When an object requires your action for its use, you take the Use an Object action. […]

However, what if you cast a spell such as fire bolt, which involves making an attack; can you draw a weapon while performing this attack?