feat:新增github自动构建
This commit is contained in:
1 parent
f135e7f6fc
commit
29e07facb4
1 file changed
+80
@@ -0,0 +1,80 @@
|
||||
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}
|
||||
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-${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 release asset
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
team-api-*.zip
|
||||
team-api-*.tar.gz
|
||||
Reference in new issue
Block a user