Initial commit
This commit is contained in:
134
.github/workflows/build.yml
vendored
Normal file
134
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
name: Multi-platform Build Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Version tag, for example v1.0.0"
|
||||
required: false
|
||||
default: "dev"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
source_name: codex-console.exe
|
||||
asset_name: codex-console-windows-x64.exe
|
||||
- os: ubuntu-latest
|
||||
source_name: codex-console
|
||||
asset_name: codex-console-linux-x64
|
||||
- os: macos-latest
|
||||
source_name: codex-console
|
||||
asset_name: codex-console-macos-arm64
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python 3.11
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.11"
|
||||
cache: "pip"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -r requirements.txt pyinstaller
|
||||
|
||||
- name: Build binary
|
||||
run: |
|
||||
pyinstaller codex_register.spec --clean --noconfirm
|
||||
|
||||
- name: Rename packaged binary
|
||||
shell: bash
|
||||
run: |
|
||||
mv "dist/${{ matrix.source_name }}" "dist/${{ matrix.asset_name }}"
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.asset_name }}
|
||||
path: dist/${{ matrix.asset_name }}
|
||||
if-no-files-found: error
|
||||
|
||||
release:
|
||||
name: Create release
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: dist/
|
||||
|
||||
- name: Bundle release archives
|
||||
run: |
|
||||
mkdir -p release
|
||||
find dist/ -type f | while read f; do
|
||||
name=$(basename "$f")
|
||||
case "$name" in
|
||||
*windows*) platform=$(echo "$name" | sed 's/\.[^.]*$//') ;;
|
||||
*linux*) platform="$name" ;;
|
||||
*macos*) platform="$name" ;;
|
||||
*) platform="$name" ;;
|
||||
esac
|
||||
tmpdir="tmp_${platform}"
|
||||
mkdir -p "$tmpdir"
|
||||
cp "$f" "$tmpdir/"
|
||||
cp README.md "$tmpdir/README.md"
|
||||
cp .env.example "$tmpdir/.env.example"
|
||||
[ -f LICENSE ] && cp LICENSE "$tmpdir/LICENSE" || true
|
||||
cd "$tmpdir"
|
||||
zip -r "../release/${platform}.zip" .
|
||||
cd ..
|
||||
rm -rf "$tmpdir"
|
||||
done
|
||||
ls -lh release/
|
||||
|
||||
- name: Create GitHub release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: release/*
|
||||
generate_release_notes: true
|
||||
body: |
|
||||
## codex-console
|
||||
|
||||
### Download
|
||||
| Platform | File |
|
||||
|------|------|
|
||||
| Windows x64 | `codex-console-windows-x64.exe` |
|
||||
| Linux x64 | `codex-console-linux-x64` |
|
||||
| macOS ARM64 | `codex-console-macos-arm64` |
|
||||
|
||||
### Usage
|
||||
```bash
|
||||
# Linux/macOS may need execute permission first
|
||||
chmod +x codex-console-*
|
||||
|
||||
# Start Web UI
|
||||
./codex-console
|
||||
|
||||
# Custom port
|
||||
./codex-console --port 8080
|
||||
|
||||
# Debug mode
|
||||
./codex-console --debug
|
||||
|
||||
# Set Web UI password
|
||||
./codex-console --access-password mypassword
|
||||
```
|
||||
68
.github/workflows/docker-publish.yml
vendored
Normal file
68
.github/workflows/docker-publish.yml
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master", "main" ]
|
||||
# 当发布新版本时触发
|
||||
tags: [ 'v*.*.*' ]
|
||||
pull_request:
|
||||
branches: [ "master", "main" ]
|
||||
|
||||
env:
|
||||
# GitHub Container Registry 的地址
|
||||
REGISTRY: ghcr.io
|
||||
# 镜像名称,默认为 GitHub 用户名/仓库名
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
# 如果需要签名生成的镜像,可以使用 id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# 设置 Docker Buildx 用于构建多平台镜像 (可选)
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 登录到 Docker 镜像仓库
|
||||
# 如果只是在 PR 中测试构建,则跳过登录
|
||||
- name: Log in to the Container registry
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# 提取 Docker 镜像的元数据(标签、注释等)
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=schedule
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
# 构建并推送 Docker 镜像
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
Reference in New Issue
Block a user