I ran into the same issue and also updated the rights but didn't get it to work.
I fixed it with exporting it locally first and then using altool to upload it.
For xcodebuild -exportArchive you'd need to do the following
Set the export option plist destination to export
add -exportPath <your preferred ipa folder> to the command
Validate or Upload
xcrun altool --validate-app/--upload-app -f <ipa-folder/ipa-file.ipa> -t iOS --apiIssuer ... --apiKey ...
altool wants a key file stored in the folder where its executed from: private_keys/AuthKey_<keyid>.p8
if you use github action and secrets, setting up the key could look like this:
echo "${{ secrets.<idToYourStoredKeyContent> }}" > ${{ format('private_keys/AuthKey_{0}.p8', secrets.<idToYourStoredKeyId>) }}