Update docker workflow

This commit is contained in:
世界 2024-05-03 18:52:54 +08:00
parent 742adacce7
commit 1f470c69c4
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -4,13 +4,35 @@ on:
release: release:
types: types:
- released - released
workflow_dispatch:
inputs:
tag:
description: "The tag version you want to build"
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: 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 - name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
with:
ref: ${{ steps.ref.outputs.ref }}
- name: Setup Docker Buildx - name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Setup QEMU for Docker Buildx - name: Setup QEMU for Docker Buildx
@ -30,10 +52,11 @@ jobs:
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
platforms: linux/386,linux/amd64,linux/arm64,linux/s390x platforms: linux/386,linux/amd64,linux/arm64,linux/s390x
context: .
target: dist target: dist
build-args: | build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
tags: | tags: |
ghcr.io/sagernet/sing-box:latest ghcr.io/sagernet/sing-box:${{ steps.ref.outputs.latest }}
ghcr.io/sagernet/sing-box:${{ github.ref_name }} ghcr.io/sagernet/sing-box:${{ steps.ref.outputs.ref }}
push: true push: true