Skip to content

Commit

Permalink
chore: release rust-sdks and js-sdks (#1192)
Browse files Browse the repository at this point in the history
* update crates release script to allow sdks releases separately

* metadata for forester-utils

* metadata for forester-utils

---------

Co-authored-by: swen <swen-code@swens-MacBook-Air-2.local>
  • Loading branch information
SwenSchaeferjohann and swen authored Sep 9, 2024
1 parent 4a6ebb5 commit 4e8d033
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 16 deletions.
3 changes: 3 additions & 0 deletions forester-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
name = "forester-utils"
version = "1.0.0"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/lightprotocol/light-protocol"
description = "Utility library for Light's Forester node implementation"

[dependencies]
account-compression = { path = "../programs/account-compression", version = "1.0.0", features = ["cpi"] }
Expand Down
62 changes: 46 additions & 16 deletions scripts/release-all-rust-crates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,53 @@ CRATES_IO_TOKEN=${CRATES_IO_TOKEN}
command -v cargo >/dev/null 2>&1 || { echo >&2 "Cargo is not installed. Aborting."; exit 1; }
command -v git >/dev/null 2>&1 || { echo >&2 "Git is not installed. Aborting."; exit 1; }
command -v gh >/dev/null 2>&1 || { echo >&2 "GitHub CLI is not installed. Aborting."; exit 1; }
echo "Tagging and releasing all Rust projects..."

# Parse command line arguments
RELEASE_PROGRAMS=false
RELEASE_SDKS=false

while [[ "$#" -gt 0 ]]; do
case $1 in
--programs) RELEASE_PROGRAMS=true ;;
--sdks) RELEASE_SDKS=true ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done

if [ "$RELEASE_PROGRAMS" = false ] && [ "$RELEASE_SDKS" = false ]; then
echo "Please specify --programs or --sdks (or both)"
exit 1
fi

echo "Logging in to crates.io..."
cargo login "${CRATES_IO_TOKEN}"
# TODO: allow dynamic releases, and add gh release workflow
PACKAGES=("aligned-sized" "light-heap" "light-bounded-vec" "light-utils" "light-hasher" "light-macros" "light-hash-set" "light-merkle-tree-reference" "light-concurrent-merkle-tree" "light-indexed-merkle-tree" "light-prover-client" "light-verifier" "account-compression" "light-system-program" "light-registry" "light-compressed-token" "photon-api" "light-test-utils" "light-sdk")


for PACKAGE in "${PACKAGES[@]}"; do
PKG_VERSION=$(cargo pkgid -p "$PACKAGE" | cut -d "#" -f2)
VERSION=${PKG_VERSION#*@}
echo "Creating tag for Rust package: $PACKAGE v$VERSION"
git tag "${PACKAGE}-v${VERSION}"
git push origin "${PACKAGE}-v${VERSION}"
for attempt in {1..3}; do
echo "Attempt $attempt: Publishing $PACKAGE..."
cargo release publish --package "$PACKAGE" --execute --no-confirm && break || echo "Attempt $attempt failed, retrying in 20..."
sleep 13

PROGRAMS=("aligned-sized" "light-heap" "light-bounded-vec" "light-utils" "light-hasher" "light-macros" "light-hash-set" "light-merkle-tree-reference" "light-concurrent-merkle-tree" "light-indexed-merkle-tree" "light-prover-client" "light-verifier" "account-compression" "light-system-program" "light-registry" "light-compressed-token")
SDKS=("photon-api" "forester-utils" "light-test-utils" "light-sdk-macros" "light-sdk")

release_packages() {
local packages=("$@")
for PACKAGE in "${packages[@]}"; do
PKG_VERSION=$(cargo pkgid -p "$PACKAGE" | cut -d "#" -f2)
VERSION=${PKG_VERSION#*@}
echo "Creating tag for Rust package: $PACKAGE v$VERSION"
git tag "${PACKAGE}-v${VERSION}"
git push origin "${PACKAGE}-v${VERSION}"
for attempt in {1..2}; do
echo "Attempt $attempt: Publishing $PACKAGE..."
cargo release publish --package "$PACKAGE" --execute --no-confirm && break || echo "Attempt $attempt failed, retrying in 10..."
sleep 10
done
done
done
}

if [ "$RELEASE_PROGRAMS" = true ]; then
echo "Releasing programs..."
release_packages "${PROGRAMS[@]}"
fi

if [ "$RELEASE_SDKS" = true ]; then
echo "Releasing SDKs..."
release_packages "${SDKS[@]}"
fi

0 comments on commit 4e8d033

Please sign in to comment.