Long Answer Short: Vampires, and careful planning.
Seeing as that the next "runner up" in terms of undeath and reanimation (via Create Undead) is a Ghoul (MM p. 148) , you likely would not be able to remain in control of yourself if you were to become one.
Your only hope in the situation of becoming a Ghoul would be praying something like the following happens:
(MM p. 148 : Ghasts) Orcus sometimes infuses a ghoul with a stronger dose of abyssal energy, making a ghast. Whereas ghouls are little more than savage beasts, a ghast is cunning and can inspire a pack of ghouls to follow its commands.
One who is hopeful enough toward Orcus' boons might hope that enough abyssal energy would maintain some semblance of sentience in their person. But whichever way that goes, you still become a very smelly and unsavory type of undead.
That being said,
A vampire would likely be your best bet, as you not only become much more powerful, but you are essentially undead, and maintain your intellect almost entirely intact. The same can't be said of your humanity, of course:
(MM p. 295 : Dark Desires) Whether or not a vampire retains any memories from its former life, its emotional attachments wither as once-pure feelings become twisted by undeath. Love turns into hungry obsession, while friendship becomes bitter jealousy. In place of emotion, vampires pursue physical symbols of what they crave, so that a vampire seeking love might fixate on a young beauty. etc...
If that is all peachy with you, then you have to figure out how to become one... Namely, finding a vampire who is honest enough to turn you into a Vampire Spawn, and then let you feed off of their own blood. Otherwise you could just get turned into the equivalent of a powerful ghoul and be stuck in servitude for ever. Luckily, vampires are lawful evil by default. So perhaps drafting a contract could seal the deal, or arranging some other method of trade in order to secure your own vampirism? Regardless, the rules for a player character as a vampire are as follows:
(MM p. 295 : Player Characters as Vampires) The character's Strength, Dexterity, and Constitution scores become 18 if they aren't higher. In addition, the character gains the vampire's damage resistances, darkvision, traits, and actions. Attack and damage rolls for the vampire's attacks are based on Strength. The save DC for Charm is 8 + the vampire's proficiency bonus+ the vampire's Charisma modifier. The character's alignment becomes lawful evil, and the DM might take control of the character until the vampirism is reversed with a wish spell or the character is killed and brought back to life.
What's that? You don't want to lose control of yourself, or become evil? Not a problem, you need only locate a Helm of Opposite Alignment to keep yourself on a "righteous" path. Best of luck finding one, of course, let alone subjecting yourself to it at the right moment. Also, convincing a vampire to convert you to one and then becoming potentially Good-aligned is probably not something any vampire will want to do to begin with.
With that out of the way, here's why you can't use Contingency.
Contingency - 6th level Evocation : Choose a spell of 5th level or lower that you can cast, that has a casting time of 1 action.
Firstly, Create Undead has a casting time of One minute. Secondly, Create Undead is a 6th level spell. So that is physically impossible to do from the getgo.
The only resurrecting spell you can use this with is Revivify, since it is level 3, and has a casting time of 1 action.