Bump and publish ostd-test and ostd-macros

This commit is contained in:
Zhang Junyang
2024-08-24 14:21:58 +08:00
committed by Tate, Hongliang Tian
parent e50b05d1ee
commit 34b3aac2e3
8 changed files with 106 additions and 62 deletions

View File

@ -20,11 +20,11 @@ update_package_version() {
sed -i "0,/${pattern}/s/${pattern}/version = \"${new_version}\"/1" $1
}
# Update the version of the `ostd` dependency (`ostd = { version = "", ...`) in file $1
update_ostd_dep_version() {
echo "Updating file $1"
pattern="^ostd = { version = \"[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\""
sed -i "0,/${pattern}/s/${pattern}/ostd = { version = \"${new_version}\"/1" $1
# Update the version of the $2 dependency (`$2 = { version = "", ...`) in file $1
update_dep_version() {
echo "Updating the version of $2 in file $1"
pattern="^$2 = { version = \"[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\""
sed -i "0,/${pattern}/s/${pattern}/$2 = { version = \"${new_version}\"/1" $1
}
# Update Docker image versions (`asterinas/asterinas:{version}`) in file $1
@ -104,8 +104,10 @@ SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ASTER_SRC_DIR=${SCRIPT_DIR}/..
DOCS_DIR=${ASTER_SRC_DIR}/docs
OSTD_CARGO_TOML_PATH=${ASTER_SRC_DIR}/ostd/Cargo.toml
OSTD_TEST_CARGO_TOML_PATH=${ASTER_SRC_DIR}/ostd/libs/ostd-test/Cargo.toml
OSTD_MACROS_CARGO_TOML_PATH=${ASTER_SRC_DIR}/ostd/libs/ostd-macros/Cargo.toml
OSDK_CARGO_TOML_PATH=${ASTER_SRC_DIR}/osdk/Cargo.toml
OSTD_TEST_RUNNER_CARGO_TOML_PATH=${ASTER_SRC_DIR}/osdk/test-kernel/Cargo.toml
OSDK_TEST_RUNNER_CARGO_TOML_PATH=${ASTER_SRC_DIR}/osdk/test-kernel/Cargo.toml
VERSION_PATH=${ASTER_SRC_DIR}/VERSION
current_version=$(cat ${VERSION_PATH})
@ -119,11 +121,15 @@ fi
validate_bump_type
new_version=$(bump_version ${current_version})
# Update the package version in Cargo.toml
# Update the versions in Cargo.toml
update_package_version ${OSTD_TEST_CARGO_TOML_PATH}
update_package_version ${OSTD_MACROS_CARGO_TOML_PATH}
update_package_version ${OSTD_CARGO_TOML_PATH}
update_dep_version ${OSTD_CARGO_TOML_PATH} ostd-test
update_dep_version ${OSTD_CARGO_TOML_PATH} ostd-macros
update_package_version ${OSDK_CARGO_TOML_PATH}
update_package_version ${OSTD_TEST_RUNNER_CARGO_TOML_PATH}
update_ostd_dep_version ${OSTD_TEST_RUNNER_CARGO_TOML_PATH}
update_package_version ${OSDK_TEST_RUNNER_CARGO_TOML_PATH}
update_dep_version ${OSDK_TEST_RUNNER_CARGO_TOML_PATH} ostd
# Automatically bump Cargo.lock file
cargo update -p aster-nix --precise $new_version

View File

@ -0,0 +1,78 @@
#!/bin/bash
# SPDX-License-Identifier: MPL-2.0
set -e
# Publish OSDK and OSTD to crates.io
#
# Usage: publish_osdk_and_ostd.sh [--dry-run | --token REGISTRY_TOKEN]
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ASTER_SRC_DIR=${SCRIPT_DIR}/../..
# Print help message
print_help() {
echo "Usage: $0 [--dry-run | --token REGISTRY_TOKEN]"
echo ""
echo "Options:"
echo " --dry-run: Execute the publish check without actually publishing it."
echo " --token REGISTRY_TOKEN: The token to authenticate with crates.io."
}
# Parse the parameters
DRY_RUN=""
TOKEN=""
while [ "$#" -gt 0 ]; do
case "$1" in
--dry-run)
DRY_RUN="true"
shift
;;
--token)
TOKEN="$2"
shift 2
;;
*)
echo "Error: Invalid parameter: $1"
print_help
exit 1
;;
esac
done
# Performs the publish check or publish the crate in directory $1, with
# optional target $2. If the target is not specified, cargo will decide
# the target automatically.
do_publish_for() {
pushd $ASTER_SRC_DIR/$1
TARGET_ARGS=""
if [ -n "$2" ]; then
TARGET_ARGS="--target $2"
fi
if [ -n "$DRY_RUN" ]; then
cargo publish --dry-run $TARGET_ARGS
cargo doc $TARGET_ARGS
else
cargo publish --token $TOKEN $TARGET_ARGS
fi
popd
}
do_publish_for osdk
# All supported targets of OSTD, this array should keep consistent with
# `package.metadata.docs.rs.targets` in `ostd/Cargo.toml`.
TARGETS="x86_64-unknown-none"
for TARGET in $TARGETS; do
do_publish_for ostd/libs/ostd-macros $TARGET
do_publish_for ostd/libs/ostd-test $TARGET
do_publish_for ostd $TARGET
do_publish_for osdk/test-kernel $TARGET
# For actual publishing, we should only publish once. Using any target that
# OSTD supports is OK. Here we use the first target in the list.
if [ -z "$DRY_RUN" ]; then
break
fi
done