I needed to do the same, but with PowerShell instead of Bash. The general method is the same though.
Fetch all tags in case there are new ones:
git fetch --all --tags
Get the latest tag using:
git tag -l --sort=-version:refname | select -first 1
Get the previous tag using:
git tag -l --sort=-version:refname | select -first 2 | select -last 1
Put it together:
git diff $(git tag -l --sort=-version:refname | select -first 1) $(git tag -l --sort=-version:refname | select -first 2 | select -last 1)
My actual example use case:
git fetch --all --tags > $null; git diff tags/$(git tag -l --sort=-version:refname v* | select -first 1) tags/$(git tag -l --sort=-version:refname v* | select -first 2 | select -last 1) --name-only | Select-String -Pattern ".*\.xml" | Write-Host
This will get all remote tags in case there are new ones, redirecting output to $null so it does not show up, get the list of files changed between the most recent tags that start with v, then filter the list of files to only return those that end in .xml