Using the new package version in my build with GitLab CI/CD flow with semantic-release

I want to implement automatic versioning with semantic-release using GitLab CI/CD pipelines. I was previously triggering the automatic versioning (and changelog generation) manually and locally before pushing my changes to origin. This has been working, but I want to take out the manual process and was looking to augment our already existing GitLab pipelines/jobs to do the version bump. The normal flow I have seen in place is to do the release step after the rest of the jobs.

I’m pretty clear on how to set it all up, but I want to use the new version number in my code so I can display it on my site. And to display it on my site, I’m referencing package.json to grab the version number. The problem is if I don’t do the release step until the end of the pipeline, if I want to import (or require) the package.json file, it’ll contain the current version of the package instead of the new version after semantic-release runs. Does anyone have any thoughts on how to do something like this? My only thought at the moment is to do the release job before my build job, which would make sure that package.json contains the new version number before my code is built and packaged up. Is there a better way to do something like this?

Thank you.