Skip to content

Commit

Permalink
chore(rust): add comments to release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikKapila authored Dec 9, 2024
1 parent c0ec84d commit 7b45929
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
13 changes: 10 additions & 3 deletions DynamoDbEncryption/runtimes/rust/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ To publish a new version of the aws-db-esdk for version N.N.N
1. Acquire the appropriate permissions
1. Ensure git checkout of main is fresh and clean
1. ./start_release.sh N.N.N
1. cd ../../../releases/rust/db_esdk
1. `cd ../../../releases/rust/db_esdk`
1. Create a PR with all changed or added files
1. cargo publish
1. cd ../../../DynamoDbEncryption/runtimes/rust/ # i.e. return here
1. Within the PR, make sure you also:
1. Update the `CHANGELOG.md` in the root directory with the changes
1. If this is a major version bump, update the `SUPPORT_POLICY.rst` for Rust
1. Get the PR reviewed by a teammate
1. Before merging the PR, publish the new version of the `aws-db-esdk` crate and test the published crate (documented in next steps)
1. Run `cargo publish`
1. `cd ../../../DynamoDbEncryption/runtimes/rust/` # i.e. return here
1. ./test_published.sh N.N.N
1. Ignore/stash the changes in `DynamoDbEncryption/runtimes/rust/test_examples/Cargo.toml` which adds the `aws-db-esdk`
1. Merge the release PR
23 changes: 22 additions & 1 deletion DynamoDbEncryption/runtimes/rust/start_release.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,57 @@
#!/bin/bash -eu

# Check if exactly one argument is provided
if [ "$#" -ne 1 ]; then
echo 1>&2 "USAGE: start_release.sh N.N.N"
exit 1
fi

# Go to the directory of this script
cd $( dirname ${BASH_SOURCE[0]} )

# Check if the provided argument matches the version pattern
REGEX_VERSION='^\d+\.\d+\.\d+$'
MATCHES=$(echo "$1" | egrep $REGEX_VERSION | wc -l)
if [ $MATCHES -eq 0 ]; then
echo 1>&2 "Version \"$1\" must be N.N.N"
exit 1
fi

# Update the version in Cargo.toml
perl -pe "s/^version = .*$/version = \"$1\"/" < Cargo.toml > new_Cargo.toml
mv new_Cargo.toml Cargo.toml

# Remove all files and directories in src except for specified files
find src -depth 1 | egrep -v '(intercept.rs|lib.rs|software_externs.rs)' | xargs rm -rf

# Change to the parent directory and run make polymorph and transpile commands
cd ../..
make polymorph_rust transpile_rust test_rust

# Remove target directory
cd runtimes/rust
rm -rf target

# Remove existing release directory and copy current directory to releases
rm -rf ../../../releases/rust/db_esdk
cp -r . ../../../releases/rust/db_esdk

# Go to the release directory
cd ../../../releases/rust/db_esdk

# Restore the dafny_runtime_rust directory that was previously tracked by Git but had been deleted
git checkout dafny_runtime_rust

# Remove unnecessary files and directories
rm -rf *~ copy_externs.sh start_release.sh test_published.sh test_examples *.pem RELEASE.md

# Create .gitignore file with specified entries
echo Cargo.lock > .gitignore
echo target >> .gitignore

# Run cargo test and example tests
cargo test
cargo run --example main
rm -f Cargo.lock *.pem

# Remove Cargo.lock and .pem files after testing the examples
rm -f Cargo.lock *.pem
1 change: 0 additions & 1 deletion DynamoDbEncryption/runtimes/rust/test_examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[package]
name = "aws-db-esdk-examples"
version = "0.1.0"
edition = "2021"
rust-version = "1.80.0"

Expand Down
11 changes: 10 additions & 1 deletion DynamoDbEncryption/runtimes/rust/test_published.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/bin/bash -eu

# Check if exactly one argument is provided
if [ "$#" -ne 1 ]; then
echo 1>&2 "USAGE: test_published.sh N.N.N"
exit 1
fi

# Go to the directory of this script
cd $( dirname ${BASH_SOURCE[0]} )

# Check if the provided argument matches the version pattern
REGEX_VERSION='^\d+\.\d+\.\d+$'

echo "$1" | egrep -q $REGEX_VERSION
if [ $? -ne 0 ]; then
echo 1>&2 "Version \"$1\" must be N.N.N"
Expand All @@ -17,14 +19,21 @@ fi

VERSION=$1

# Update examples in test_examples directory
rm -rf test_examples/src
cp -r examples test_examples/src/
cd test_examples

# Add aws-db-esdk
cargo add aws-db-esdk

# Check if the added version matches the provided version
MATCH=$(fgrep "aws-db-esdk = \"$VERSION\"" Cargo.toml | wc -l)
if [ $MATCH -eq "0" ]; then
echo Version $VERSION of aws-db-esdk not the most recent
egrep '^aws-db-esdk' Cargo.toml
exit 1
fi

# Run the cargo project
cargo run
2 changes: 1 addition & 1 deletion submodules/smithy-dafny

0 comments on commit 7b45929

Please sign in to comment.