Modify a file in main before creating tag in release

Is there any way to modify a file then commit that to main BEFORE the tag gets created when creating a release using github actions. What I am trying to do is when you create a release and specify a tag, I would like to update the version in a file to that tag version, THEN create the tag from main and then the release. I have something working now that modifies the file in main and creates the release, but because the tag is created before the action is run, the file is not updated with the new version in the actual tag. Anyone know of a good way to do this?

I am currently triggering the action on the event:

on:
  release:
     types: [created]