The Oxford English Dictionary agrees with you that “let the cat out of the bag” means to disclose a secret.
The Oxford English Dictionary cites a 1760 quotation from the London Magazine: “We could have wished that the author … had not let the cat out of the bag.”
Eric Partridge’s A Dictionary of Slang and Unconventional English gives an earlier date, 1750, though it doesn’t provide a source.
Some relate the phrase to a 'cat' referred to is the cat o' nine tails, which was used to flog sailors for disclipine. Again, this has sufficient historical record to be at least possible. The cat o' nine tails was widely used and was referred to in print many years prior to the first use of 'let the cat out of the bag'. The 'nine tails' part of the name derives from the three strands of cord that the whips were made from. When unbraied the whip separated into nine strings. The 'cat' part no doubt alluded to the scratches that the knotted ends of the lash made on the sailor's back, like those from a cat's claws.
The American Heritage Dictionary of Idioms agrees with the Brewer’s explanation. It dates “let the cat out of the bag” from the mid-1700s and says:
“This expression alludes to the dishonest practice of a merchant substituting a worthless cat for a valuable pig, which is discovered only when the buyer gets home and opens the bag.”
One would have to be a pretty slow to mistake a cat, no doubt meowing and trying to claw its way out of the bag, for a squealing baby pig. Wouldn’t most people look to see what they were getting for their money?
The word sleuth Michael Quinion doesn’t buy the pig story either. On his website World Wide Words, he says the expression “let the cat out of the bag” does indeed date back to the mid-18th century, but he adds:
“Anybody who has ever kept a live cat in a bag for more than a couple of seconds will know that even the most gullible purchaser would hardly mistake it for a piglet. It may just possibly be that the phrase comes from the explosive exit of a cat from a bag when it’s opened, so suggesting an original connection more with the shock and surprise of the event than of disclosure of the secret itself.”