feat: 添加自动构建触发,push到master时自动构建

This commit is contained in:
2026-04-18 17:06:32 +08:00
parent 18f8a52be8
commit e0fb44954b
2 changed files with 33 additions and 9 deletions
+16 -4
View File
@@ -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