feat: add AI-powered auto context compression with configurable token… #47
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 Build and Push Docker Images | |
| on: | |
| release: | |
| types: [published] | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - Directory.Packages.props | |
| permissions: | |
| contents: write | |
| jobs: | |
| push-release-build: | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Extract version from Directory.Packages.props | |
| id: get_version | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| [xml]$xml = Get-Content -Raw 'Directory.Packages.props' | |
| $pg = $xml.Project.PropertyGroup | |
| $versionTemplate = [string]$pg.Version | |
| if ([string]::IsNullOrWhiteSpace($versionTemplate)) { throw 'Version not found in Directory.Packages.props' } | |
| $props = @{} | |
| foreach ($n in $pg.ChildNodes) { | |
| if ($n.NodeType -eq [System.Xml.XmlNodeType]::Element) { | |
| $props[$n.Name] = [string]$n.InnerText | |
| } | |
| } | |
| $props['TimeStamp'] = (Get-Date -AsUTC).ToString('yyyyMMdd') | |
| $unresolved = New-Object System.Collections.Generic.List[string] | |
| $finalVersion = [regex]::Replace($versionTemplate, '\$\(([A-Za-z0-9_.-]+)\)', { | |
| param($m) | |
| $name = $m.Groups[1].Value | |
| if ($props.ContainsKey($name) -and -not [string]::IsNullOrWhiteSpace($props[$name])) { $props[$name] } else { $unresolved.Add($name) | Out-Null; '' } | |
| }) | |
| if ($unresolved.Count -gt 0) { Write-Host "[warn] Unresolved version tokens -> $($unresolved -join ', ')" } | |
| if ([string]::IsNullOrWhiteSpace($finalVersion)) { throw 'Resolved version is empty' } | |
| "version=$finalVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 | |
| Write-Host "Version template: $versionTemplate" | |
| Write-Host "Final version: $finalVersion" | |
| - name: Create GitHub Release v${{ steps.get_version.outputs.version }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.get_version.outputs.version }} | |
| name: v${{ steps.get_version.outputs.version }} | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| make_latest: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install frontend dependencies | |
| working-directory: web-site | |
| run: npm i | |
| - name: Build frontend (outputs to backend wwwroot) | |
| working-directory: web-site | |
| run: npm run build | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push koala-wiki (v${{ steps.get_version.outputs.version }}) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: src/KoalaWiki/Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:latest | |
| crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:${{ steps.get_version.outputs.version }} | |
| release-build: | |
| if: github.event_name == 'release' && github.actor != 'github-actions[bot]' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout tag | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.release.tag_name }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install frontend dependencies | |
| working-directory: web-site | |
| run: npm i | |
| - name: Build frontend (outputs to backend wwwroot) | |
| working-directory: web-site | |
| run: npm run build | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract version from release tag | |
| id: get_version | |
| shell: pwsh | |
| run: | | |
| $tag = '${{ github.event.release.tag_name }}' | |
| if ([string]::IsNullOrWhiteSpace($tag)) { throw 'Release tag name is empty' } | |
| $ver = if ($tag.StartsWith('v')) { $tag.Substring(1) } else { $tag } | |
| "version=$ver" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 | |
| Write-Host "Release tag: $tag" | |
| Write-Host "Version: $ver" | |
| - name: Build and push koala-wiki | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: src/KoalaWiki/Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:latest | |
| crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:${{ steps.get_version.outputs.version }} |