mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-06-04 19:48:17 +08:00
* feat(build): add unified server image build flow Consolidate service image definitions into a single server build setup, and update CI workflows to use it. * fix(ci): correct Docker image tag generation
113 lines
3.0 KiB
YAML
113 lines
3.0 KiB
YAML
name: Build and release services Docker Images
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- release-*
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Tag version to be used for Docker image"
|
|
required: true
|
|
default: "v3.8.3"
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3.3.0
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3.8.0
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3.3.0
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3.3.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Log in to Aliyun Container Registry
|
|
uses: docker/login-action@v3.3.0
|
|
with:
|
|
registry: registry.cn-hangzhou.aliyuncs.com
|
|
username: ${{ secrets.ALIREGISTRY_USERNAME }}
|
|
password: ${{ secrets.ALIREGISTRY_TOKEN }}
|
|
|
|
- name: Resolve Docker image tags
|
|
id: tags
|
|
env:
|
|
INPUT_TAG: ${{ github.event.inputs.tag }}
|
|
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
tags=()
|
|
declare -A seen=()
|
|
|
|
add_tag() {
|
|
local tag="$1"
|
|
[[ -n "$tag" ]] || return 0
|
|
|
|
tag="${tag//\//-}"
|
|
if [[ -z "${seen[$tag]+x}" ]]; then
|
|
tags+=("$tag")
|
|
seen["$tag"]=1
|
|
fi
|
|
}
|
|
|
|
add_tag_with_semver_alias() {
|
|
local tag="$1"
|
|
add_tag "$tag"
|
|
if [[ "$tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
|
|
add_tag "${BASH_REMATCH[1]}"
|
|
add_tag "release-$tag"
|
|
fi
|
|
}
|
|
|
|
add_tag_with_semver_alias "${INPUT_TAG:-}"
|
|
add_tag_with_semver_alias "${RELEASE_TAG:-}"
|
|
|
|
if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then
|
|
add_tag_with_semver_alias "${GITHUB_REF_NAME}"
|
|
elif [[ "${GITHUB_REF_TYPE:-}" == "branch" ]]; then
|
|
add_tag "${GITHUB_REF_NAME}"
|
|
fi
|
|
|
|
add_tag "sha-${GITHUB_SHA::7}"
|
|
|
|
{
|
|
echo "tags<<EOF"
|
|
printf '%s\n' "${tags[@]}"
|
|
echo "EOF"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build and push Docker images
|
|
env:
|
|
RELEASE: "true"
|
|
PUSH: "true"
|
|
PLATFORMS: linux/amd64,linux/arm64
|
|
IMAGE_TAGS: ${{ steps.tags.outputs.tags }}
|
|
IMAGE_REGISTRIES: |
|
|
${{ secrets.DOCKER_USERNAME }}
|
|
ghcr.io/${{ github.repository_owner }}
|
|
registry.cn-hangzhou.aliyuncs.com/openimsdk
|
|
run: |
|
|
bash build/build.sh
|