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. When the hydrogen in the core is exhausted, the star gets bigger and more luminous as hydrogen burns vigorously in a shell about the core. According to this kind of stellar model, here is where we are now. .