Skip to content

Build Linux Binaries (Windows Optional) #19

Build Linux Binaries (Windows Optional)

Build Linux Binaries (Windows Optional) #19

name: Build Linux Binaries (Windows Optional)
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (e.g., 0.81.2)'
required: true
type: string
build_windows:
description: 'Also build Windows x86_64 binary (higher runner cost)'
required: false
type: boolean
default: false
workflow_call:
inputs:
tag:
description: 'Tag to build (e.g., 0.81.2)'
required: true
type: string
build_windows:
description: 'Also build Windows x86_64 binary (higher runner cost)'
required: false
type: boolean
default: false
permissions:
contents: write
actions: read
# Cost optimization:
# - Linux builds run on ubuntu-latest using Cross (lower cost)
# - Windows build is opt-in only
# - Minimal artifact retention (7 days)
# - Efficient caching
jobs:
build-linux:
name: Build (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag }}
fetch-depth: 1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: rustfmt
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: ${{ matrix.target }}
- name: Install Cross
run: cargo install cross --git https://github.com/cross-rs/cross.git --locked
- name: Build (${{ matrix.target }})
run: cross build --release --target ${{ matrix.target }}
shell: bash
- name: Verify Linux TLS linkage
shell: bash
run: |
if cargo tree -e normal -i native-tls --target ${{ matrix.target }}; then
echo "✗ native-tls detected in Linux dependency graph" >&2
exit 1
fi
if cargo tree -e normal -i openssl-sys --target ${{ matrix.target }}; then
echo "✗ openssl-sys detected in Linux dependency graph" >&2
exit 1
fi
echo "✓ Linux dependency graph is rustls-only (no native-tls/openssl-sys)"
- name: Check Binary
shell: bash
run: |
if [ -f "target/${{ matrix.target }}/release/vtcode" ]; then
echo "✓ Found Unix binary: vtcode"
else
echo "✗ Binary not found!" && exit 1
fi
- name: Package
shell: bash
run: |
cd target/${{ matrix.target }}/release
tar -czf ../../../vtcode-${{ inputs.tag }}-${{ matrix.target }}.tar.gz vtcode
cd ../../../
if command -v sha256sum &> /dev/null; then
sha256sum vtcode-${{ inputs.tag }}-${{ matrix.target }}.tar.gz > vtcode-${{ inputs.tag }}-${{ matrix.target }}.sha256
elif command -v shasum &> /dev/null; then
shasum -a 256 vtcode-${{ inputs.tag }}-${{ matrix.target }}.tar.gz > vtcode-${{ inputs.tag }}-${{ matrix.target }}.sha256
fi
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: vtcode-${{ inputs.tag }}-${{ matrix.target }}
path: |
vtcode-${{ inputs.tag }}-${{ matrix.target }}.tar.gz
vtcode-${{ inputs.tag }}-${{ matrix.target }}.sha256
if-no-files-found: error
retention-days: 7
compression-level: 6
build-windows:
if: ${{ inputs.build_windows == true || github.event.inputs.build_windows == 'true' }}
name: Build (x86_64-pc-windows-msvc)
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag }}
fetch-depth: 1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
components: rustfmt
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: x86_64-pc-windows-msvc
- name: Build (x86_64-pc-windows-msvc)
run: cargo build --release --target x86_64-pc-windows-msvc
shell: bash
- name: Check Binary
shell: bash
run: |
if [ -f "target/x86_64-pc-windows-msvc/release/vtcode.exe" ]; then
echo "✓ Found Windows binary: vtcode.exe"
else
echo "✗ Binary not found!" && exit 1
fi
- name: Package
shell: bash
run: |
cd target/x86_64-pc-windows-msvc/release
tar -czf ../../../vtcode-${{ inputs.tag }}-x86_64-pc-windows-msvc.tar.gz vtcode.exe
cd ../../../
if command -v sha256sum &> /dev/null; then
sha256sum vtcode-${{ inputs.tag }}-x86_64-pc-windows-msvc.tar.gz > vtcode-${{ inputs.tag }}-x86_64-pc-windows-msvc.sha256
elif command -v shasum &> /dev/null; then
shasum -a 256 vtcode-${{ inputs.tag }}-x86_64-pc-windows-msvc.tar.gz > vtcode-${{ inputs.tag }}-x86_64-pc-windows-msvc.sha256
fi
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: vtcode-${{ inputs.tag }}-x86_64-pc-windows-msvc
path: |
vtcode-${{ inputs.tag }}-x86_64-pc-windows-msvc.tar.gz
vtcode-${{ inputs.tag }}-x86_64-pc-windows-msvc.sha256
if-no-files-found: error
retention-days: 7
compression-level: 6