Like the Sun, most stars have lifetimes of several billion years during which they steadily fuse hydrogen into helium. For a short period at the end of their lives, these stars burn helium to carbon (element 6) and sometimes oxygen (element 8). These kinds of reactions have been a constant source of new elements since the first stars formed not long after the Big Bang.
In some cases, such as a pulsing red giant star near the end of its life, the light elements are converted more quickly into elements much heavier than carbon or oxygen. This likely happens as the red giant gradually loses its outer layers and evolves to become a white dwarf; we think it takes several periods, each a few hundred years long.
Supernovae produce lots of new elements in just a few minutes or even seconds. The helium, oxygen, and other atoms used as fuel to burn into heavier atoms are already there — ready to ignite as the temperature rapidly increases when the outer layers of the dying star collapse. The sequence may run from iron (element 26) to uranium (element 92) and beyond in about 1 second. — Ian Roederer, Carnegie Observatories, Pasadena, California