update: release build action

This commit is contained in:
Evans Mike 2023-05-05 12:21:00 +01:00
parent 8cef4e15bf
commit 865cd62d77

View file

@ -1,31 +1,19 @@
name: Build Docker Images
name: Build Docker Images (Release)
on:
workflow_dispatch:
inputs:
tag:
description: "The tag version or branch you want to build"
description: "The tag version you want to build"
required: true
default: "main"
buildType:
description: "The type of build you want to build"
required: true
default: 'standard'
type: choice
options:
- standard
- minimized
- full
distro:
description: "The distro you want to build"
required: true
default: 'alpine'
type: choice
options:
- alpine
- distroless
jobs:
build:
strategy:
fail-fast: true
matrix:
buildType: [standard, minimized, full]
distro: [alpine, distroless]
runs-on: ubuntu-latest
steps:
- name: Checkout Action Repo
@ -36,7 +24,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: 'SagerNet/sing-box'
ref: ${{ github.event.inputs.branch }}
ref: ${{ github.event.inputs.tag }}
submodules: true
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
@ -44,26 +32,27 @@ jobs:
uses: docker/setup-qemu-action@v2
- name: Select Dockerfile
run: |
if [[ "${{ github.event.inputs.buildType }}" == "full" ]]; then
if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
if [[ "${{ matrix.buildType }}" == "full" ]]; then
if [[ "${{ matrix.distro }}" == "distroless" ]]; then
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.full" > Dockerfile
echo "tag_postfix=-full-distroless" >> $GITHUB_OUTPUT
echo "tag_postfix=full-distroless" >> $GITHUB_OUTPUT
else
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.full" > Dockerfile
echo "tag_postfix=-full" >> $GITHUB_OUTPUT
if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
echo "tag_postfix=full" >> $GITHUB_OUTPUT
if [[ "${{ matrix.distro }}" == "distroless" ]]; then
fi
elif [[ "${{ github.event.inputs.buildType }}" == "minimized" ]]; then
if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
elif [[ "${{ matrix.buildType }}" == "minimized" ]]; then
if [[ "${{ matrix.distro }}" == "distroless" ]]; then
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.minimized" > Dockerfile
echo "tag_postfix=-mini-distroless" >> $GITHUB_OUTPUT
echo "tag_postfix=mini-distroless" >> $GITHUB_OUTPUT
else
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.minimized" > Dockerfile
echo "tag_postfix=-mini" >> $GITHUB_OUTPUT
echo "tag_postfix=mini" >> $GITHUB_OUTPUT
fi
else
if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
if [[ "${{ matrix.distro }}" == "distroless" ]]; then
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.standard" > Dockerfile
echo "tag_postfix=distroless" >> $GITHUB_OUTPUT
else
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.standard" > Dockerfile
fi
@ -84,9 +73,13 @@ jobs:
echo "latest=etnperlong/sing-box:latest" >> $GITHUB_OUTPUT
if [[ -z "${{ github.event.inputs.tag }}" ]]; then
echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
if [[ -z ${{ steps.tag.outputs.tag_postfix }} ]]; then
echo "versioned=etnperlong/sing-box:${{ github.event.inputs.tag }}-${{ steps.tag.outputs.tag_postfix }}" >> $GITHUB_OUTPUT
else
echo "versioned=etnperlong/sing-box:${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
fi
fi
- name: Build and release Docker images
uses: docker/build-push-action@v4
with: