A better Rust ATProto crate

codegen bug fix, binary release script

Orual e0276830 445fb429

+1
.gitignore
··· 12 12 /lex_js 13 13 /plans 14 14 /docs 15 + /binaries/releases/
+2
binaries/SHA256SUMS
··· 1 + df7948afb0d458a2d23830acbfe88c531b18a33f05b0eb32069a0af299f5bd00 jacquard-codegen_x86_64-unknown-linux-gnu.tar.xz 2 + 4f2ac0b2d3e53a1f66c47c10372798775c92806719212e77c09bfc0429674d8b lex-fetch_x86_64-unknown-linux-gnu.tar.xz
binaries/jacquard-codegen_x86_64-unknown-linux-gnu.tar.xz

This is a binary file and will not be displayed.

binaries/jacquard-codegen_x86_64-unknown-linux-gnu_v0.5.3.tar.xz

This is a binary file and will not be displayed.

binaries/lex-fetch_x86_64-unknown-linux-gnu.tar.xz

This is a binary file and will not be displayed.

binaries/lex-fetch_x86_64-unknown-linux-gnu_v0.5.3.tar.xz

This is a binary file and will not be displayed.

+4
justfile
··· 32 32 codegen *ARGS: 33 33 cargo run -p jacquard-lexicon --bin jacquard-codegen -- -r crate {{ARGS}} 34 34 35 + # Package binaries for distribution (creates tar.xz archives) 36 + package-binaries: 37 + ./scripts/package-binaries.sh 38 + 35 39 # List all available examples 36 40 examples: 37 41 #!/usr/bin/env bash
+127
scripts/package-binaries.sh
··· 1 + #!/usr/bin/env bash 2 + set -euo pipefail 3 + 4 + # Script to package jacquard-codegen and lex-fetch binaries for distribution 5 + # Creates tar.xz archives with binaries, README, LICENSE, and config files 6 + # 7 + # Generates two versions: 8 + # - Unversioned archives in binaries/ (tracked in git, overwritten each build) 9 + # - Versioned archives in binaries/releases/ (gitignored, for GitHub releases) 10 + 11 + # Determine project root (script is in scripts/ subdirectory) 12 + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 13 + PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" 14 + cd "$PROJECT_ROOT" 15 + 16 + # Parse version from workspace Cargo.toml 17 + VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') 18 + echo "Packaging version: $VERSION" 19 + 20 + # Detect target triple (default to x86_64-unknown-linux-gnu) 21 + TARGET="${CARGO_BUILD_TARGET:-x86_64-unknown-linux-gnu}" 22 + echo "Target: $TARGET" 23 + 24 + # Output directories 25 + OUTPUT_DIR="binaries" 26 + RELEASES_DIR="binaries/releases" 27 + mkdir -p "$OUTPUT_DIR" 28 + mkdir -p "$RELEASES_DIR" 29 + 30 + # Build binaries in release mode 31 + echo "Building binaries..." 32 + cargo build --release -p jacquard-lexicon --bin jacquard-codegen 33 + cargo build --release -p jacquard-lexicon --bin lex-fetch 34 + 35 + # Binary locations 36 + CODEGEN_BIN="target/release/jacquard-codegen" 37 + LEXFETCH_BIN="target/release/lex-fetch" 38 + 39 + # Verify binaries exist 40 + if [[ ! -f "$CODEGEN_BIN" ]]; then 41 + echo "Error: jacquard-codegen binary not found at $CODEGEN_BIN" 42 + exit 1 43 + fi 44 + 45 + if [[ ! -f "$LEXFETCH_BIN" ]]; then 46 + echo "Error: lex-fetch binary not found at $LEXFETCH_BIN" 47 + exit 1 48 + fi 49 + 50 + # Helper function to package a binary 51 + package_binary() { 52 + local BIN_NAME=$1 53 + local BIN_PATH=$2 54 + local EXTRA_FILES=("${@:3}") # Additional files beyond README and LICENSE 55 + 56 + echo "Packaging ${BIN_NAME}..." 57 + 58 + # Names for versioned and unversioned archives 59 + local VERSIONED_NAME="${BIN_NAME}_${TARGET}_v${VERSION}" 60 + local UNVERSIONED_NAME="${BIN_NAME}_${TARGET}" 61 + 62 + # Create staging directory 63 + local STAGE_DIR="/tmp/${VERSIONED_NAME}" 64 + rm -rf "$STAGE_DIR" 65 + mkdir -p "$STAGE_DIR" 66 + 67 + # Copy files 68 + cp "$BIN_PATH" "$STAGE_DIR/" 69 + cp LICENSE "$STAGE_DIR/" 70 + cp README.md "$STAGE_DIR/" 71 + for file in "${EXTRA_FILES[@]}"; do 72 + [[ -n "$file" ]] && cp "$file" "$STAGE_DIR/" 73 + done 74 + 75 + # Strip binary (reduce size) 76 + strip "$STAGE_DIR/$BIN_NAME" || echo "Warning: strip failed, skipping" 77 + 78 + # Create versioned archive (for releases) 79 + cd /tmp 80 + tar -cJf "${VERSIONED_NAME}.tar.xz" "$VERSIONED_NAME" 81 + mv "${VERSIONED_NAME}.tar.xz" "$PROJECT_ROOT/$RELEASES_DIR/" 82 + echo " Created: ${RELEASES_DIR}/${VERSIONED_NAME}.tar.xz" 83 + 84 + # Rename staging directory for unversioned archive 85 + mv "$VERSIONED_NAME" "$UNVERSIONED_NAME" 86 + 87 + # Create unversioned archive (tracked in git) 88 + tar -cJf "${UNVERSIONED_NAME}.tar.xz" "$UNVERSIONED_NAME" 89 + mv "${UNVERSIONED_NAME}.tar.xz" "$PROJECT_ROOT/$OUTPUT_DIR/" 90 + echo " Created: ${OUTPUT_DIR}/${UNVERSIONED_NAME}.tar.xz" 91 + 92 + # Cleanup 93 + rm -rf "$UNVERSIONED_NAME" 94 + cd "$PROJECT_ROOT" 95 + } 96 + 97 + # Package jacquard-codegen 98 + package_binary "jacquard-codegen" "$CODEGEN_BIN" 99 + 100 + # Package lex-fetch (with lexicons.kdl) 101 + package_binary "lex-fetch" "$LEXFETCH_BIN" "lexicons.kdl" 102 + 103 + # Print summary 104 + echo "" 105 + echo "Packaging complete!" 106 + echo "" 107 + echo "Tracked archives (binaries/):" 108 + ls -lh "$OUTPUT_DIR"/*.tar.xz 109 + echo "" 110 + echo "Release archives (binaries/releases/):" 111 + ls -lh "$RELEASES_DIR"/*.tar.xz 112 + 113 + # Generate checksums for tracked archives 114 + echo "" 115 + echo "Generating checksums for tracked archives..." 116 + cd "$OUTPUT_DIR" 117 + sha256sum *.tar.xz > SHA256SUMS 118 + echo "Checksums written to ${OUTPUT_DIR}/SHA256SUMS" 119 + cat SHA256SUMS 120 + 121 + # Generate checksums for release archives 122 + echo "" 123 + echo "Generating checksums for release archives..." 124 + cd "$PROJECT_ROOT/$RELEASES_DIR" 125 + sha256sum *.tar.xz > SHA256SUMS 126 + echo "Checksums written to ${RELEASES_DIR}/SHA256SUMS" 127 + cat SHA256SUMS