How to have dynamic version name at run time when deploying google app engine in Travis CI?

148 Views Asked by At

I am studying to automate the build and deployment of my google app engine application in Travis, so far it allows me to have static or predefined version name during deployment in .travis.yml.

Is there any way to make it dynamically generated at runtime? Like for example below in my .travis.yml file, I have deployment for production and staging version of the application, both are named or labeled as production and qa-staging, and I would like to suffix the version names with a timestamp or anything as long as it would be unique every successful build and deployment.

language: node_js
node_js:
- "10"

before_install:
- openssl aes-256-cbc -K $encrypted_c423808ed406_key -iv $encrypted_c423808ed406_iv
  -in gae-creds.json.enc -out gae-creds.json -d
- chmod +x test.sh
- cat gae-creds.json

install:
- npm install

script:
- "./test.sh"

deploy:
  - provider: gae
    skip_cleanup: true
    keyfile: gae-creds.json
    project: traviscicd
    no_promote: true
    version: qa-staging
    on:
      branch: staging
  - provider: gae
    skip_cleanup: true
    keyfile: gae-creds.json
    project: traviscicd
    version: production
    on:
      branch: master
2

There are 2 best solutions below

0
On

Perhaps you can use go generate to generate a version string that can be included? You need to run go generate as part of the build process for it to work, though.

0
On

Have you tried with https://yaml.org/type/timestamp.html ?

Im not sure if the context is the correct but seems a good and elegant option for your yaml file.