Files

109 lines
3.0 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Release
on:
release:
types: [published]
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: windows
goarch: amd64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.25"
- uses: oven-sh/setup-bun@v2
- name: Build frontend
run: |
cd web/admin && bun install && bun run build
cd ../tenant && bun install && bun run build
- name: Set variables
id: vars
run: |
VERSION=${GITHUB_REF_NAME}
# 资产文件名统一去掉 v 前缀,与 Go 侧 getPlatformAssetName 的命名约定一致
# (内置版本号 VERSION 保留原始 tag,如 v0.2.0;仅文件名用 ASSET_VERSION)
ASSET_VERSION=${VERSION#v}
BINARY=team-api
if [ "${{ matrix.goos }}" = "windows" ]; then
BINARY=team-api.exe
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "binary=${BINARY}" >> $GITHUB_OUTPUT
echo "artifact=team-api-${ASSET_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}" >> $GITHUB_OUTPUT
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -tags embedweb -ldflags "-X github.com/qianfree/team-api/internal/consts.Version=${{ steps.vars.outputs.version }}" -o ${{ steps.vars.outputs.binary }} main.go
- name: Package
run: |
ARTIFACT=${{ steps.vars.outputs.artifact }}
mkdir -p $ARTIFACT
cp ${{ steps.vars.outputs.binary }} $ARTIFACT/
cp README.md $ARTIFACT/ 2>/dev/null || true
cp LICENSE $ARTIFACT/ 2>/dev/null || true
if [ "${{ matrix.goos }}" = "windows" ]; then
zip -r ${ARTIFACT}.zip $ARTIFACT
else
tar -czf ${ARTIFACT}.tar.gz $ARTIFACT
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.vars.outputs.artifact }}
path: |
team-api-*.tar.gz
team-api-*.zip
retention-days: 1
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Generate checksums
run: |
cd artifacts
sha256sum team-api-*.tar.gz team-api-*.zip > checksums-sha256.txt
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/team-api-*.zip
artifacts/team-api-*.tar.gz
artifacts/checksums-sha256.txt