We studied the efficiency of two different schemes for a quantum heat engine, by considering a single Dirac particle trapped in an infinite one-dimensional potential well as the "working substance." The first scheme is a cycle, composed of two adiabatic and two isoenergetic reversible trajectories in configuration space. The trajectories are driven by a quasistatic deformation of the potential well due to an external applied force. The second scheme is a variant of the former, where isoenergetic trajectories are replaced by isothermal ones, along which the system is in contact with macroscopic thermostats. This second scheme constitutes a quantum analog of the classical Carnot cycle. Our expressions, as obtained from the Dirac single-particle spectrum, converge in the nonrelativistic limit to some of the existing results in the literature for the Schrödinger spectrum.