This repository was archived by the owner on Aug 7, 2026. It is now read-only.
Repository navigation
fix: correct version comparison logic in release workflow #13
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: Release | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if version changed | |
| id: check | |
| run: | | |
| VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Get latest tag | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| LATEST_VERSION=${LATEST_TAG#v} | |
| echo "Current version: $VERSION" | |
| echo "Latest tag: $LATEST_TAG (version: $LATEST_VERSION)" | |
| if [ "$VERSION" != "$LATEST_VERSION" ]; then | |
| # Verify this is a newer version (not older) | |
| # sort -V -C returns 0 if input is sorted; if [old, new] is sorted, new IS newer | |
| printf '%s\n%s\n' "$LATEST_VERSION" "$VERSION" | sort -V -C && IS_NEWER=true || IS_NEWER=false | |
| if [ "$IS_NEWER" = "true" ] || [ "$LATEST_VERSION" = "0.0.0" ]; then | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| echo "New version detected, will release $VERSION" | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| echo "Version $VERSION is not newer than $LATEST_VERSION, skipping release" | |
| fi | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| echo "Version unchanged, skipping release" | |
| fi | |
| release: | |
| needs: check-version | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ needs.check-version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create and push tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v${{ needs.check-version.outputs.version }}" -m "Release v${{ needs.check-version.outputs.version }}" | |
| git push origin "v${{ needs.check-version.outputs.version }}" | |
| build: | |
| needs: [check-version, release] | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| asset_name: lambda-cli-x86_64-unknown-linux-gnu | |
| npm_os: linux | |
| npm_arch: x64 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| asset_name: lambda-cli-x86_64-apple-darwin | |
| npm_os: darwin | |
| npm_arch: x64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| asset_name: lambda-cli-aarch64-apple-darwin | |
| npm_os: darwin | |
| npm_arch: arm64 | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| asset_name: lambda-cli-x86_64-pc-windows-msvc | |
| npm_os: win32 | |
| npm_arch: x64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.check-version.outputs.version }} | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Build release | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Create tarball (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar -czvf ../../../${{ matrix.asset_name }}.tar.gz lambda lambda-mcp | |
| - name: Create tarball (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| 7z a ../../../${{ matrix.asset_name }}.zip lambda.exe lambda-mcp.exe | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: ${{ matrix.asset_name }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} | |
| - name: Create npm platform package | |
| run: | | |
| mkdir -p npm-pkg/bin | |
| if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
| cp target/${{ matrix.target }}/release/lambda-mcp.exe npm-pkg/bin/ | |
| else | |
| cp target/${{ matrix.target }}/release/lambda-mcp npm-pkg/bin/ | |
| chmod +x npm-pkg/bin/lambda-mcp | |
| fi | |
| if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
| cat > npm-pkg/package.json << EOF | |
| { | |
| "name": "@strand-ai/lambda-mcp-${{ matrix.npm_os }}-${{ matrix.npm_arch }}", | |
| "version": "${{ needs.check-version.outputs.version }}", | |
| "description": "Platform-specific binary for lambda-mcp (${{ matrix.npm_os }}-${{ matrix.npm_arch }})", | |
| "os": ["${{ matrix.npm_os }}"], | |
| "cpu": ["${{ matrix.npm_arch }}"], | |
| "repository": { "type": "git", "url": "https://github.com/Strand-AI/lambda-cli" }, | |
| "license": "MIT" | |
| } | |
| EOF | |
| else | |
| cat > npm-pkg/package.json << EOF | |
| { | |
| "name": "@strand-ai/lambda-mcp-${{ matrix.npm_os }}-${{ matrix.npm_arch }}", | |
| "version": "${{ needs.check-version.outputs.version }}", | |
| "description": "Platform-specific binary for lambda-mcp (${{ matrix.npm_os }}-${{ matrix.npm_arch }})", | |
| "os": ["${{ matrix.npm_os }}"], | |
| "cpu": ["${{ matrix.npm_arch }}"], | |
| "repository": { "type": "git", "url": "https://github.com/Strand-AI/lambda-cli" }, | |
| "license": "MIT", | |
| "scripts": { "postinstall": "chmod +x bin/lambda-mcp 2>/dev/null || true" } | |
| } | |
| EOF | |
| fi | |
| shell: bash | |
| - name: Upload npm package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-lambda-mcp-${{ matrix.npm_os }}-${{ matrix.npm_arch }} | |
| path: npm-pkg/ | |
| publish: | |
| needs: [check-version, release, build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| files: | | |
| artifacts/**/*.tar.gz | |
| artifacts/**/*.zip | |
| generate_release_notes: true | |
| update-homebrew: | |
| needs: [check-version, release, publish] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Compute SHA256 | |
| id: sha256 | |
| run: | | |
| TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/v${{ needs.check-version.outputs.version }}.tar.gz" | |
| SHA256=$(curl -sL "$TARBALL_URL" | sha256sum | cut -d' ' -f1) | |
| echo "sha256=$SHA256" >> $GITHUB_OUTPUT | |
| - name: Checkout homebrew-tap | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Strand-AI/homebrew-tap | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| path: homebrew-tap | |
| - name: Update formula | |
| run: | | |
| cat > homebrew-tap/Formula/lambda-cli.rb << 'EOF' | |
| class LambdaCli < Formula | |
| desc "Unofficial CLI and MCP server for Lambda cloud GPU instances" | |
| homepage "https://github.com/Strand-AI/lambda-cli" | |
| url "https://github.com/Strand-AI/lambda-cli/archive/refs/tags/v${{ needs.check-version.outputs.version }}.tar.gz" | |
| sha256 "${{ steps.sha256.outputs.sha256 }}" | |
| license "MIT" | |
| head "https://github.com/Strand-AI/lambda-cli.git", branch: "main" | |
| depends_on "rust" => :build | |
| def install | |
| system "cargo", "build", "--release" | |
| bin.install "target/release/lambda" | |
| bin.install "target/release/lambda-mcp" | |
| end | |
| test do | |
| assert_match "lambda", shell_output("#{bin}/lambda --version") | |
| end | |
| end | |
| EOF | |
| - name: Commit and push | |
| run: | | |
| cd homebrew-tap | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/lambda-cli.rb | |
| git commit -m "lambda-cli: update to ${{ needs.check-version.outputs.version }}" | |
| git push | |
| publish-npm: | |
| needs: [check-version, release, build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.check-version.outputs.version }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Download npm package artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: npm-lambda-mcp-* | |
| path: npm-packages | |
| - name: Publish platform packages | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| for pkg_dir in npm-packages/npm-lambda-mcp-*/; do | |
| echo "Publishing $pkg_dir" | |
| cd "$pkg_dir" | |
| npm publish --access public | |
| cd - | |
| done | |
| - name: Prepare and publish main package | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| cd npm/lambda-mcp | |
| # Update version in package.json | |
| sed -i 's/"version": "0.0.0"/"version": "${{ needs.check-version.outputs.version }}"/' package.json | |
| # Update optional dependency versions | |
| sed -i 's/"@strand-ai\/lambda-mcp-linux-x64": "0.0.0"/"@strand-ai\/lambda-mcp-linux-x64": "${{ needs.check-version.outputs.version }}"/' package.json | |
| sed -i 's/"@strand-ai\/lambda-mcp-darwin-x64": "0.0.0"/"@strand-ai\/lambda-mcp-darwin-x64": "${{ needs.check-version.outputs.version }}"/' package.json | |
| sed -i 's/"@strand-ai\/lambda-mcp-darwin-arm64": "0.0.0"/"@strand-ai\/lambda-mcp-darwin-arm64": "${{ needs.check-version.outputs.version }}"/' package.json | |
| sed -i 's/"@strand-ai\/lambda-mcp-win32-x64": "0.0.0"/"@strand-ai\/lambda-mcp-win32-x64": "${{ needs.check-version.outputs.version }}"/' package.json | |
| npm install | |
| npm run build | |
| npm publish --access public |