@@ -1228,15 +1228,15 @@ function is_version_on_rubygems() {
12281228 fi
12291229
12301230 debug " checking rubygem %s at version %s is currently published" " ${name} " " ${version} "
1231- local cmd_args=()
1231+ local cmd_args=(" gem " " search " )
12321232 if [ -n " ${gemstore} " ]; then
12331233 debug " checking rubygem publication at custom source: %s" " ${gemstore} "
12341234 cmd_args+=(" --clear-sources" " --source" " ${gemstore} " )
12351235 fi
12361236 cmd_args+=(" --remote" " --exact" " --all" )
12371237
12381238 local result
1239- result=" $( gem search --remote --exact --all " ${name} " ) " ||
1239+ result=" $( " ${cmd_args[@]} " " ${name} " ) " ||
12401240 failure " Failed to retreive remote version list from RubyGems"
12411241 local versions=" ${result##* \( } "
12421242 local versions=" ${versions%% )* } "
@@ -1278,9 +1278,19 @@ function publish_to_rubygems() {
12781278 failure " Path provided does not exist or is not a file (%s)" " ${gem_file} "
12791279 fi
12801280
1281- export GEM_HOST_API_KEY=" ${RUBYGEMS_API_KEY} "
1282- wrap gem push " ${gem_file} " ||
1281+ # NOTE: Newer versions of rubygems support setting the
1282+ # api key via the GEM_HOST_API_KEY environment
1283+ # variable. Config file is still used so that older
1284+ # versions can be used for doing pushes.
1285+ gem_config=" $( mktemp -p ./) " ||
1286+ failure " Could not create gem configuration file"
1287+ # NOTE: The `--` are required due to the double dash
1288+ # start of the first argument
1289+ printf -- " ---\n:rubygems_api_key: %s\n" " ${RUBYGEMS_API_KEY} " > " ${gem_config} "
1290+
1291+ gem push --config-file " ${gem_config} " " ${gem_file} " ||
12831292 failure " Failed to publish RubyGem at '%s' to RubyGems.org" " ${gem_file} "
1293+ rm -f " ${gem_config} "
12841294}
12851295
12861296# Publish gem to the hashigems repository
@@ -1318,12 +1328,12 @@ function publish_to_hashigems() {
13181328 pushd " ${tmpdir} "
13191329
13201330 # Run quick test to ensure bucket is accessible
1321- wrap aws s3 ls " ${HASHIGEMS_METADATA_BUCKET} " \
1331+ wrap aws s3 ls " s3:// ${HASHIGEMS_METADATA_BUCKET} " \
13221332 " Failed to access hashigems asset bucket"
13231333
13241334 # Grab our remote metadata. If the file doesn't exist, that is always an error.
13251335 debug " fetching hashigems metadata file from %s" " ${HASHIGEMS_METADATA_BUCKET} "
1326- wrap aws s3 cp " ${HASHIGEMS_METADATA_BUCKET} /vagrant-rubygems.list" ./ \
1336+ wrap aws s3 cp " s3:// ${HASHIGEMS_METADATA_BUCKET} /vagrant-rubygems.list" ./ \
13271337 " Failed to retrieve hashigems metadata list"
13281338
13291339 # Add the new gem to the metadata file
@@ -1337,12 +1347,12 @@ function publish_to_hashigems() {
13371347 # Upload the updated repository
13381348 pushd ./hashigems
13391349 debug " uploading new hashigems repository content to %s" " ${HASHIGEMS_PUBLIC_BUCKET} "
1340- wrap_stream aws s3 sync . " ${HASHIGEMS_PUBLIC_BUCKET} " \
1350+ wrap_stream aws s3 sync . " s3:// ${HASHIGEMS_PUBLIC_BUCKET} " \
13411351 " Failed to upload the hashigems repository"
13421352 # Store the updated metadata
13431353 popd
13441354 debug " uploading updated hashigems metadata file to %s" " ${HASHIGEMS_METADATA_BUCKET} "
1345- wrap_stream aws s3 cp vagrant-rubygems.list " ${HASHIGEMS_METADATA_BUCKET} /vagrant-rubygems.list" \
1355+ wrap_stream aws s3 cp vagrant-rubygems.list " s3:// ${HASHIGEMS_METADATA_BUCKET} /vagrant-rubygems.list" \
13461356 " Failed to upload the updated hashigems metadata file"
13471357
13481358 # Invalidate cloudfront so the new content is available
@@ -1818,7 +1828,7 @@ function github_release_assets() {
18181828 local repository_bak=" ${repository} "
18191829 repository=" ${repo_owner} /${release_repo} "
18201830
1821- req_args+=(" Content-Type : application/json" )
1831+ req_args+=(" -H " " Accept : application/vnd.github+ json" )
18221832 req_args+=(" https://api.github.com/repos/${repository} /releases/tags/${release_name} " )
18231833
18241834 debug " fetching release asset list for release %s on %s" " ${release_name} " " ${repository} "
@@ -1842,7 +1852,7 @@ function github_release_assets() {
18421852 failure " Failed to detect asset in release (${release_name} ) for ${release_repo} "
18431853
18441854 req_args=()
1845- req_args+=(" Accept: application/octet-stream" )
1855+ req_args+=(" -H " " Accept: application/octet-stream" )
18461856
18471857 local assets asset_names
18481858 readarray -t assets < <( printf " %s" " ${asset_list} " )
@@ -2410,15 +2420,15 @@ function github_delete_release() {
24102420 repository=" ${repo_owner} /${release_repo} "
24112421
24122422 # Fetch the release first
2413- local release
2414- release =" $( github_request \
2423+ local release_content
2424+ release_content =" $( github_request \
24152425 -H " Accept: application/vnd.github+json" \
24162426 " https://api.github.com/repos/${repository} /releases/tags/${release_name} " ) " ||
24172427 failure " Failed to fetch release information for '${release_name} ' in ${repository} "
24182428
24192429 # Get the release id to reference in delete request
24202430 local rel_id
2421- rel_id=" $( jq -r ' .id' <( printf " %s" " ${release } " ) ) " ||
2431+ rel_id=" $( jq -r ' .id' <( printf " %s" " ${release_content } " ) ) " ||
24222432 failure " Failed to read release id for '${release_name} ' in ${repository} "
24232433
24242434 debug " deleting github release '${release_name} ' in ${repository} with id ${rel_id} "
0 commit comments