Begin with downloading CyanogenMod Android 5.1 Lollipop CM12.1 custom ROM with Google Apps on the PC. Next, plug in your HTC One M8 via USB to your PC. Transfer the Android 5.1 custom ROM zip file with the downloaded Google Apps on your phone chip only. Continue by putting the boot.img file on android-sdk-windows platform-tools directory before switching the device off and disconnecting the PC as well. Move over to performing regular Bootloader mode sortie. Once done, click on android-sdk-windows platform-tools on PC to flick open Command prompt. Enter the command ‘fastboot flash boot boot.img.’ Next type in ‘fastboot reboot’ and adhere to displayed instructions. Choose BOOTLOADER and make an entry into Recovery Mode. Wipe off all phone memory using factory reset. Choose ‘wipe cache partition’ next before opting for ClockworkMod recovery > ‘advanced’> ‘wipe dalvik cache.’ After coming back to main screen, tap ‘install zip from SD card.’ Select ‘choose zip from sdcard’ to access Android 5.1 ROM .zip file and enter the process for installation. Perform all the sane steps for Google Apps. Finally select ‘+++++Go Back+++++’ and re-start using ‘reboot system now.’
Wrap up by selecting settings > select about phone and confirm installation of CyanogenMod Android 5.1 Lollipop CM12.1 custom ROM on your HTC One M8.