I would like to access my PC remotely without using any dedicated service (i.e. teamviewer) for that. Ideally some installed script installed on this PC would detect if its internet public IP changes and post it anywhere I could grab it. Then I could remotely interact with it (ssh for instance). Is that even possible?
There's an existing system for this: Dynamic DNS.
There shouldn't be any need to roll your own solution.
Personally (a developer answer), I would create a simple react REST API and run that on a cloud server somewhere. (or in PHP if I was being lazy)
This REST API would take in an IP address POSTed to it, update the value, then display to the user on a GET request. Meaning you can easily obtain this IP address when you are external from your network.
Then get your machine to post it's IP address to that REST API endpoint on a timed basis, or when it detects and external IP change. This could be done with a simple cronjob or task schedule.