In this paper we propose a simple method for generating short-length rate-compatible codes over $mathbb{Z}_M$ that are robust to non-coherent detection for $M$-PSK constellations. First, a greedy algorithm is used to construct a family of rotationally invariant codes for a given constellation. Then, by properly modifying such codes we obtain codes that are robust to non-coherent detection. We briefly discuss the optimality of the constructed codes for special cases of BPSK and QPSK constellations. Our method provides an upper bound for the length of optimal codes with a given desired non-coherent distance. We also derive a simple asymptotic upper bound on the frame error rate (FER) of such codes and provide the simulation results for a selected set of proposed codes. Finally, we briefly discuss the problem of designing binary codes that are robust to non-coherent detection for QPSK constellation.