Gitlab CI release get version from a file

I tried the following release configuration:

release_version:
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  needs:
    - artifacts: false
      job: registry_upload
  release:
    description: release of version ${VERSION_NUMBER} of my_package
    ref: ${CI_COMMIT_SHORT_SHA}
    tag_name: v${VERSION_NUMBER}
  script:
    - VERSION_NUMBER=$(grep -E -o "[0-9]+?\.[0-9]+?\.[0-9]+?" ${CI_PROJECT_DIRECTORY}/my_package/src/version.py)
    - echo ${VERSION_NUMBER}

This does release successfully, but VERSION_NUMBER variable is missing for release part, i.e. description became “release of version of custom package”.

How can I set a variable from a file and persist it for release part?

(Cross-posted at Get version from a file for release job in GitLab CI - Stack Overflow)