Skip to content

Commit

Permalink
Merge pull request #6621 from habitat-sh/sm/fix-promotion
Browse files Browse the repository at this point in the history
Fix release promotion
  • Loading branch information
smacfarlane authored Jun 5, 2019
2 parents 2ac6098 + a3caefc commit c39dcb7
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .buildkite/finish_release_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ steps:
command: .buildkite/scripts/promote_release_channel.sh builder-live
agents:
queue: habitat-release
env:
BUILD_PKG_TARGET: "x86_64-linux"

- block: ":habicat: Ensure that Builder is stable on the new release"
prompt: |
Expand All @@ -22,6 +24,8 @@ steps:
command: .buildkite/scripts/promote_release_channel.sh stable
agents:
queue: habitat-release
env:
BUILD_PKG_TARGET: "x86_64-linux"

- wait

Expand Down
2 changes: 2 additions & 0 deletions .buildkite/release_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ steps:
command: .buildkite/scripts/resolve_launcher_actions.sh
agents:
queue: habitat-release
env:
BUILD_PKG_TARGET: "x86_64-linux"

# New Launcher build steps are automatically added here, if applicable.

Expand Down
3 changes: 3 additions & 0 deletions .buildkite/scripts/build_component.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ Push-Location "C:\build"

Write-Host "Running hab pkg upload for $Component to channel $ReleaseChannel"
Invoke-Expression "$baseHabExe pkg upload results\$pkg_artifact --channel=$ReleaseChannel"
Invoke-Expression "buildkite-agent meta-data set ${pkg_ident}-x86_64-windows true"



If ($Component -eq 'hab') {
Write-Host "--- :buildkite: Recording metadata $pkg_ident"
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/scripts/build_component.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ ${hab_binary} pkg upload \
--auth="${HAB_AUTH_TOKEN}" \
"results/${pkg_artifact:-}"

set_target_metadata "${pkg_ident}" "${pkg_target}"

echo "--- :writing_hand: Recording Build Metadata"
case "${component}" in
"hab")
Expand Down
20 changes: 18 additions & 2 deletions .buildkite/scripts/promote_release_channel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ source .buildkite/scripts/shared.sh
to_channel=${1}
from_channel=$(get_release_channel)

set_hab_binary

echo "--- :thinking_face: Determining which channel to promote to"
if is_fake_release; then
echo "This isn't a \"real\" release!"
Expand Down Expand Up @@ -94,13 +96,27 @@ targets=("x86_64-linux"

for pkg in "${non_supervisor_packages[@]}"; do
echo "--- :habicat: Promoting '$pkg' to '$to_channel'"
hab pkg promote --auth="${HAB_AUTH_TOKEN}" "${pkg}" "${to_channel}" "${pkg_target}"
for target in "${targets[@]}"; do
if ident_has_target "${pkg}" "${target}"; then
echo "--- :star: Found a match: ${pkg} is for ${target}"
${hab_binary} pkg promote --auth="${HAB_AUTH_TOKEN}" "${pkg}" "${to_channel}" "${target}"
else
echo "--- :thumbsdown: not a match"
fi
done
done

echo "--- :warning: PROMOTING SUPERVISORS TO '$to_channel' :warning:"
for pkg in "${supervisor_packages[@]}"; do
echo "--- :habicat: Promoting $pkg to $to_channel"
hab pkg promote --auth="${HAB_AUTH_TOKEN}" "${pkg}" "${to_channel}" "${pkg_target}"
for target in "${targets[@]}"; do
if ident_has_target "${pkg}" "${target}"; then
echo "--- :star: Found a match: ${pkg} is for ${target}"
${hab_binary} pkg promote --auth="${HAB_AUTH_TOKEN}" "${pkg}" "${to_channel}" "${target}"
else
echo "--- :thumbsdown: not a match"
fi
done
done

buildkite-agent annotate --style="success" --context="release-manifest"
Expand Down
6 changes: 5 additions & 1 deletion .buildkite/scripts/resolve_launcher_actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ promote_from_one_channel_to_another() {
to_channel="${4}" # e.g. "rc-0.75.0"

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}" "${target}"
${hab_binary} pkg promote --auth="${HAB_AUTH_TOKEN}" "${artifact}" "${to_channel}" "${target}"
set_target_metadata "${artifact}" "${target}"
}

launcher_action=$(buildkite-agent meta-data get "launcher-action");
Expand All @@ -28,12 +30,14 @@ case "${launcher_action}" in
buildkite-agent pipeline upload .buildkite/launcher_build_steps.yaml
;;
"use-stable-launcher")
set_hab_binary
release_channel=$(get_release_channel)
echo "--- Adding stable Launcher artifacts to channel '${release_channel}'"
# We don't build the launcher on macOS
launcher_platforms=("x86_64-linux"
"x86_64-linux-kernel2"
"x86_64-windows")


for target in "${launcher_platforms[@]}"; do
promote_from_one_channel_to_another "${target}" "hab-launcher" "stable" "${release_channel}"
Expand Down
26 changes: 26 additions & 0 deletions .buildkite/scripts/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,29 @@ set_version() {
local version=$1
buildkite-agent meta-data set "version" "${version}"
}

# Until we can reliably deal with packages that have the same
# identifier, but different target, we'll track the information in
# Buildkite metadata.
#
# Each time we put a package into our release channel, we'll record
# what target it was built for.
set_target_metadata() {
package_ident="${1}"
target="${2}"

echo "--- :partyparrot: Setting target metadata for '${package_ident}' (${target})"
buildkite-agent meta-data set "${package_ident}-${target}" "true"
}

# When we do the final promotions, we need to know the target of each
# package in order to properly get the promotion done. If Buildkite metadata for
# an ident/target pair exists, then that means that's a valid
# combination, and we can use the target in the promotion call.
ident_has_target() {
package_ident="${1}"
target="${2}"

echo "--- :partyparrot: Checking target metadata for '${package_ident}' (${target})"
buildkite-agent meta-data exists "${package_ident}-${target}"
}

0 comments on commit c39dcb7

Please sign in to comment.