Merge pull request #115 from FalkorDB/bump-v0.1.14-falkordb-4.18.6 #461
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - 'v*' # Also trigger on version tags for releases | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g., v1.0.0)' | |
| required: true | |
| default: 'v0.1.0' | |
| release_name: | |
| description: 'Release name (optional)' | |
| required: false | |
| default: '' | |
| prerelease: | |
| description: 'Mark as prerelease' | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # CI job - runs on every push/PR to master | |
| ci: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Cache cargo dependencies | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Check formatting | |
| run: cargo fmt -- --check | |
| - name: Run clippy | |
| run: cargo clippy -- -W clippy::pedantic -W clippy::nursery -D warnings | |
| - name: Run tests | |
| run: cargo test | |
| - name: Build | |
| run: cargo build --release | |
| # Release job - only runs on version tags or manual dispatch | |
| release: | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-musl | |
| os: ubuntu-latest | |
| use_cross: true | |
| runs-on: ${{ matrix.os }} | |
| needs: ci | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo dependencies | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-${{ matrix.target }}- | |
| ${{ runner.os }}-cargo- | |
| - name: Install musl tools (for musl targets) | |
| if: contains(matrix.target, 'musl') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y musl-tools musl-dev | |
| - name: Install cross for cross-compilation | |
| if: matrix.use_cross | |
| run: | | |
| cargo install cross | |
| - name: Build binary | |
| run: | | |
| echo "Building for target: ${{ matrix.target }} on ${{ matrix.os }}" | |
| if [ "${{ matrix.use_cross }}" = "true" ]; then | |
| echo "Using cross for cross-compilation..." | |
| cross build --release --target ${{ matrix.target }} --verbose | |
| elif [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then | |
| echo "Using musl-gcc for x86_64 musl target..." | |
| CC_x86_64_unknown_linux_musl=musl-gcc cargo build --release --target ${{ matrix.target }} --verbose | |
| else | |
| echo "Using standard cargo build for native compilation..." | |
| cargo build --release --target ${{ matrix.target }} --verbose | |
| fi | |
| echo "β Build completed successfully for ${{ matrix.target }}" | |
| - name: Prepare artifacts | |
| run: | | |
| mkdir -p release-artifacts | |
| # Copy binary | |
| cp target/${{ matrix.target }}/release/text-to-cypher release-artifacts/text-to-cypher-linux-$(echo ${{ matrix.target }} | sed 's/unknown-linux-//' | sed 's/-unknown-linux//') | |
| # Copy templates | |
| cp -r templates release-artifacts/ | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: binary-${{ matrix.target }} | |
| path: release-artifacts/ | |
| # Combine artifacts and create release | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | |
| with: | |
| path: artifacts | |
| - name: Combine artifacts and create packages | |
| run: | | |
| mkdir -p release-artifacts/packages | |
| echo "π Downloaded artifacts structure:" | |
| find artifacts -type f -name "*" | head -20 | |
| # Combine all binaries | |
| for artifact_dir in artifacts/binary-*; do | |
| if [ -d "$artifact_dir" ]; then | |
| echo "π Processing artifact dir: $artifact_dir" | |
| ls -la "$artifact_dir" | |
| cp "$artifact_dir"/text-to-cypher-linux-* release-artifacts/ 2>/dev/null || echo "β No binaries found in $artifact_dir" | |
| fi | |
| done | |
| # Copy templates from any artifact (they're all the same) | |
| if [ -d "artifacts/binary-x86_64-unknown-linux-musl/templates" ]; then | |
| cp -r artifacts/binary-x86_64-unknown-linux-musl/templates release-artifacts/ | |
| echo "β Templates copied from x86_64 artifact" | |
| else | |
| echo "β Templates not found in x86_64 artifact" | |
| echo "Available files in x86_64 artifact:" | |
| ls -la artifacts/binary-x86_64-unknown-linux-musl/ 2>/dev/null || echo "Directory not found" | |
| fi | |
| # Create packages | |
| cd release-artifacts | |
| echo "π Current directory contents:" | |
| ls -la | |
| echo "π Looking for binaries matching 'text-to-cypher-linux-*':" | |
| ls -la text-to-cypher-linux-* 2>/dev/null || echo "No binaries found!" | |
| for binary in text-to-cypher-linux-*; do | |
| if [ -f "$binary" ]; then | |
| package_name="${binary}.tar.gz" | |
| echo "Creating package: $package_name" | |
| temp_dir="temp_${binary}" | |
| mkdir -p "$temp_dir" | |
| cp "$binary" "$temp_dir/text-to-cypher" | |
| cp -r templates "$temp_dir/" | |
| tar -czf "packages/${package_name}" -C "$temp_dir" . | |
| rm -rf "$temp_dir" | |
| echo "β Created package: packages/$package_name" | |
| else | |
| echo "β Binary not found or not a file: $binary" | |
| fi | |
| done | |
| # Create checksums | |
| sha256sum packages/*.tar.gz > checksums.txt | |
| # List everything we're releasing | |
| echo "π¦ Release artifacts:" | |
| ls -la packages/ | |
| echo "π Checksums:" | |
| cat checksums.txt | |
| - name: Upload release artifacts | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: release-packages | |
| path: | | |
| release-artifacts/packages/ | |
| release-artifacts/checksums.txt | |
| release-artifacts/text-to-cypher-linux-* | |
| - name: Create installation script | |
| run: | | |
| cat > release-artifacts/install.sh << 'EOF' | |
| #!/bin/bash | |
| set -e | |
| # Text-to-Cypher Installation Script | |
| REPO="FalkorDB/text-to-cypher" | |
| BINARY_NAME="text-to-cypher" | |
| # Parse arguments | |
| INSTALL_SYSTEM=false | |
| for arg in "$@"; do | |
| case $arg in | |
| --install) | |
| INSTALL_SYSTEM=true | |
| ;; | |
| *) | |
| ;; | |
| esac | |
| done | |
| # Detect architecture | |
| ARCH=$(uname -m) | |
| OS=$(uname -s) | |
| case "$OS" in | |
| Linux*) | |
| case "$ARCH" in | |
| x86_64) PLATFORM="linux-x86_64-musl" ;; # Prefer musl for better compatibility | |
| aarch64) PLATFORM="linux-aarch64-musl" ;; # Prefer musl for better compatibility | |
| arm64) PLATFORM="linux-aarch64-musl" ;; # Prefer musl for better compatibility | |
| *) echo "Unsupported architecture: $ARCH"; exit 1 ;; | |
| esac | |
| ;; | |
| Darwin*) | |
| case "$ARCH" in | |
| x86_64) PLATFORM="darwin-x86_64" ;; | |
| arm64) PLATFORM="darwin-aarch64" ;; | |
| *) echo "Unsupported architecture: $ARCH"; exit 1 ;; | |
| esac | |
| ;; | |
| *) echo "Unsupported OS: $OS"; exit 1 ;; | |
| esac | |
| # Get latest release | |
| LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') | |
| # Download complete package with templates (always includes templates) | |
| DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_RELEASE/packages/$BINARY_NAME-$PLATFORM.tar.gz" | |
| echo "Downloading $BINARY_NAME $LATEST_RELEASE (with templates) for $PLATFORM..." | |
| # Download and extract package | |
| if command -v curl >/dev/null 2>&1; then | |
| curl -L "$DOWNLOAD_URL" -o "$BINARY_NAME.tar.gz" | |
| elif command -v wget >/dev/null 2>&1; then | |
| wget "$DOWNLOAD_URL" -O "$BINARY_NAME.tar.gz" | |
| else | |
| echo "Error: curl or wget is required" | |
| exit 1 | |
| fi | |
| # Extract the package | |
| tar -xzf "$BINARY_NAME.tar.gz" | |
| rm "$BINARY_NAME.tar.gz" | |
| echo "Downloaded $BINARY_NAME with templates!" | |
| echo "Files extracted:" | |
| echo " - $BINARY_NAME (executable)" | |
| echo " - templates/ (directory)" | |
| # Install to system path (optional) | |
| if [ "$INSTALL_SYSTEM" = "true" ]; then | |
| sudo mv "$BINARY_NAME" /usr/local/bin/ | |
| sudo mkdir -p /usr/local/share/text-to-cypher | |
| sudo cp -r templates /usr/local/share/text-to-cypher/ | |
| echo "$BINARY_NAME installed to /usr/local/bin/" | |
| echo "Templates installed to /usr/local/share/text-to-cypher/templates/" | |
| else | |
| echo "$BINARY_NAME downloaded successfully!" | |
| echo "Run with: ./$BINARY_NAME" | |
| echo "Templates available in: ./templates/" | |
| echo "" | |
| echo "Usage options:" | |
| echo " $0 --install # Install system-wide" | |
| fi | |
| EOF | |
| chmod +x release-artifacts/install.sh | |
| - name: Generate release tag | |
| id: tag | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| # Use manual input version | |
| TAG="${{ github.event.inputs.version }}" | |
| RELEASE_NAME="${{ github.event.inputs.release_name }}" | |
| if [ -z "$RELEASE_NAME" ]; then | |
| RELEASE_NAME="Release $TAG" | |
| fi | |
| else | |
| # Use the tag from the push event | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| RELEASE_NAME="Release $TAG" | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "release_name=$RELEASE_NAME" >> $GITHUB_OUTPUT | |
| # Auto-detect prerelease based on tag name for tag-based releases | |
| if [[ "$TAG" == *"alpha"* ]] || [[ "$TAG" == *"beta"* ]] || [[ "$TAG" == *"rc"* ]]; then | |
| echo "prerelease=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "prerelease=${{ github.event.inputs.prerelease || 'false' }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.tag }} | |
| name: ${{ steps.tag.outputs.release_name }} | |
| prerelease: ${{ steps.tag.outputs.prerelease }} | |
| body: | | |
| ## π Text-to-Cypher ${{ steps.tag.outputs.tag }} | |
| **Built from commit:** ${{ github.sha }} | |
| **Release Type:** ${{ steps.tag.outputs.prerelease == 'true' && 'Pre-release' || 'Stable' }} | |
| ### π¦ Quick Installation: | |
| ```bash | |
| # One-line install (Linux/macOS) | |
| curl -sSL https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.sh | bash | |
| # Or install system-wide | |
| curl -sSL https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.sh | bash -s -- --install | |
| ``` | |
| ### π Manual Downloads: | |
| - **Complete Packages** (includes binary + templates): | |
| - `packages/text-to-cypher-linux-x86_64-musl.tar.gz` (x86_64 static) | |
| - `packages/text-to-cypher-linux-aarch64-musl.tar.gz` (ARM64 static) | |
| - **Checksums**: `checksums.txt` | |
| - **Checksums**: `checksums.txt` | |
| ### π³ Use in Your Dockerfiles: | |
| ```dockerfile | |
| # Download and use in your Dockerfile | |
| FROM alpine:latest | |
| RUN apk add --no-cache wget tar && \ | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/packages/text-to-cypher-linux-x86_64-musl.tar.gz && \ | |
| tar -xzf text-to-cypher-linux-x86_64-musl.tar.gz && \ | |
| mv text-to-cypher /usr/local/bin/text-to-cypher && \ | |
| mv templates /usr/local/share/text-to-cypher-templates && \ | |
| rm text-to-cypher-linux-x86_64-musl.tar.gz | |
| ENV TEMPLATES_DIR=/usr/local/share/text-to-cypher-templates | |
| CMD ["text-to-cypher"] | |
| ``` | |
| files: | | |
| release-artifacts/packages/* | |
| release-artifacts/checksums.txt | |
| release-artifacts/install.sh | |
| release-artifacts/text-to-cypher-linux-* | |
| draft: false |