He does both-He carries out the terms of the covenant with undeviating fidelity. God acts according to law. He is lawful and just when He punishes. He is lawful and just when He saves. This is what the covenantal character of His acts means.
Scholars generally agree that the word righteousness is a strongly forensic or legal word.
It is also a covenantal word. It means fidelity to the terms of the covenant. We could even say that righteousness means covenantal justice. Whatever God does, He upholds the law and sees that justice prevails. The righteousness of God is displayed both in His punishing acts and in His saving acts.