支持一键安装脚本

This commit is contained in:
xintaofei
2026-03-29 19:46:41 +08:00
parent 1cda9aa5f5
commit a49b59e403
13 changed files with 996 additions and 163 deletions

View File

@@ -21,6 +21,7 @@ jobs:
outputs:
release_id: ${{ steps.release.outputs.release_id }}
release_url: ${{ steps.release.outputs.release_url }}
upload_url: ${{ steps.release.outputs.upload_url }}
prerelease: ${{ steps.meta.outputs.prerelease }}
release_body: ${{ steps.release.outputs.release_body }}
steps:
@@ -161,6 +162,7 @@ jobs:
core.setOutput("release_id", String(release.id));
core.setOutput("release_url", release.html_url);
core.setOutput("upload_url", release.upload_url);
core.setOutput("release_body", releaseBody);
build-tauri:
@@ -332,6 +334,117 @@ jobs:
includeUpdaterJson: true
retryAttempts: 2
build-server:
needs: create-draft-release
name: Server ${{ matrix.name }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- name: "Linux x64"
runner: "ubuntu-22.04"
target: "x86_64-unknown-linux-gnu"
artifact: "codeg-server-linux-x64"
- name: "Linux arm64"
runner: "ubuntu-22.04"
target: "aarch64-unknown-linux-gnu"
artifact: "codeg-server-linux-arm64"
- name: "macOS x64"
runner: "macos-latest"
target: "x86_64-apple-darwin"
artifact: "codeg-server-darwin-x64"
- name: "macOS arm64"
runner: "macos-latest"
target: "aarch64-apple-darwin"
artifact: "codeg-server-darwin-arm64"
- name: "Windows x64"
runner: "windows-2022"
target: "x86_64-pc-windows-msvc"
artifact: "codeg-server-windows-x64"
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"
shared-key: server-${{ matrix.target }}
- name: Install Linux arm64 cross compiler
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
run_install: false
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Build frontend
run: |
pnpm install --frozen-lockfile
pnpm build
- name: Build server binary
working-directory: src-tauri
run: cargo build --release --bin codeg-server --no-default-features --target ${{ matrix.target }}
- name: Package (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p dist/${{ matrix.artifact }}
cp src-tauri/target/${{ matrix.target }}/release/codeg-server dist/${{ matrix.artifact }}/
cp -r out dist/${{ matrix.artifact }}/web
cd dist && tar czf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist/${{ matrix.artifact }}
Copy-Item src-tauri/target/${{ matrix.target }}/release/codeg-server.exe dist/${{ matrix.artifact }}/
Copy-Item -Recurse out dist/${{ matrix.artifact }}/web
Compress-Archive -Path dist/${{ matrix.artifact }} -DestinationPath dist/${{ matrix.artifact }}.zip
- name: Upload to release (Unix)
if: runner.os != 'Windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
asset_path: dist/${{ matrix.artifact }}.tar.gz
asset_name: ${{ matrix.artifact }}.tar.gz
asset_content_type: application/gzip
- name: Upload to release (Windows)
if: runner.os == 'Windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
asset_path: dist/${{ matrix.artifact }}.zip
asset_name: ${{ matrix.artifact }}.zip
asset_content_type: application/zip
build-docker:
needs: create-draft-release
name: Build Docker image
@@ -383,7 +496,8 @@ jobs:
needs:
- create-draft-release
- build-tauri
if: ${{ needs.build-tauri.result == 'success' }}
- build-server
if: ${{ needs.build-tauri.result == 'success' && needs.build-server.result == 'success' }}
runs-on: ubuntu-22.04
permissions:
contents: write