feat:支持ipv6的接入,即双栈ip的主控 #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 🐳 构建标准版 Docker 镜像 | |
| on: | |
| push: | |
| tags: [ 'v*.*.*' ] | |
| branches: [ main ] | |
| workflow_dispatch: | |
| inputs: | |
| no_cache: | |
| description: '禁用构建缓存' | |
| required: false | |
| default: false | |
| type: boolean | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| DOCKERFILE: Dockerfile | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: 📦 检出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: 📝 获取版本信息 | |
| id: get_version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| if [ "$VERSION" != "$TAG_VERSION" ]; then | |
| echo "❌ 错误: Tag版本($TAG_VERSION)与package.json版本($VERSION)不匹配" | |
| exit 1 | |
| fi | |
| fi | |
| REPO_LC=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "is_release=${{ startsWith(github.ref, 'refs/tags/') }}" >> $GITHUB_OUTPUT | |
| echo "is_main=${{ github.ref == 'refs/heads/main' }}" >> $GITHUB_OUTPUT | |
| echo "repo_name=$REPO_LC" >> $GITHUB_OUTPUT | |
| echo "📦 当前版本: $VERSION" | |
| - name: 🔧 设置 QEMU | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: docker/setup-qemu-action@v3 | |
| - name: 🔧 设置 Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: | | |
| image=moby/buildkit:latest | |
| - name: 🔑 登录到容器仓库 | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 📋 提取镜像元数据 | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ steps.get_version.outputs.repo_name }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ steps.get_version.outputs.is_main == 'true' }} | |
| type=raw,value=${{ steps.get_version.outputs.version }},enable=${{ steps.get_version.outputs.is_main == 'true' || steps.get_version.outputs.is_release == 'true' }} | |
| - name: 🏗️ 构建和推送(使用缓存) | |
| if: ${{ !inputs.no_cache }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ env.DOCKERFILE }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: | | |
| org.opencontainers.image.version=${{ steps.get_version.outputs.version }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.title=${{ steps.get_version.outputs.repo_name }} | |
| platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | |
| cache-from: | | |
| type=gha,scope=standard-${{ github.workflow }} | |
| type=registry,ref=${{ env.REGISTRY }}/${{ steps.get_version.outputs.repo_name }}:buildcache | |
| cache-to: | | |
| type=gha,mode=max,scope=standard-${{ github.workflow }} | |
| type=registry,ref=${{ env.REGISTRY }}/${{ steps.get_version.outputs.repo_name }}:buildcache,mode=max | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| VERSION=${{ steps.get_version.outputs.version }} | |
| - name: 🏗️ 构建和推送(无缓存) | |
| if: ${{ inputs.no_cache }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ env.DOCKERFILE }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: | | |
| org.opencontainers.image.version=${{ steps.get_version.outputs.version }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.title=${{ steps.get_version.outputs.repo_name }} | |
| platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | |
| no-cache: true | |
| build-args: | | |
| VERSION=${{ steps.get_version.outputs.version }} | |
| - name: 📢 输出版本信息 | |
| run: | | |
| echo "🏷️ 版本: ${{ steps.get_version.outputs.version }}" | |
| echo "📦 镜像标签:" | |
| echo "${{ steps.meta.outputs.tags }}" | tr '\n' '\n ' | |
| echo "🏗️ 构建架构: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}" | |
| echo "🚫 缓存状态: ${{ inputs.no_cache && '已禁用' || '已启用' }}" |