From e0fb44954b44b0ddcea7fc82ef01705342cf2657 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 18 Apr 2026 17:06:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=A7=A6=E5=8F=91=EF=BC=8Cpush=E5=88=B0maste?= =?UTF-8?q?r=E6=97=B6=E8=87=AA=E5=8A=A8=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docker-artifact.yml | 20 +++++++++++++++---- .github/workflows/build-docker-image.yml | 22 ++++++++++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-docker-artifact.yml b/.github/workflows/build-docker-artifact.yml index 57c57c11b..c45b642c0 100644 --- a/.github/workflows/build-docker-artifact.yml +++ b/.github/workflows/build-docker-artifact.yml @@ -1,11 +1,14 @@ name: Build Docker Image Artifact on: + push: + branches: + - master workflow_dispatch: inputs: tag: description: '镜像标签版本' - required: true + required: false default: 'latest' jobs: @@ -40,17 +43,26 @@ jobs: go mod tidy CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -o next-terminal ../main.go + - name: Get version + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "VERSION=${{ inputs.tag }}" >> $GITHUB_OUTPUT + else + echo "VERSION=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT + fi + - name: Create package run: | mkdir -p next-terminal cp server/next-terminal next-terminal/ cp config.yml.example next-terminal/config.yml cp LICENSE next-terminal/ - tar zcvf next-terminal-${{ inputs.tag }}-linux-amd64.tar.gz next-terminal/ + tar zcvf next-terminal-${{ steps.version.outputs.VERSION }}-linux-amd64.tar.gz next-terminal/ - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: next-terminal-${{ inputs.tag }}-linux-amd64 - path: next-terminal-${{ inputs.tag }}-linux-amd64.tar.gz + name: next-terminal-${{ steps.version.outputs.VERSION }}-linux-amd64 + path: next-terminal-${{ steps.version.outputs.VERSION }}-linux-amd64.tar.gz retention-days: 7 diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index db9554f2f..5e591304e 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -1,11 +1,14 @@ name: Build Docker Image on: + push: + branches: + - master workflow_dispatch: inputs: tag: description: '镜像标签版本' - required: true + required: false default: 'latest' jobs: @@ -29,17 +32,26 @@ jobs: yarn build cp -r build ../server/resource/ + - name: Get version + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "VERSION=${{ inputs.tag }}" >> $GITHUB_OUTPUT + else + echo "VERSION=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT + fi + - name: Build Docker image run: | - docker build -t next-terminal:${{ inputs.tag }} . + docker build -t next-terminal:${{ steps.version.outputs.VERSION }} . - name: Save Docker image run: | - docker save next-terminal:${{ inputs.tag }} | gzip > next-terminal-${{ inputs.tag }}.tar.gz + docker save next-terminal:${{ steps.version.outputs.VERSION }} | gzip > next-terminal-${{ steps.version.outputs.VERSION }}.tar.gz - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: next-terminal-docker-${{ inputs.tag }} - path: next-terminal-${{ inputs.tag }}.tar.gz + name: next-terminal-docker-${{ steps.version.outputs.VERSION }} + path: next-terminal-${{ steps.version.outputs.VERSION }}.tar.gz retention-days: 7