Except as otherwise provided by law, no defendant charged in a warrant of arrest with any public offense shall be discharged from custody upon bail except upon a written order of a competent court or magistrate admitting the defendant to bail in the amount specified in the indorsement referred to in Section 815a, and where an undertaking is furnished, upon a written order of such court or magistrate approving the undertaking. All such orders must be signed by such court or magistrate and delivered to the officer having custody of the defendant before the defendant is released. Any officer releasing any defendant upon bail otherwise than as herein provided shall be guilty of a misdemeanor.
Ca. Pen. Code § 1269a