Outside the Book of Vile Darkness (3.5e), which is vague, there are no official rules for becoming a lich, so this is inherently a matter of homebrew. That said, lets consider what the monster manual says.
When a lich's body is broken by accident or assault, the will and mind
of the lich drains from it, leaving only a lifeless corpse behind.
Within days, a new body reforms next to the lich's phylactery,
coalescing out of glowing smoke that issues from the device.
There's no mention of death there- being beaten up and destroyed is probably fine, and won't trigger the soul loss clause. It's worth reading the fine print.
However, there is a catch.
No wizard takes up the path to lichdom on a whim, and the process of becoming a lich is a well-guarded secret. Wizards that seek lichdom must make bargains with fiends, evil gods, or other foul entities. Many turn to Orcus, Demon Prince of Undeath, whose power has created countless liches. However, those that control the power of lichdom always demand fealty and service for their knowledge.
Becoming a lich may mean swearing fealty to an existing great power, which may prevent you from making a deal with the devil, or may supersede your existing deal. You could try to pull a John Constantine, and have both desire your soul and fight over it, but I am uncertain how reliable that plan is.
That said, if you're powerful enough to become a lich, there are safer ways to do this, like the clone spell.
This spell grows an inert duplicate of a living creature as a
safeguard against death. This clone forms inside as a sealed vessel
and grows to full size and maturity after 120 days you can also choose
to have the clone be a younger version of the same creature. It
remains inert and endures indefinitely, as long as its vessel remains
undisturbed.
At any time after the clone matures, if the original creature dies,
its soul transfers to the clone, provided that the soul is free and
willing to return.
Just convince the demon that you intend to do many dark and terrible deals with it in the future, and make sure the contract allows the use of cloning.
You should ask if your DM is willing to import some previous edition types of lich, like the archlich (a good aligned lich). Depending on your alignment, this may be a step to far, since if you're making a deal with the devil you're a bit sketchy to start with. Archlichdom does not require deals with demons.