Setting different values on editor and build

I have an int variable called ID, and I want to create a game where the ID of the player in the editor equals one, the ID of the player in the build equals 2, the ID of the second build equals 3, and so on…

How can I write a script that changes the ID value everytime a new build is created?

What I can think of, that I’ve done in my previous projects, is to create custom MenuItem which does just that. (Loads scene, changes variable, saves scene)
and then starts the build.