From 865cd62d77064802120b16b30903125db8633815 Mon Sep 17 00:00:00 2001 From: Evans Mike Date: Fri, 5 May 2023 12:21:00 +0100 Subject: [PATCH] update: release build action --- .github/workflows/build-singbox-docker.yml | 55 ++++++++++------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-singbox-docker.yml b/.github/workflows/build-singbox-docker.yml index 28251a0..64e0d12 100644 --- a/.github/workflows/build-singbox-docker.yml +++ b/.github/workflows/build-singbox-docker.yml @@ -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 @@ -85,7 +74,11 @@ jobs: if [[ -z "${{ github.event.inputs.tag }}" ]]; then echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT else - echo "versioned=etnperlong/sing-box:${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + 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