@@ -1228,15 +1228,15 @@ function is_version_on_rubygems() {
1228
1228
fi
1229
1229
1230
1230
debug " checking rubygem %s at version %s is currently published" " ${name} " " ${version} "
1231
- local cmd_args=()
1231
+ local cmd_args=(" gem " " search " )
1232
1232
if [ -n " ${gemstore} " ]; then
1233
1233
debug " checking rubygem publication at custom source: %s" " ${gemstore} "
1234
1234
cmd_args+=(" --clear-sources" " --source" " ${gemstore} " )
1235
1235
fi
1236
1236
cmd_args+=(" --remote" " --exact" " --all" )
1237
1237
1238
1238
local result
1239
- result=" $( gem search --remote --exact --all " ${name} " ) " ||
1239
+ result=" $( " ${cmd_args[@]} " " ${name} " ) " ||
1240
1240
failure " Failed to retreive remote version list from RubyGems"
1241
1241
local versions=" ${result##* \( } "
1242
1242
local versions=" ${versions%% )* } "
@@ -1278,9 +1278,19 @@ function publish_to_rubygems() {
1278
1278
failure " Path provided does not exist or is not a file (%s)" " ${gem_file} "
1279
1279
fi
1280
1280
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} " ||
1283
1292
failure " Failed to publish RubyGem at '%s' to RubyGems.org" " ${gem_file} "
1293
+ rm -f " ${gem_config} "
1284
1294
}
1285
1295
1286
1296
# Publish gem to the hashigems repository
@@ -1318,12 +1328,12 @@ function publish_to_hashigems() {
1318
1328
pushd " ${tmpdir} "
1319
1329
1320
1330
# 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} " \
1322
1332
" Failed to access hashigems asset bucket"
1323
1333
1324
1334
# Grab our remote metadata. If the file doesn't exist, that is always an error.
1325
1335
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" ./ \
1327
1337
" Failed to retrieve hashigems metadata list"
1328
1338
1329
1339
# Add the new gem to the metadata file
@@ -1337,12 +1347,12 @@ function publish_to_hashigems() {
1337
1347
# Upload the updated repository
1338
1348
pushd ./hashigems
1339
1349
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} " \
1341
1351
" Failed to upload the hashigems repository"
1342
1352
# Store the updated metadata
1343
1353
popd
1344
1354
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" \
1346
1356
" Failed to upload the updated hashigems metadata file"
1347
1357
1348
1358
# Invalidate cloudfront so the new content is available
@@ -1818,7 +1828,7 @@ function github_release_assets() {
1818
1828
local repository_bak=" ${repository} "
1819
1829
repository=" ${repo_owner} /${release_repo} "
1820
1830
1821
- req_args+=(" Content-Type : application/json" )
1831
+ req_args+=(" -H " " Accept : application/vnd.github+ json" )
1822
1832
req_args+=(" https://api.github.com/repos/${repository} /releases/tags/${release_name} " )
1823
1833
1824
1834
debug " fetching release asset list for release %s on %s" " ${release_name} " " ${repository} "
@@ -1842,7 +1852,7 @@ function github_release_assets() {
1842
1852
failure " Failed to detect asset in release (${release_name} ) for ${release_repo} "
1843
1853
1844
1854
req_args=()
1845
- req_args+=(" Accept: application/octet-stream" )
1855
+ req_args+=(" -H " " Accept: application/octet-stream" )
1846
1856
1847
1857
local assets asset_names
1848
1858
readarray -t assets < <( printf " %s" " ${asset_list} " )
@@ -2410,15 +2420,15 @@ function github_delete_release() {
2410
2420
repository=" ${repo_owner} /${release_repo} "
2411
2421
2412
2422
# Fetch the release first
2413
- local release
2414
- release =" $( github_request \
2423
+ local release_content
2424
+ release_content =" $( github_request \
2415
2425
-H " Accept: application/vnd.github+json" \
2416
2426
" https://api.github.com/repos/${repository} /releases/tags/${release_name} " ) " ||
2417
2427
failure " Failed to fetch release information for '${release_name} ' in ${repository} "
2418
2428
2419
2429
# Get the release id to reference in delete request
2420
2430
local rel_id
2421
- rel_id=" $( jq -r ' .id' <( printf " %s" " ${release } " ) ) " ||
2431
+ rel_id=" $( jq -r ' .id' <( printf " %s" " ${release_content } " ) ) " ||
2422
2432
failure " Failed to read release id for '${release_name} ' in ${repository} "
2423
2433
2424
2434
debug " deleting github release '${release_name} ' in ${repository} with id ${rel_id} "
0 commit comments