Skip to content

fix: 校准纯 Go WAA 启动契约并完善文档 #64

fix: 校准纯 Go WAA 启动契约并完善文档

fix: 校准纯 Go WAA 启动契约并完善文档 #64

Workflow file for this run

name: Build And Release
on:
push:
branches: [main]
tags: ['v*']
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
jobs:
build:
runs-on: ubuntu-24.04
env:
CGO_ENABLED: '0'
GOTOOLCHAIN: local
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '22.13.0'
cache: npm
cache-dependency-path: web/package-lock.json
- name: Check And Build Frontend
working-directory: web
run: |
npm ci
npm run lint
npm run build
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Run Unit Tests
run: go test -mod=readonly ./cmd/... ./internal/...
- name: Check Minimum Go Version
run: |
go version
go vet ./...
go build -mod=readonly ./cmd/aistudio2api
- uses: actions/setup-go@v7
with:
go-version: stable
cache: false
- name: Build Packages
shell: bash
run: |
version="${GITHUB_SHA:0:7}"
if [[ "$GITHUB_REF_TYPE" == tag ]]; then version="$GITHUB_REF_NAME"; fi
mkdir -p dist
for target in windows/amd64 linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do
export GOOS="${target%/*}" GOARCH="${target#*/}"
name="aistudio2api-${version}-${GOOS}-${GOARCH}"
directory="dist/$name"
mkdir -p "$directory"
binary=aistudio2api
if [[ "$GOOS" == windows ]]; then binary+=.exe; cp start.bat "$directory/"; fi
go build -mod=readonly -trimpath -ldflags='-s -w' -o "$directory/$binary" ./cmd/aistudio2api
cp README.md README_en.md LICENSE .env.example "$directory/"
cp -r docs "$directory/"
if [[ "$GOOS" == windows ]]; then
(cd dist && zip -qr "$name.zip" "$name")
else
tar -czf "dist/$name.tar.gz" -C dist "$name"
fi
done
- uses: actions/upload-artifact@v7
with:
name: packages
path: |
dist/*.zip
dist/*.tar.gz
retention-days: 7
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
name: packages
path: dist
- name: Publish Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ github.ref_name }}
shell: bash
run: |
flags=()
if [[ "$RELEASE_TAG" == *-* ]]; then flags+=(--prerelease); fi
gh release create "$RELEASE_TAG" dist/* --verify-tag --generate-notes --title "$RELEASE_TAG" "${flags[@]}"