mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 08:06:19 +00:00
121 lines
3.8 KiB
YAML
121 lines
3.8 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: zyycn/codex-proxy-rs
|
|
|
|
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: Write VERSION file
|
|
shell: bash
|
|
run: printf '%s\n' '${{ steps.version.outputs.version }}' > backend/build/VERSION
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
|
|
- name: Enable pnpm
|
|
run: |
|
|
corepack enable
|
|
corepack prepare pnpm@11.7.0 --activate
|
|
|
|
- name: Install frontend dependencies
|
|
run: pnpm --dir frontend install --frozen-lockfile
|
|
|
|
- name: Build frontend
|
|
run: pnpm --dir frontend build
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Cache Rust
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: backend -> target
|
|
|
|
- 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 }}
|
|
CPR_BUILD_TYPE: release
|
|
run: cargo build --manifest-path backend/Cargo.toml --release --locked --bin codex-proxy-rs
|
|
|
|
- name: Package release assets
|
|
shell: bash
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
PACKAGE_DIR="dist-package/codex-proxy-rs"
|
|
mkdir -p "${PACKAGE_DIR}/web"
|
|
cp backend/target/release/codex-proxy-rs "${PACKAGE_DIR}/"
|
|
cp -r frontend/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 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: .
|
|
file: deploy/Dockerfile
|
|
target: runtime
|
|
platforms: linux/amd64
|
|
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 }}
|
|
CPR_BUILD_TYPE=release
|
|
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: 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
|