mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-13 08:06:41 +00:00
154 lines
5.2 KiB
YAML
154 lines
5.2 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Tag to release, for example v0.1.0'
|
|
required: true
|
|
type: string
|
|
|
|
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@v7
|
|
with:
|
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
|
|
|
|
- name: Derive version
|
|
id: version
|
|
shell: bash
|
|
env:
|
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
|
|
run: |
|
|
VERSION="${RELEASE_TAG#v}"
|
|
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
GIT_SHA="$(git rev-parse HEAD)"
|
|
{
|
|
echo "tag=${RELEASE_TAG}"
|
|
echo "version=${VERSION}"
|
|
echo "build_time=${BUILD_TIME}"
|
|
echo "git_sha=${GIT_SHA}"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Verify Cargo package version
|
|
env:
|
|
RELEASE_VERSION: ${{ steps.version.outputs.version }}
|
|
run: |
|
|
PACKAGE_VERSION="$(python3 - <<'PY'
|
|
import pathlib
|
|
import tomllib
|
|
|
|
manifest = tomllib.loads(pathlib.Path("backend/Cargo.toml").read_text())
|
|
print(manifest["package"]["version"])
|
|
PY
|
|
)"
|
|
|
|
if [ "${PACKAGE_VERSION}" != "${RELEASE_VERSION}" ]; then
|
|
echo "Tag version ${RELEASE_VERSION} does not match backend/Cargo.toml package version ${PACKAGE_VERSION}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: Setup QEMU
|
|
uses: docker/setup-qemu-action@v4
|
|
|
|
- name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Package release assets
|
|
shell: bash
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
rm -rf dist-package checksums.txt
|
|
|
|
docker buildx build \
|
|
--file deploy/Dockerfile \
|
|
--target release-asset \
|
|
--platform linux/amd64,linux/arm64 \
|
|
--output type=local,dest=dist-package \
|
|
--cache-from type=gha,scope=release \
|
|
--cache-to type=gha,mode=max,scope=release \
|
|
--build-arg CPR_VERSION="${VERSION}" \
|
|
--build-arg CPR_GIT_SHA="${{ steps.version.outputs.git_sha }}" \
|
|
--build-arg CPR_BUILD_TIME="${{ steps.version.outputs.build_time }}" \
|
|
--build-arg CPR_BUILD_TYPE=release \
|
|
.
|
|
|
|
find dist-package -type f -name 'codex-proxy-rs_*.tar.gz' -exec cp {} . \;
|
|
test -f "codex-proxy-rs_${VERSION}_linux_amd64.tar.gz"
|
|
test -f "codex-proxy-rs_${VERSION}_linux_arm64.tar.gz"
|
|
sha256sum "codex-proxy-rs_${VERSION}_linux_amd64.tar.gz" \
|
|
"codex-proxy-rs_${VERSION}_linux_arm64.tar.gz" > checksums.txt
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push app image
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
file: deploy/Dockerfile
|
|
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 }}
|
|
CPR_BUILD_TYPE=release
|
|
cache-from: type=gha,scope=release
|
|
cache-to: type=gha,mode=max,scope=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-${{ steps.version.outputs.git_sha }}
|
|
|
|
- name: Publish GitHub Release
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
tag_name: ${{ steps.version.outputs.tag }}
|
|
generate_release_notes: true
|
|
body: |
|
|
## Installation
|
|
|
|
**Docker:**
|
|
```bash
|
|
# GitHub Container Registry
|
|
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
|
```
|
|
|
|
**Manual download:**
|
|
Download the appropriate archive for your platform from the assets below.
|
|
|
|
## Documentation
|
|
|
|
- [GitHub Repository](https://github.com/${{ github.repository }})
|
|
- [Installation Guide](https://github.com/${{ github.repository }}/blob/main/deploy/README.md)
|
|
files: |
|
|
codex-proxy-rs_${{ steps.version.outputs.version }}_linux_amd64.tar.gz
|
|
codex-proxy-rs_${{ steps.version.outputs.version }}_linux_arm64.tar.gz
|
|
checksums.txt
|