mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-26 13:14:14 +00:00
Merge dd039378df
into cb1afb33e6
This commit is contained in:
commit
703e0507a3
1 changed files with 86 additions and 47 deletions
133
.github/workflows/docker.yml
vendored
133
.github/workflows/docker.yml
vendored
|
@ -1,36 +1,74 @@
|
||||||
name: Build docker image
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types:
|
||||||
|
- published
|
||||||
|
- released
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: "Docker image tag:"
|
||||||
|
required: true
|
||||||
|
latest:
|
||||||
|
description: "Set to latest"
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-image:
|
build-and-push:
|
||||||
|
if: (github.event.action != 'published') || (github.event.action == 'published' && github.event.release.prerelease == true)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Set repository and image name to lowercase
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: "${{ github.repository }}"
|
||||||
|
run: |
|
||||||
|
echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
|
||||||
|
echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
|
||||||
|
|
||||||
- name: Docker metadata
|
- name: Validate and extract tag
|
||||||
id: meta
|
run: |
|
||||||
uses: docker/metadata-action@v5
|
SOURCE_TAG="${{ github.event.inputs.tag }}"
|
||||||
with:
|
if [[ -z "$SOURCE_TAG" ]]; then
|
||||||
images: ghcr.io/${{ github.repository_owner }}/xray-core
|
SOURCE_TAG="${{ github.ref_name }}"
|
||||||
flavor: latest=auto
|
fi
|
||||||
tags: |
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
|
|
||||||
- name: Docker metadata (unsupported architectures)
|
if [[ -z "$SOURCE_TAG" ]]; then
|
||||||
id: metausa
|
echo "Error: Could not determine a valid tag source. Input tag and context tag (github.ref_name) are both empty."
|
||||||
uses: docker/metadata-action@v5
|
exit 1
|
||||||
with:
|
fi
|
||||||
images: ghcr.io/${{ github.repository_owner }}/xray-core
|
|
||||||
flavor: |
|
if [[ "$SOURCE_TAG" =~ ^v[0-9]+\.[0-9] ]]; then
|
||||||
latest=auto
|
IMAGE_TAG="${SOURCE_TAG#v}"
|
||||||
suffix=-usa,onlatest=true
|
else
|
||||||
tags: |
|
IMAGE_TAG="$SOURCE_TAG"
|
||||||
type=semver,pattern={{version}}
|
fi
|
||||||
|
|
||||||
|
echo "Docker image tag: '$IMAGE_TAG'."
|
||||||
|
echo "IMAGE_TAG=$IMAGE_TAG" >>${GITHUB_ENV}
|
||||||
|
|
||||||
|
LATEST=false
|
||||||
|
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" == "false" ]] || [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.latest }}" == "true" ]]; then
|
||||||
|
LATEST=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Latest: '$LATEST'."
|
||||||
|
echo "LATEST=$LATEST" >>${GITHUB_ENV}
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
@ -39,13 +77,12 @@ jobs:
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Build Docker image (main architectures)
|
||||||
uses: docker/setup-buildx-action@v3
|
id: build_main_arches
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
file: .github/docker/Dockerfile
|
||||||
platforms: |
|
platforms: |
|
||||||
linux/amd64
|
linux/amd64
|
||||||
linux/arm/v7
|
linux/arm/v7
|
||||||
|
@ -53,39 +90,41 @@ jobs:
|
||||||
linux/ppc64le
|
linux/ppc64le
|
||||||
linux/s390x
|
linux/s390x
|
||||||
provenance: false
|
provenance: false
|
||||||
file: .github/docker/Dockerfile
|
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
|
|
||||||
- name: Build and push (unsupported architectures)
|
- name: Build Docker image (additional architectures)
|
||||||
|
id: build_additional_arches
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
file: .github/docker/Dockerfile.usa
|
||||||
platforms: |
|
platforms: |
|
||||||
linux/386
|
linux/386
|
||||||
linux/arm/v6
|
linux/arm/v6
|
||||||
linux/riscv64
|
linux/riscv64
|
||||||
linux/loong64
|
linux/loong64
|
||||||
provenance: false
|
provenance: false
|
||||||
file: .github/docker/Dockerfile.usa
|
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
|
||||||
push: true
|
|
||||||
tags: ${{ steps.metausa.outputs.tags }}
|
|
||||||
|
|
||||||
- name: Merge Multi-Arch Manifests
|
- name: Create manifest list and push
|
||||||
run: |
|
run: |
|
||||||
echo "Starting to merge multi-architecture manifests..."
|
echo "Creating multi-arch manifest with tag: '${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG }}'."
|
||||||
|
docker buildx imagetools create \
|
||||||
|
--tag ${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
|
||||||
|
${{ env.FULL_IMAGE_NAME }}@${{ steps.build_main_arches.outputs.digest }} \
|
||||||
|
${{ env.FULL_IMAGE_NAME }}@${{ steps.build_additional_arches.outputs.digest }}
|
||||||
|
|
||||||
# Convert newlines to spaces and split into array
|
if [[ "${{ env.LATEST }}" == "true" ]]; then
|
||||||
TAGS=($(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '))
|
echo "Adding 'latest' tag to manifest: '${{ env.FULL_IMAGE_NAME }}:latest'."
|
||||||
|
docker buildx imagetools create \
|
||||||
|
--tag ${{ env.FULL_IMAGE_NAME }}:latest \
|
||||||
|
${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG }}
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Total tags to process: ${#TAGS[@]}"
|
- name: Inspect image
|
||||||
for tag in "${TAGS[@]}"; do
|
run: |
|
||||||
echo "Merging tag: $tag with unsupported architectures ($tag-usa)"
|
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ env.IMAGE_TAG }}
|
||||||
docker buildx imagetools create --append --tag "$tag" "$tag-usa"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error: Failed to merge $tag-usa into $tag"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Multi-architecture manifest merge completed successfully."
|
if [[ "${{ env.LATEST }}" == "true" ]]; then
|
||||||
|
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:latest
|
||||||
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue