Rotate an object and move up local z axis at the same time
So what you can do is:


Create your 2 objects. Create an empty where the rotation is supposed to happen. Parent object 1 to the empty, parent object 2 to object 1.





Give object 2 a Copy Transforms constraint with object 1 as Target.