Update README.md #93
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 and Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-cli: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Read version from file | |
| id: version | |
| run: echo "VERSION_TAG=$(cat version.txt)" >> $env:GITHUB_OUTPUT | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r requirements-build.txt | |
| - name: Build CLI Executable | |
| run: | | |
| pyinstaller --onefile caption_openai.py | |
| - name: Create CLI Package | |
| run: | | |
| mkdir vlm-caption-cli | |
| copy dist\caption_openai.exe vlm-caption-cli\ | |
| copy caption.yaml vlm-caption-cli\ | |
| copy character_info.txt vlm-caption-cli\ | |
| copy *.MD vlm-caption-cli\ | |
| powershell Compress-Archive -Path vlm-caption-cli\* -DestinationPath vlm-caption-cli-v${{ steps.version.outputs.VERSION_TAG }}.${{ github.run_number }}.zip | |
| - name: Upload CLI Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vlm-caption-cli | |
| path: vlm-caption-cli-v${{ steps.version.outputs.VERSION_TAG }}.${{ github.run_number }}.zip | |
| build-electron: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Read version from file | |
| id: version | |
| run: echo "VERSION_TAG=$(cat version.txt)" >> $env:GITHUB_OUTPUT | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r requirements-build.txt | |
| - name: Install Node.js dependencies | |
| run: | | |
| cd ui | |
| npm install | |
| - name: Update package.json version | |
| run: | | |
| cd ui | |
| npm version ${{ steps.version.outputs.VERSION_TAG }}.${{ github.run_number }} --no-git-tag-version | |
| - name: Build Electron App | |
| timeout-minutes: 30 | |
| run: | | |
| cd ui | |
| npm run build:backend | |
| npm run build | |
| npx electron-builder --win --publish never | |
| - name: Upload Electron Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vlm-caption-electron | |
| path: ui/dist/*.exe | |
| create-release: | |
| runs-on: windows-latest | |
| needs: [build-cli, build-electron] | |
| permissions: | |
| contents: write | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download CLI Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: vlm-caption-cli | |
| - name: Download Electron Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: vlm-caption-electron | |
| - name: Read version from file | |
| id: version | |
| run: echo "VERSION_TAG=$(cat version.txt)" >> $env:GITHUB_OUTPUT | |
| - name: Generate Changelog | |
| id: changelog | |
| run: | | |
| # Get the latest release tag (excluding the current one we're about to create) | |
| $previousTag = git tag --sort=-version:refname | Where-Object { $_ -match '^v\d+\.\d+\.\d+$' } | Select-Object -First 1 | |
| if ($previousTag) { | |
| Write-Output "Previous tag found: $previousTag" | |
| # Get commit messages since the previous tag, format them nicely | |
| $commits = git log --pretty=format:"- %s" "$previousTag..HEAD" | |
| } else { | |
| Write-Output "No previous tag found, getting all commits" | |
| # If no previous tag exists, get all commits | |
| $commits = git log --pretty=format:"- %s" | |
| } | |
| # Filter out merge commits and format the changelog | |
| $changelog = $commits | Where-Object { $_ -notmatch "^- Merge " } | Out-String | |
| if (-not $changelog.Trim()) { | |
| $changelog = "- No new changes since last release" | |
| } | |
| # Trim trailing whitespace/newlines and escape newlines for GitHub Actions output | |
| $changelog = $changelog.Trim() -replace "`r`n", "%0A" -replace "`n", "%0A" | |
| echo "CHANGELOG=$changelog" >> $env:GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.VERSION_TAG }}.${{ github.run_number }} | |
| name: VLM Caption v${{ steps.version.outputs.VERSION_TAG }}.${{ github.run_number }} | |
| body: | | |
| Automated release containing both CLI and GUI versions of VLM Caption. | |
| 📦 **Downloads:** | |
| - `vlm-caption-cli-v${{ steps.version.outputs.VERSION_TAG }}.${{ github.run_number }}.zip` - Windows command-line (unzip and run) | |
| - `VLM_Caption_Setup_v${{ steps.version.outputs.VERSION_TAG }}.${{ github.run_number }}.exe` - GUI version (Windows installer) | |
| 🚀 **What's New:** | |
| ${{ steps.changelog.outputs.CHANGELOG }} | |
| files: | | |
| vlm-caption-cli-v*.zip | |
| VLM_Caption_Setup_v*.exe | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |