Only run publish-crate on release branches, clarify crate ordering
This commit is contained in:
parent
54fb4e370c
commit
080d18b06e
|
@ -8,6 +8,7 @@ steps:
|
|||
- command: "ci/publish-crate.sh"
|
||||
timeout_in_minutes: 20
|
||||
name: "publish crate [public]"
|
||||
branches: "!master"
|
||||
- command: "ci/publish-bpf-sdk.sh"
|
||||
timeout_in_minutes: 5
|
||||
name: "publish bpf sdk"
|
||||
|
|
|
@ -1,29 +1,51 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
if [[ -z "$BUILDKITE_TAG" && -z "$TRIGGERED_BUILDKITE_TAG" ]]; then
|
||||
# Skip publish if this is not a tagged release
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -z "$CRATES_IO_TOKEN" ]]; then
|
||||
# List of internal crates to publish
|
||||
#
|
||||
# IMPORTANT: the order of the CRATES *is* significant. Crates must be published
|
||||
# before the crates that depend on them. Note that this information is already
|
||||
# expressed in the various Cargo.toml files, and ideally would not be duplicated
|
||||
# here. (TODO: figure the crate ordering dynamically)
|
||||
#
|
||||
CRATES=(
|
||||
sdk
|
||||
metrics
|
||||
drone
|
||||
programs/native/{budget,bpf_loader,lua_loader,native_loader,noop,system,vote}
|
||||
.
|
||||
)
|
||||
|
||||
|
||||
maybePackage="echo Package skipped"
|
||||
maybePublish="echo Publish skipped"
|
||||
|
||||
# Only package/publish if this is a tagged release
|
||||
if [[ -n $BUILDKITE_TAG && -n $TRIGGERED_BUILDKITE_TAG ]]; then
|
||||
maybePackage="cargo package"
|
||||
|
||||
# Only publish if there's no human around
|
||||
if [[ -n $CI ]]; then
|
||||
maybePublish="cargo publish --token $CRATES_IO_TOKEN"
|
||||
if [[ -z "$CRATES_IO_TOKEN" ]]; then
|
||||
echo CRATES_IO_TOKEN undefined
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
maybePublish="echo Publish skipped"
|
||||
if [[ -n $CI ]]; then
|
||||
maybePublish="cargo publish --token $CRATES_IO_TOKEN"
|
||||
fi
|
||||
|
||||
# shellcheck disable=2044 # Disable 'For loops over find output are fragile...'
|
||||
for Cargo_toml in {sdk,metrics,drone,programs/native/{budget,bpf_loader,lua_loader,native_loader,noop,system,vote},.}/Cargo.toml; do
|
||||
for crate in "${CRATES[@]}"; do
|
||||
if [[ ! -r $crate/Cargo.toml ]]; then
|
||||
echo "Error: $crate/Cargo.toml does not exist"
|
||||
exit 1
|
||||
fi
|
||||
echo "-- $crate"
|
||||
# TODO: Ensure the published version matches the contents of BUILDKITE_TAG
|
||||
(
|
||||
set -x
|
||||
ci/docker-run.sh rust bash -exc "cd $(dirname "$Cargo_toml"); cargo package; $maybePublish"
|
||||
ci/docker-run.sh rust bash -exc "cd $crate; $maybePackage; $maybePublish"
|
||||
)
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in New Issue