|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | + |
| 20 | +set -e |
| 21 | + |
| 22 | +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) |
| 23 | +ROOT_DIR="$SCRIPT_DIR/../.." |
| 24 | +CRATES_DIR=( |
| 25 | + "optee-utee/optee-utee-sys" |
| 26 | + "optee-utee/macros" |
| 27 | + "optee-utee-build" |
| 28 | + "optee-utee" |
| 29 | + "optee-teec/optee-teec-sys" |
| 30 | + "optee-teec/macros" |
| 31 | + "optee-teec" |
| 32 | +) |
| 33 | + |
| 34 | +cd "$ROOT_DIR" |
| 35 | +echo "Working directory set to: $(pwd)" |
| 36 | + |
| 37 | +echo "=== Phase 1: Verify All Packages (Local Build Check) ===" |
| 38 | +for DIR in "${CRATES_DIR[@]}"; do |
| 39 | + echo "[$DIR] Validating package..." |
| 40 | + if [ ! -d "$DIR" ]; then |
| 41 | + echo "Error: Directory $DIR not found!" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + (cd "$DIR" && cargo build) |
| 45 | +done |
| 46 | + |
| 47 | +echo -e "\nAll packages passed Phase 1 (local verification)." |
| 48 | +echo "Entering Phase 2: Sequential Dry-run and Interactive Publish." |
| 49 | + |
| 50 | +for DIR in "${CRATES_DIR[@]}"; do |
| 51 | + echo "------------------------------------------------" |
| 52 | + echo "Processing crate: $DIR" |
| 53 | + |
| 54 | + pushd "$DIR" > /dev/null |
| 55 | + |
| 56 | + echo "[$DIR] Step 1: Running cargo publish --dry-run..." |
| 57 | + cargo publish --dry-run |
| 58 | + |
| 59 | + echo -e "\n[$DIR] Dry-run successful." |
| 60 | + read -p "Do you want to formally PUBLISH [$DIR] to crates.io? (y/n) " -n 1 -r |
| 61 | + echo |
| 62 | + if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
| 63 | + echo "Publishing aborted by user at [$DIR]. Exiting." |
| 64 | + popd > /dev/null |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | + |
| 68 | + echo "[$DIR] Step 2: Publishing..." |
| 69 | + cargo publish |
| 70 | + |
| 71 | + popd > /dev/null |
| 72 | + |
| 73 | + echo "[$DIR] Done. Waiting 30s for crates.io index sync..." |
| 74 | + sleep 30 |
| 75 | +done |
| 76 | + |
| 77 | +echo "------------------------------------------------" |
| 78 | +echo "All crates have been published successfully!" |
0 commit comments