Do the `curl` bit on launcher promotions, too
@@ -18,7 +18,29 @@ promote_from_one_channel_to_another() {
artifact="$(latest_from_builder "${target}" "${from_channel}" "${package_name}")"
echo "--- Promoting ${artifact} (${target}) to ${to_channel}"
- hab pkg promote --auth="${HAB_AUTH_TOKEN}" "${artifact}" "${to_channel}"
+ # TODO: after 0.79.0 we can reenable this. We are explicitly using curl to upload
+ # due to this bug: https://github.com/habitat-sh/builder/issues/940
+ # hab pkg promote --auth="${HAB_AUTH_TOKEN}" "${artifact}" "${to_channel}"
+
+ # Create the channel, if necessary.
+ #
+ # Don't use --fail here, because trying to create a channel that
+ # already exists returns a 409, and we don't want to fail in that case.
+ curl --request POST \
+ --header "Authorization: Bearer $HAB_AUTH_TOKEN" \
+ --verbose \
+ "https://bldr.habitat.sh/v1/depot/channels/core/${to_channel}"
+
+ # Extract the individual bits of the fully-qualified identifier we
+ # just retrieved.
+ IFS="/" read -r _ _ version release <<< "${artifact}"
+
+ # Promote the uploaded package into the channel.
+ curl --request PUT \
+ --header "Authorization: Bearer $HAB_AUTH_TOKEN" \
+ --fail \
+ --verbose \
+ "https://bldr.habitat.sh/v1/depot/channels/core/${to_channel}/pkgs/${package_name}/${version}/${release}/promote?&target=${target}"
}
launcher_action=$(buildkite-agent meta-data get "launcher-action");
