feat: 删除旧的 Docker 镜像构建工作流,添加新的工作流以支持多架构构建和推送,更新 GitHub Pages 和 Release 工作流文档

This commit is contained in:
ryan
2026-03-11 10:05:21 +08:00
parent f3f4980b7d
commit f3012bfabf
8 changed files with 238 additions and 152 deletions
+121
View File
@@ -0,0 +1,121 @@
name: Release
on:
workflow_dispatch:
push:
tags: ["v*"]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: https://github.com/actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve version metadata
id: version
shell: bash
run: |
SHOULD_RUN=true
POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)"
if [[ "${GITHUB_REF}" == refs/heads/main ]] && [[ -n "$POINTED_TAG" ]]; then
SHOULD_RUN=false
VERSION="$POINTED_TAG"
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF_NAME}"
else
VERSION="$(git describe --tags)"
fi
echo "should_run=$SHOULD_RUN" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: Set up Node.js
if: steps.version.outputs.should_run == 'true'
uses: https://github.com/actions/setup-node@v4
with:
node-version: 18
- name: Build Frontend
if: steps.version.outputs.should_run == 'true'
env:
CI: ""
VERSION: ${{ steps.version.outputs.version }}
run: |
cd atsf_server/web
npm install
REACT_APP_VERSION="$VERSION" npm run build
- name: Set up Go
if: steps.version.outputs.should_run == 'true'
uses: https://github.com/actions/setup-go@v5
with:
go-version-file: atsf_server/go.mod
- name: Build Server Binaries
if: steps.version.outputs.should_run == 'true'
shell: bash
env:
CGO_ENABLED: 0
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
mkdir -p dist
cd atsf_server
go mod download
while read -r GOOS GOARCH ASSET_NAME; do
GOOS="$GOOS" GOARCH="$GOARCH" \
go build -trimpath -ldflags "-s -w -X 'atsflare/common.Version=$VERSION'" -o "../dist/$ASSET_NAME" .
done <<'EOF'
linux amd64 atsflare-server-linux-amd64
linux arm64 atsflare-server-linux-arm64
darwin amd64 atsflare-server-darwin-amd64
darwin arm64 atsflare-server-darwin-arm64
windows amd64 atsflare-server-windows-amd64.exe
EOF
- name: Build Agent Binaries
if: steps.version.outputs.should_run == 'true'
shell: bash
env:
CGO_ENABLED: 0
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
cd atsf_agent
go mod download
while read -r GOOS GOARCH ASSET_NAME; do
GOOS="$GOOS" GOARCH="$GOARCH" \
go build -trimpath -ldflags "-s -w -X 'atsflare-agent/internal/config.AgentVersion=$VERSION'" -o "../dist/$ASSET_NAME" ./cmd/agent
done <<'EOF'
linux amd64 atsflare-agent-linux-amd64
linux arm64 atsflare-agent-linux-arm64
darwin amd64 atsflare-agent-darwin-amd64
darwin arm64 atsflare-agent-darwin-arm64
windows amd64 atsflare-agent-windows-amd64.exe
EOF
- name: Publish Release
if: steps.version.outputs.should_run == 'true'
uses: https://gitea.com/actions/gitea-release-action@v1
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
target_commitish: ${{ github.sha }}
files: |
dist/*
draft: false
prerelease: ${{ steps.version.outputs.is_prerelease == 'true' }}