how to make path for using gameobject in from prefebs

Hello sir, i am learning unity, and found your replies to other questioners very useful for me. i have a problem that i want to make track in front of player using gameobject(for example cubes)and i want to do it through code, don’t want to make track using manual placement,i don’t know how to do this how to place different length cubes side by side accurately. can you guide me. i am doing 2.5D endless runner game.

CreatePrimitive for cubes, this documentation page for anything else.