I was having the same issue but then I found a solution.
Instead of running only 1 command like you were trying to do (productbuild --component "$appDir" "/Applications" --scripts "../Scripts" --sign "Developer ID Installer: $DEVNAME" "$appName.pkg")
I now run 3 commands:
1: pkgbuild --root "MyApp.app" --identifier com.my.app --sign "Developer ID Installer: $DEVNAME" --scripts Scripts --install-location "/Applications/MyApp.app" Distribution.pkg
2: productbuild --synthesize --package Distribution.pkg Distribution.xml
3: productbuild --distribution Distribution.xml --sign "Developer ID Installer: $DEVNAME" --resources Resources --package-path . MyApp.pkg
Then when I run MyApp.pkg the installer runs the postinstall script opening the app.
Note: I have the postinstall file without extension.