Skip to content

Commit e08caf5

Browse files
committed
Add build, push, and release GitHub workflow
Introduces a new GitHub Actions workflow for building, publishing Docker images, and creating releases. Updates Directory.Packages.props to set a fixed version (0.9.1) and removes VersionSuffix. Adds the workflow file to the solution items in KoalaWiki.sln.
1 parent 3bf081d commit e08caf5

File tree

3 files changed

+159
-2
lines changed

3 files changed

+159
-2
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Build, Push Image, and Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- "Directory.Packages.props"
8+
- ".github/workflows/build-and-release.yml"
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
packages: write
14+
15+
env:
16+
FRONTEND_DIR: web-site
17+
BACKEND_PROJECT: src/KoalaWiki/KoalaWiki.csproj
18+
DOCKERFILE: src/KoalaWiki/Dockerfile
19+
20+
jobs:
21+
build-push-and-release:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Setup .NET
31+
uses: actions/setup-dotnet@v4
32+
with:
33+
dotnet-version: 9.0.x
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: 20
39+
cache: 'npm'
40+
cache-dependency-path: |
41+
web-site/package-lock.json
42+
43+
- name: Compute image name (lowercase)
44+
shell: bash
45+
run: |
46+
echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/koala-wiki" >> $GITHUB_ENV
47+
48+
- name: Read version from Directory.Packages.props
49+
id: version
50+
shell: pwsh
51+
run: |
52+
[xml]$xml = Get-Content -Raw "Directory.Packages.props"
53+
$v = $xml.Project.PropertyGroup.Version
54+
if (-not $v) { throw "Version not found in Directory.Packages.props" }
55+
echo "PKG_VERSION=$v" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
56+
echo "RELEASE_TAG=v$($v)" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
57+
Write-Host "Using version: $v"
58+
59+
- name: Build frontend (Vite -> src/KoalaWiki/wwwroot)
60+
working-directory: ${{ env.FRONTEND_DIR }}
61+
run: |
62+
npm ci
63+
npm run build
64+
65+
- name: Show wwwroot summary
66+
run: |
67+
echo "Built frontend into src/KoalaWiki/wwwroot"
68+
ls -la src/KoalaWiki/wwwroot | head -n 50
69+
70+
- name: Restore .NET
71+
run: dotnet restore KoalaWiki.sln
72+
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v3
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v3
78+
79+
- name: Login to GitHub Container Registry
80+
uses: docker/login-action@v3
81+
with:
82+
registry: ghcr.io
83+
username: ${{ github.actor }}
84+
password: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Optional login to Aliyun Registry
87+
if: ${{ secrets.ALIYUN_REGISTRY != '' && secrets.ALIYUN_USERNAME != '' && secrets.ALIYUN_PASSWORD != '' }}
88+
uses: docker/login-action@v3
89+
with:
90+
registry: ${{ secrets.ALIYUN_REGISTRY }}
91+
username: ${{ secrets.ALIYUN_USERNAME }}
92+
password: ${{ secrets.ALIYUN_PASSWORD }}
93+
94+
- name: Build and push multi-arch Docker image (GHCR)
95+
uses: docker/build-push-action@v6
96+
with:
97+
context: .
98+
file: ${{ env.DOCKERFILE }}
99+
platforms: linux/amd64,linux/arm64
100+
push: true
101+
tags: |
102+
${{ env.IMAGE_NAME }}:v${{ env.PKG_VERSION }}
103+
${{ env.IMAGE_NAME }}:latest
104+
build-args: |
105+
BUILD_CONFIGURATION=Release
106+
107+
- name: Build and push image to Aliyun (optional)
108+
if: ${{ secrets.ALIYUN_REGISTRY != '' && secrets.ALIYUN_USERNAME != '' && secrets.ALIYUN_PASSWORD != '' }}
109+
uses: docker/build-push-action@v6
110+
with:
111+
context: .
112+
file: ${{ env.DOCKERFILE }}
113+
platforms: linux/amd64,linux/arm64
114+
push: true
115+
tags: |
116+
${{ secrets.ALIYUN_REGISTRY }}/koala-ai/koala-wiki:v${{ env.PKG_VERSION }}
117+
${{ secrets.ALIYUN_REGISTRY }}/koala-ai/koala-wiki:latest
118+
build-args: |
119+
BUILD_CONFIGURATION=Release
120+
121+
- name: Publish multi-platform backend packages
122+
shell: pwsh
123+
run: |
124+
$ErrorActionPreference = 'Stop'
125+
$rids = @('win-x64','linux-x64','linux-arm64','osx-arm64')
126+
foreach ($rid in $rids) {
127+
$outDir = "out/$rid"
128+
dotnet publish "${{ env.BACKEND_PROJECT }}" -c Release -r $rid --self-contained false -p:Version="${{ env.PKG_VERSION }}" -o $outDir
129+
$zip = "OpenDeepWiki-${{ env.PKG_VERSION }}-$rid.zip"
130+
if (Test-Path $zip) { Remove-Item $zip -Force }
131+
Compress-Archive -Path "$outDir/*" -DestinationPath $zip
132+
}
133+
134+
- name: Upload build artifacts
135+
uses: actions/upload-artifact@v4
136+
with:
137+
name: OpenDeepWiki-${{ env.PKG_VERSION }}
138+
path: |
139+
OpenDeepWiki-${{ env.PKG_VERSION }}-win-x64.zip
140+
OpenDeepWiki-${{ env.PKG_VERSION }}-linux-x64.zip
141+
OpenDeepWiki-${{ env.PKG_VERSION }}-linux-arm64.zip
142+
OpenDeepWiki-${{ env.PKG_VERSION }}-osx-arm64.zip
143+
if-no-files-found: error
144+
retention-days: 14
145+
146+
- name: Create GitHub Release
147+
uses: softprops/action-gh-release@v2
148+
with:
149+
tag_name: ${{ env.RELEASE_TAG }}
150+
name: OpenDeepWiki ${{ env.PKG_VERSION }}
151+
files: |
152+
OpenDeepWiki-${{ env.PKG_VERSION }}-win-x64.zip
153+
OpenDeepWiki-${{ env.PKG_VERSION }}-linux-x64.zip
154+
OpenDeepWiki-${{ env.PKG_VERSION }}-linux-arm64.zip
155+
OpenDeepWiki-${{ env.PKG_VERSION }}-osx-arm64.zip
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Directory.Packages.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<Project>
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4-
<VersionSuffix>1</VersionSuffix>
54
<TimeStamp>$([System.DateTime]::UtcNow.ToString("yyyyMMdd"))</TimeStamp>
6-
<Version>0.9.$(VersionSuffix)</Version>
5+
<Version>0.9.1</Version>
76
<!-- 项目信息 -->
87
<Product>OpenDeepWiki</Product>
98
<Title>OpenDeepWiki - AI驱动的代码知识库</Title>

KoalaWiki.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2020
NuGet.Config = NuGet.Config
2121
README.md = README.md
2222
README.zh-CN.md = README.zh-CN.md
23+
.github\workflows\release.yml = .github\workflows\release.yml
2324
EndProjectSection
2425
EndProject
2526
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KoalaWiki.Core", "KoalaWiki.Core\KoalaWiki.Core.csproj", "{8E887B45-75E2-4264-B5DE-93C9E206495E}"

0 commit comments

Comments
 (0)