|
| 1 | +#!/bin/bash -eu |
| 2 | + |
| 3 | +# Check if exactly one argument is provided |
| 4 | +if [ "$#" -ne 1 ]; then |
| 5 | + echo 1>&2 "USAGE: start_release.sh N.N.N" |
| 6 | + exit 1 |
| 7 | +fi |
| 8 | + |
| 9 | +# Go to the directory of this script |
| 10 | +cd $( dirname ${BASH_SOURCE[0]} ) |
| 11 | + |
| 12 | +# Check if the provided argument matches the version pattern |
| 13 | +REGEX_VERSION='^\d+\.\d+\.\d+$' |
| 14 | +MATCHES=$(echo "$1" | egrep $REGEX_VERSION | wc -l) |
| 15 | +if [ $MATCHES -eq 0 ]; then |
| 16 | + echo 1>&2 "Version \"$1\" must be N.N.N" |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +# Update the version in Cargo.toml |
| 21 | +perl -pe "s/^version = .*$/version = \"$1\"/" < Cargo.toml > new_Cargo.toml |
| 22 | +mv new_Cargo.toml Cargo.toml |
| 23 | + |
| 24 | +# Remove all files and directories in src except for specified files |
| 25 | +find src -depth 1 | egrep -v '(intercept.rs|lib.rs|software_externs.rs)' | xargs rm -rf |
| 26 | + |
| 27 | +# Change to the parent directory and run make polymorph and transpile commands |
| 28 | +cd ../.. |
| 29 | +make polymorph_rust transpile_rust test_rust |
| 30 | + |
| 31 | +# Remove target directory |
| 32 | +cd runtimes/rust |
| 33 | +rm -rf target |
| 34 | + |
| 35 | +# Remove existing release directory and copy current directory to releases |
| 36 | +rm -rf ../../../releases/rust/db_esdk |
| 37 | +cp -r . ../../../releases/rust/db_esdk |
| 38 | + |
| 39 | +# Go to the release directory |
| 40 | +cd ../../../releases/rust/db_esdk |
| 41 | + |
| 42 | +# Restore the dafny_runtime_rust directory that was previously tracked by Git but had been deleted |
| 43 | +git checkout dafny_runtime_rust |
| 44 | + |
| 45 | +# Remove unnecessary files and directories |
| 46 | +rm -rf *~ copy_externs.sh start_release.sh test_published.sh test_examples *.pem RELEASE.md |
| 47 | + |
| 48 | +# Create .gitignore file with specified entries |
| 49 | +echo Cargo.lock > .gitignore |
| 50 | +echo target >> .gitignore |
| 51 | + |
| 52 | +# Run cargo test and example tests |
| 53 | +cargo test |
| 54 | +cargo run --example main |
| 55 | + |
| 56 | +# Remove Cargo.lock and .pem files after testing the examples |
| 57 | +rm -f Cargo.lock *.pem |
0 commit comments