#!/usr/bin/env ruby

require 'fog'

s = Fog::Storage.new(
  :provider => 'OpenStack',
  :openstack_auth_url => ENV.fetch('OPENSTACK_AUTH_URL'),
  :openstack_username => ENV.fetch('OPENSTACK_USER_NAME'),
  :openstack_api_key  => ENV.fetch('OPENSTACK_API_KEY'),
)

files = Pathname.glob(ENV.fetch('FILE_GLOB'))

if 1 != files.size
  warn "Expect only one FILE_GLOB, but got #{files.size}: #{files}"
  exit 1
end

file = files.first
file_name = file.basename

dir = s.directories.create key: ENV.fetch('REMOTE_FOLDER'), public: true
remote_file = dir.files.create key: file_name.to_s, body: file.open, public: true

puts "Successfully uploaded #{file_name} as #{remote_file.public_url}"

#!/usr/bin/env ruby

require 'fog'

s = Fog::Storage.new(
  :provider => 'OpenStack',
  :openstack_auth_url => ENV.fetch('OPENSTACK_AUTH_URL'),
  :openstack_username => ENV.fetch('OPENSTACK_USER_NAME'),
  :openstack_api_key  => ENV.fetch('OPENSTACK_API_KEY'),
)

files = Pathname.glob(ENV.fetch('FILE_GLOB'))

if 1 != files.size
  warn "Expect only one FILE_GLOB, but got #{files.size}: #{files}"
  exit 1
end

file = files.first
file_name = file.basename

release_version_file = Pathname(ENV.fetch('VERSION_FILE'))
release_version = release_version_file.read.chomp

if release_version.empty?
  warn "Could not find a release version in #{release_version_file}"
  exit 1
end

dir = s.directories.create key: ENV.fetch('REMOTE_FOLDER'), public: true

remote_file = dir.files.create(
  key: (release_version / file_name).to_s,
  body: file.open,
  public: true
)

puts "Successfully uploaded #{file_name} as #{remote_file.public_url}"

Add the release version to name of the published file
Add the release version to name of the published file

[#115144847]

Signed-off-by: Steffen Uhlig <f82265073a33b8214db2ab356bc472f35869736c@de.ibm.com>
