Quality of roasted coffee begin to degrade as soon as it comes out of roasting machine. Preservation of quality is done by filling it in appropriate packaging. A polymer that prevents oxygen entry and subsequent rancidity.
However, packing it immediately is not recommended. Carbon dioxide is still emitting from freshly roasted beans. Prompt packing will cause bulging of plastic and flexible pouches.
Bulging coffee package is common to amateur coffee processors. I have visited several small time processors-sellers and saw several bulged coffee package on their shelves. I asked how they are dealing with it. Their answer was straightforward and simple. Every bulged package is pricked with needle and pressed carefully.
A practical solution for a simple mistake. The tiny and unnoticeable hole allows the exit of accumulated gasses but the atmospheric oxygen can enter freely and cause eventual rancidity.
A better solution. Purchase a packaging material equipped with a one-way valve. It will allow bent off of carbon dioxide while preventing oxygen entry. Packing immediately after roasting may not cause bulging. An excellent solution if budget permits.
Another good feature is a resealable closure. Cut off the top permanent seal. Get coffee. Then press the opening together to seal again and preserve taste and aroma of unused grounds. However, the resealing process is not as good as permanent sealing, not even close. Transferring the contents to a tightly sealed jar is always recommended.