Merge pull request #598 from vinhnx/dependabot/cargo/all-rust-deps-78… #270
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: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: 'Tag to release (e.g., v0.73.0)' | ||
| required: true | ||
| type: string | ||
| permissions: | ||
| contents: write | ||
| packages: write | ||
| jobs: | ||
| build: | ||
| name: Build (${{ matrix.target }}) | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: macos-latest | ||
| target: x86_64-apple-darwin | ||
| - os: macos-latest | ||
| target: aarch64-apple-darwin | ||
| - os: ubuntu-latest | ||
| target: x86_64-unknown-linux-gnu | ||
| - os: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| - os: windows-latest | ||
| target: aarch64-pc-windows-msvc | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| sparse-checkout: | | ||
| !docs/ | ||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: ${{ matrix.target }} | ||
| - name: Rust Cache | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| key: ${{ matrix.target }} | ||
| - name: Install Cross | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: cargo install cross --git https://github.com/cross-rs/cross.git | ||
| - name: Build (MacOS) | ||
| if: matrix.os == 'macos-latest' | ||
| run: cargo build --release --target ${{ matrix.target }} | ||
| - name: Build (Linux) | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: cross build --release --target ${{ matrix.target }} | ||
| - name: Build (Windows) | ||
| if: matrix.os == 'windows-latest' | ||
| run: cargo build --release --target ${{ matrix.target }} | ||
| - name: Check Binary | ||
| shell: bash | ||
| run: | | ||
| echo "Looking for binary in target/${{ matrix.target }}/release/" | ||
| ls -lah target/${{ matrix.target }}/release/ | grep -E "vtcode|binary" || echo "No binary found" | ||
| if [ -f "target/${{ matrix.target }}/release/vtcode" ]; then | ||
| echo "✓ Found Unix binary: vtcode" | ||
| elif [ -f "target/${{ matrix.target }}/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/${{ matrix.target }}/release | ||
| # Handle both Unix (vtcode) and Windows (vtcode.exe) binaries | ||
| if [ -f "vtcode.exe" ]; then | ||
| BINARY="vtcode.exe" | ||
| else | ||
| BINARY="vtcode" | ||
| fi | ||
| echo "Packaging: $BINARY" | ||
| tar -czf ../../../vtcode-${{ github.event.inputs.tag }}-${{ matrix.target }}.tar.gz "$BINARY" | ||
| cd ../../../ | ||
| echo "Computing SHA256..." | ||
| shasum -a 256 vtcode-${{ github.event.inputs.tag }}-${{ matrix.target }}.tar.gz > vtcode-${{ github.event.inputs.tag }}-${{ matrix.target }}.sha256 | ||
| echo "✓ Package complete:" | ||
| ls -lh vtcode-${{ github.event.inputs.tag }}-${{ matrix.target }}.* | ||
| - name: Upload Artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: artifacts-${{ matrix.target }} | ||
| path: | | ||
| vtcode-${{ github.event.inputs.tag }}-${{ matrix.target }}.tar.gz | ||
| vtcode-${{ github.event.inputs.tag }}-${{ matrix.target }}.sha256 | ||
| if-no-files-found: error | ||
| build-summary: | ||
| name: Build Summary | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| if: always() | ||
| steps: | ||
| - name: Check Build Results | ||
| run: | | ||
| echo "Build Status: ${{ needs.build.result }}" | ||
| if [ "${{ needs.build.result }}" != "success" ]; then | ||
| echo "⚠️ Some builds may have failed. Check the build job logs above." | ||
| fi | ||
| create-release: | ||
| name: Create Release | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| sparse-checkout: | | ||
| !docs/ | ||
| - name: Download Artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
| merge-multiple: true | ||
| - name: List Downloaded Artifacts | ||
| run: | | ||
| echo "=== Downloaded Artifacts ===" | ||
| find artifacts -type f | sort | ||
| echo "" | ||
| echo "Total files: $(find artifacts -type f | wc -l)" | ||
| - name: Generate Changelog | ||
| id: changelog | ||
| run: | | ||
| # Get the previous tag | ||
| PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "${{ github.event.inputs.tag }}" | head -n 1) | ||
| if [ -z "$PREV_TAG" ]; then | ||
| CHANGELOG=$(npx changelogithub --dry 2>/dev/null || git log HEAD --no-merges --pretty=format:"* %s") | ||
| else | ||
| CHANGELOG=$(npx changelogithub --dry --from "$PREV_TAG" --to HEAD 2>/dev/null || git log "$PREV_TAG"..HEAD --no-merges --pretty=format:"* %s") | ||
| fi | ||
| # Extract the changelog content between separators (remove the --- lines) | ||
| CHANGELOG=$(echo "$CHANGELOG" | sed -n '/^-*$/,/^-*$/p' | sed '1d;$d') | ||
| # Save to file for use in release | ||
| echo "$CHANGELOG" > release_notes.md | ||
| echo "CHANGELOG_CONTENT<<EOF" >> $GITHUB_ENV | ||
| echo "$CHANGELOG" >> $GITHUB_ENV | ||
| echo "EOF" >> $GITHUB_ENV | ||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ github.event.inputs.tag }} | ||
| files: | | ||
| artifacts/*.tar.gz | ||
| artifacts/*.sha256 | ||
| body_path: release_notes.md | ||
| draft: false | ||
| prerelease: false | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||