fix: update logo paths in README

This commit is contained in:
CaIon
2026-04-28 14:34:18 +08:00
parent a42b397607
commit c609cb13b2
9 changed files with 143 additions and 253 deletions
+137 -53
View File
@@ -1,89 +1,173 @@
name: Build and Push Docker Image
name: Publish Docker image (Multi-arch)
on:
push:
branches:
- main
tags:
- 'v*'
- '*'
- '!nightly*'
workflow_dispatch:
env:
DOCKER_REPO: t0ngyu/new-api-alpha
inputs:
tag:
description: 'Tag name to build (e.g., v0.10.8)'
required: false
type: string
jobs:
build-and-push:
runs-on: ubuntu-latest
build_single_arch:
name: Build & push (${{ matrix.arch }})
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-latest
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
outputs:
tag: ${{ steps.version.outputs.tag }}
is_tag: ${{ steps.version.outputs.is_tag }}
permissions:
packages: write
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'workflow_dispatch' && 0 || 1 }}
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Save version info
- name: Resolve version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
# For tags, use the tag name
echo "${GITHUB_REF#refs/tags/}" > VERSION
IS_TAG=false
if [ -n "${{ github.event.inputs.tag }}" ]; then
TAG="${{ github.event.inputs.tag }}"
if ! git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
echo "::error::Tag '$TAG' does not exist"
exit 1
fi
IS_TAG=true
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
IS_TAG=true
else
# For branches, use date and commit hash
echo "$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" > VERSION
TAG="$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
fi
cat VERSION
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "is_tag=${IS_TAG}" >> $GITHUB_OUTPUT
echo "${TAG}" > VERSION
echo "Building version: ${TAG} for ${{ matrix.arch }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Compute image tags
id: tags
run: |
TAGS="calciumion/new-api:${TAG}-${{ matrix.arch }}"
if [ "${{ steps.version.outputs.is_tag }}" = "true" ]; then
TAGS="${TAGS}"$'\n'"calciumion/new-api:latest-${{ matrix.arch }}"
else
TAGS="${TAGS}"$'\n'"calciumion/new-api:main-${{ matrix.arch }}"
fi
{
echo "tags<<EOF"
echo "${TAGS}"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
driver-opts: |
image=moby/buildkit:latest
network=host
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
- name: Extract metadata (labels)
id: meta
uses: docker/metadata-action@v6
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REPO }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
images: calciumion/new-api
- name: Build and push Docker image
- name: Build & push
id: build
uses: docker/build-push-action@v7
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
platforms: ${{ matrix.platform }}
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Enable BuildKit cache mounts and GHA cache
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
provenance: mode=max
sbom: true
- name: Install cosign
if: steps.version.outputs.is_tag == 'true'
uses: sigstore/cosign-installer@v3
- name: Sign image with cosign
if: steps.version.outputs.is_tag == 'true'
run: cosign sign --yes calciumion/new-api@${{ steps.build.outputs.digest }}
- name: Image summary
run: |
echo "### Docker Image Built Successfully! 🚀" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo "### Docker Image Digest (${{ matrix.arch }})" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo "calciumion/new-api:${TAG}-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.build.outputs.digest }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Digest:** \`${{ steps.build.outputs.digest }}\`" >> $GITHUB_STEP_SUMMARY
create_manifests:
name: Create multi-arch manifests
needs: [build_single_arch]
runs-on: ubuntu-latest
steps:
- name: Set version
run: echo "TAG=${{ needs.build_single_arch.outputs.tag }}" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create & push manifest (version)
run: |
docker buildx imagetools create \
-t calciumion/new-api:${TAG} \
calciumion/new-api:${TAG}-amd64 \
calciumion/new-api:${TAG}-arm64
- name: Create & push manifest (latest)
if: needs.build_single_arch.outputs.is_tag == 'true'
run: |
docker buildx imagetools create \
-t calciumion/new-api:latest \
calciumion/new-api:latest-amd64 \
calciumion/new-api:latest-arm64
- name: Create & push manifest (main)
if: needs.build_single_arch.outputs.is_tag != 'true'
run: |
docker buildx imagetools create \
-t calciumion/new-api:main \
calciumion/new-api:main-amd64 \
calciumion/new-api:main-arm64
- name: Manifest summary
run: |
echo "### Multi-arch Manifest" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
docker buildx imagetools inspect calciumion/new-api:${TAG} >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY