How to manage Releases for JavaScript projects with Scripting

I’m trying to piece together scripts to automate the deployment of several Angular (Typescript) projects. My understanding is that I have to get the release number into the source code when I build the project, and that release number is based on a hash generated sentry-cli (which is based on the Git commit SHA). So right now my process is to commit my code, and then run the following script:
VERSION=`sentry-cli releases propose-version`

echo -e "export const RELEASE = '$VERSION';" > src/environments/release.ts

This writes the release number to a TS file so it gets incorporated into the build. After that I use sentry-cli to to make a new release with the --finalize flag (I’m still not clear from the docs when I wouldn’t add the --finalize flag), upload the sourcemaps, and deploy the release. I have two (somewhat related) questions:

  1. Is this an acceptable/good way to do what I’m trying to do (which is just to create releases that line up with correct source maps)? As a new and inexperienced dev, I feel a little weird about my build depending on a file that I generate at build-time, but maybe that’s just par for the modern devops course these days.

  2. This setup took a fair bit of experimentation - is there documentation that I just flat-out missed (very possible)? If not, some further instruction in the docs (even it’s just something like “you’ll need to write a script or something to make sure your release number gets into your build”) would assure noob devs like me we’re not wandering off the beaten path.

Thanks a bunch,
Daniel Hines

P.S This is only tangentially related, but if someone wanted to explain when and why to use sentry-cli new --finalize versus sentry-cli finalize VERSION, that would also be helpful.