action: prerelease
This commit is contained in:
parent
5eeb17a9fb
commit
fd3ed889a0
1 changed files with 103 additions and 0 deletions
103
.github/workflows/build-singbox-docker-prerelease.yml
vendored
Normal file
103
.github/workflows/build-singbox-docker-prerelease.yml
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
name: Build Docker Images (Release)
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "The tag version you want to build"
|
||||
required: true
|
||||
default: "main"
|
||||
repository_dispatch:
|
||||
types: [build-prerelease]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
buildType: [full]
|
||||
distro: [alpine]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TAG: ${{ github.event.client_payload.tag || github.event.inputs.tag}}
|
||||
steps:
|
||||
- name: Get Build Tags
|
||||
run: |
|
||||
echo "Version: ${{env.TAG}}"
|
||||
- name: Checkout Source Code of 'SagerNet/sing-box'
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: 'SagerNet/sing-box'
|
||||
ref: ${{env.TAG}}
|
||||
submodules: true
|
||||
- name: Checkout Action Repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: action
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Setup QEMU for Docker Buildx
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Login to Docker Hub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Docker metadata
|
||||
id: metadata
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: etnperlong/sing-box
|
||||
- name: Select Dockerfile
|
||||
id: dockerfile
|
||||
run: |
|
||||
if [[ "${{ matrix.buildType }}" == "full" ]]; then
|
||||
if [[ "${{ matrix.distro }}" == "distroless" ]]; then
|
||||
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.full" "$GITHUB_WORKSPACE/Dockerfile"
|
||||
echo "tagpost=full-distroless" >> $GITHUB_OUTPUT
|
||||
else
|
||||
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.full" "$GITHUB_WORKSPACE/Dockerfile"
|
||||
# echo "tagpost=full" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
elif [[ "${{ matrix.buildType }}" == "minimized" ]]; then
|
||||
if [[ "${{ matrix.distro }}" == "distroless" ]]; then
|
||||
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.minimized" "$GITHUB_WORKSPACE/Dockerfile"
|
||||
echo "tagpost=mini-distroless" >> $GITHUB_OUTPUT
|
||||
else
|
||||
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.minimized" "$GITHUB_WORKSPACE/Dockerfile"
|
||||
echo "tagpost=mini" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
else
|
||||
if [[ "${{ matrix.distro }}" == "distroless" ]]; then
|
||||
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.standard" "$GITHUB_WORKSPACE/Dockerfile"
|
||||
echo "tagpost=distroless" >> $GITHUB_OUTPUT
|
||||
else
|
||||
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.standard" "$GITHUB_WORKSPACE/Dockerfile"
|
||||
fi
|
||||
fi
|
||||
- name: Get tag to build
|
||||
id: tag
|
||||
run: |
|
||||
if [[ "${{ matrix.distro }}" == "alpine" && "${{ matrix.buildType }}" == "full" ]]; then
|
||||
echo "latest=etnperlong/sing-box:latest" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
if [[ "${{ matrix.distro }}" == "distroless" && "${{ matrix.buildType }}" == "full" ]]; then
|
||||
echo "latest=etnperlong/sing-box:distroless" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
if [[ -z "${{env.TAG}}" ]]; then
|
||||
echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
if [[ -n "${{ steps.dockerfile.outputs.tagpost }}" ]]; then
|
||||
echo "versioned=etnperlong/sing-box:${{env.TAG}}-${{ steps.dockerfile.outputs.tagpost }}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "versioned=etnperlong/sing-box:${{env.TAG}}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
fi
|
||||
- name: Build and release Docker images
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
target: dist
|
||||
tags: |
|
||||
${{ steps.tag.outputs.versioned }}
|
||||
push: true
|
Loading…
Reference in a new issue