Skip to content

Commit f08d177

Browse files
committed
release: add helper script for publishing crates
1 parent 74af801 commit f08d177

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

docs/release-tips.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ cargo publish --dry-run # check if ready, will not upload
6060
cargo publish # check and upload
6161
```
6262

63+
We have a script to simplify this process:
64+
[publish_crates.sh](https://github.com/apache/teaclave-trustzone-sdk/blob/main/scripts/release/publish_crates.sh).
65+
66+
To use the script with the Docker environment:
67+
68+
```bash
69+
# Run the Docker container (use the same image from the vote email)
70+
docker run -it --rm \
71+
-v $(pwd):/root/teaclave_sdk_src \
72+
-w /root/teaclave_sdk_src \
73+
teaclave/teaclave-trustzone-emulator-nostd-expand-memory:OPTEE-VERSION
74+
75+
# Inside the Docker container:
76+
cargo login
77+
./scripts/release/publish_crates.sh
78+
```
79+
6380
### GitHub Action for Drafting Release Notes
6481

6582
We use a GitHub Action to help categorize pull requests and generate a draft of

scripts/release/publish_crates.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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

Comments
 (0)