Once a star is born, it spends its active life somewhere on the main sequence. Its place on the main sequence is determined by its mass. Astronomers make computer models of the evolution of stars. Balance pressure against gravity. Compression of gas raises its temperature.
Heat flows out toward the surface by photon radiation or convection.
If the temperature and pressure are high enough, nuclear fusion occurs. Fusion gradually increases the amount of helium and decreases the amount of hydrogen. The star is on the main sequence. It stays on the main sequence for a long time compared to the time it took for the star to be born. As the hydrogen burns, the star's luminosity increases slowly.