##Pyth, 20 18 bytes
.Uu:G`CHHsrBG1+bZz
Same algorithm as @Dennis. It's a lot easier to code in Pyth on my phone than in Jelly.
implicit: z=input
.U Reduce the following lambda b, Z over z
b is the string being built; z is the next char
u Reduce the following lambda G,H over +bZ
G is the string, H is the next letter to match
: Replace
G in G
` C H the char code of H
H with H
s rB where H takes on values:
G the lowercase alphabet (that's the global value of G)
1 concatenated to its uppercased self.
+
b
Z
z
Thanks @isaacg
Try it here.