mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-15 08:06:21 +00:00
feat: add docker online update flow
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: zyycn/codex-proxy-rs
|
||||
UPDATER_IMAGE_NAME: zyycn/codex-proxy-rs-updater
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Derive version
|
||||
id: version
|
||||
shell: bash
|
||||
run: |
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "build_time=${BUILD_TIME}" >> "$GITHUB_OUTPUT"
|
||||
echo "git_sha=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
|
||||
- name: Enable pnpm
|
||||
run: corepack enable
|
||||
|
||||
- name: Install frontend dependencies
|
||||
run: pnpm --dir web install --frozen-lockfile
|
||||
|
||||
- name: Build frontend
|
||||
run: pnpm --dir web build
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@1.95
|
||||
|
||||
- name: Cache Rust
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Build release binaries
|
||||
env:
|
||||
CPR_VERSION: ${{ steps.version.outputs.version }}
|
||||
CPR_GIT_SHA: ${{ steps.version.outputs.git_sha }}
|
||||
CPR_BUILD_TIME: ${{ steps.version.outputs.build_time }}
|
||||
run: cargo build --release --locked --bins
|
||||
|
||||
- name: Package release assets
|
||||
shell: bash
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
PACKAGE_DIR="dist-package/codex-proxy-rs"
|
||||
mkdir -p "${PACKAGE_DIR}"
|
||||
cp target/release/codex-proxy-rs "${PACKAGE_DIR}/"
|
||||
cp target/release/codex-proxy-rs-updater "${PACKAGE_DIR}/"
|
||||
cp -r web/dist "${PACKAGE_DIR}/web-dist"
|
||||
tar -czf "codex-proxy-rs_${VERSION}_linux_x86_64.tar.gz" -C dist-package codex-proxy-rs
|
||||
sha256sum "codex-proxy-rs_${VERSION}_linux_x86_64.tar.gz" > checksums.txt
|
||||
|
||||
- name: Setup QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push app image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
target: runtime
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
build-args: |
|
||||
CPR_VERSION=${{ steps.version.outputs.version }}
|
||||
CPR_GIT_SHA=${{ steps.version.outputs.git_sha }}
|
||||
CPR_BUILD_TIME=${{ steps.version.outputs.build_time }}
|
||||
labels: |
|
||||
org.opencontainers.image.title=Codex Proxy RS
|
||||
org.opencontainers.image.version=${{ steps.version.outputs.version }}
|
||||
org.opencontainers.image.revision=${{ steps.version.outputs.git_sha }}
|
||||
org.opencontainers.image.source=https://github.com/zyycn/codex-proxy-rs
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${{ github.sha }}
|
||||
|
||||
- name: Build and push updater image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
target: updater-runtime
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
build-args: |
|
||||
CPR_VERSION=${{ steps.version.outputs.version }}
|
||||
CPR_GIT_SHA=${{ steps.version.outputs.git_sha }}
|
||||
CPR_BUILD_TIME=${{ steps.version.outputs.build_time }}
|
||||
labels: |
|
||||
org.opencontainers.image.title=Codex Proxy RS Updater
|
||||
org.opencontainers.image.version=${{ steps.version.outputs.version }}
|
||||
org.opencontainers.image.revision=${{ steps.version.outputs.git_sha }}
|
||||
org.opencontainers.image.source=https://github.com/zyycn/codex-proxy-rs
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.UPDATER_IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
||||
${{ env.REGISTRY }}/${{ env.UPDATER_IMAGE_NAME }}:latest
|
||||
${{ env.REGISTRY }}/${{ env.UPDATER_IMAGE_NAME }}:sha-${{ github.sha }}
|
||||
|
||||
- name: Publish GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
codex-proxy-rs_${{ steps.version.outputs.version }}_linux_x86_64.tar.gz
|
||||
checksums.txt
|
||||
Reference in New Issue
Block a user