Skip to content

Commit 6edd759

Browse files
committed
Make upload task find the version automatically
Because ezbake doesn't use the git describe and instead the version is based on a timestamp when the thing was build, this looks up the version/release from the ezbake config to determine what to upload.
1 parent 556a303 commit 6edd759

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tasks/upload.rake

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace :vox do
22
desc 'Upload artifacts from the output directory to S3. Requires the AWS CLI to be installed and configured appropriately.'
3-
task :upload, [:tag, :platform] do |_, args|
3+
task :upload, [:platform] do |_, args|
44
endpoint = ENV.fetch('ENDPOINT_URL')
55
bucket = ENV.fetch('BUCKET_NAME')
66
component = 'openvox-server'
@@ -14,23 +14,31 @@ namespace :vox do
1414

1515
abort 'You must set the ENDPOINT_URL environment variable to the S3 server you want to upload to.' if endpoint.nil? || endpoint.empty?
1616
abort 'You must set the BUCKET_NAME environment variable to the S3 bucket you are uploading to.' if bucket.nil? || bucket.empty?
17-
abort 'You must provide a tag.' if args[:tag].nil? || args[:tag].empty?
1817

19-
munged_tag = args[:tag].gsub('-', '.')
2018
s3 = "aws s3 --endpoint-url=#{endpoint}"
2119

2220
# Ensure the AWS CLI isn't going to fail with the given parameters
2321
run_command("#{s3} ls s3://#{bucket}/")
2422

25-
glob = "#{__dir__}/../output/**/*#{munged_tag}*"
23+
config = File.expand_path("../target/staging/ezbake.rb", __dir__)
24+
abort "Could not find ezbake config from the build at #{config}" unless File.exist?(config)
25+
load config
26+
version = EZBake::Config.fetch(:version)
27+
release = EZBake::Config.fetch(:release)
28+
# If release is a digit, then we built a tagged version. Otherwise,
29+
# we built a snapshot and want to include that in the path to upload to.
30+
tag = release =~ /^\d{1,2}$/ ? version : "#{version}-#{release}"
31+
32+
33+
glob = "#{__dir__}/../output/**/*#{tag}*"
2634
if os
2735
# "arch" is not used here because it's all noarch
2836
glob += "#{os}*"
2937
end
3038
files = Dir.glob(glob)
3139
abort 'No files for the given tag found in the output directory.' if files.empty?
3240

33-
path = "s3://#{bucket}/#{component}/#{args[:tag]}"
41+
path = "s3://#{bucket}/#{component}/#{tag}"
3442
files.each do |f|
3543
run_command("#{s3} cp #{f} #{path}/#{File.basename(f)}", silent: false)
3644
end

0 commit comments

Comments
 (0)