diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 61d61fa8..cf21f6fe 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,13 +4,35 @@ on: release: types: - released - + workflow_dispatch: + inputs: + tag: + description: "The tag version you want to build" jobs: build: runs-on: ubuntu-latest steps: + - name: Get commit to build + id: ref + run: |- + if [[ -z "${{ github.event.inputs.tag }}" ]]; then + ref="${{ github.ref_name }}" + else + ref="${{ github.event.inputs.tag }}" + fi + echo "ref=$ref" + echo "ref=$ref" >> $GITHUB_OUTPUT + if [[ $ref == *"-"* ]]; then + latest=latest-beta + else + latest=latest + fi + echo "latest=$latest" + echo "latest=$latest" >> $GITHUB_OUTPUT - name: Checkout uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 + with: + ref: ${{ steps.ref.outputs.ref }} - name: Setup Docker Buildx uses: docker/setup-buildx-action@v3 - name: Setup QEMU for Docker Buildx @@ -30,10 +52,11 @@ jobs: uses: docker/build-push-action@v5 with: platforms: linux/386,linux/amd64,linux/arm64,linux/s390x + context: . target: dist build-args: | BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 tags: | - ghcr.io/sagernet/sing-box:latest - ghcr.io/sagernet/sing-box:${{ github.ref_name }} + ghcr.io/sagernet/sing-box:${{ steps.ref.outputs.latest }} + ghcr.io/sagernet/sing-box:${{ steps.ref.outputs.ref }} push: true