Running macOS Sierra (10.12) or macOS High Sierra (10.13) on a 21.5" mid 2017 iMac
The mid 2017 21.5" iMac (both Retina 4K and non-retina models) originally shipped with macOS Sierra 10.12.4. Thus, both macOS Sierra and macOS High Sierra have the drivers to run on either one of the iMac's.

It would be possible to run the last (publicly available) release of both macOS Sierra 10.12.6 and macOS High Sierra 10.13.6 on either one of the iMac's by installing via USB installer or via Internet recovery.

The installer can use downloaded from the Mac App Store:


macOS Sierra 10.12.6 - Mac App Store
macOS High Sierra 10.13.6 - Mac App Store