Every time I push my app to heroku I see the line
-----> Launching... done, v43
Is there a way to make that version number apear within the
Following @jassa answer - but using the more recent PlatformAPI
if (app_name = ENV["HEROKU_APP_NAME"]).present? and ENV['HEROKU_API_KEY'].present?
require 'platform-api'
heroku = PlatformAPI.connect(ENV['HEROKU_API_KEY'], default_headers: {'Range' => 'version ..; order=desc'})
released_at_s = heroku.app.info(app_name)['released_at']
released_at_d = Time.parse(released_at_s).strftime('%Y-%m-%d')
release = heroku.release.list(app_name).first
deploy_v = release['description']
version = release['version']
ENV['HEROKU_RELEASE_NAME'] = "#{version} (#{deploy_v}) #{released_at_d}"
end
I am using Codeship so I plan on just adding this to the push config:
heroku config:add HEROKU_RELEASE_VERSION=$(heroku releases | head -2 | awk 'NR==2' | awk '{print $1}')
Note that the other similar answer is invalid since it is grabbing some of the later versions (it uses tail instead of head) and it tries to set it to two versions instead of just one (ie: v100 \n v101
).
AFAIK you can only get the version via the CLI:
heroku releases --app <YOUR_APP_NAME>
You could do this via the Heroku gem from you app, but this is probably more trouble that it's worth.