mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 09:13:49 +08:00
75 lines
3.3 KiB
YAML
75 lines
3.3 KiB
YAML
name: Backend
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-24.04
|
|
strategy:
|
|
matrix:
|
|
goarch: [ amd64, arm64 ]
|
|
fail-fast: true
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
cache: true
|
|
go-version: 'stable'
|
|
- name: Install dependencies
|
|
run: go mod tidy
|
|
- name: Wait for frontend build
|
|
uses: lewagon/wait-on-check-action@v1.3.4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
check-name: 'build (frontend)'
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Download frontend
|
|
uses: dawidd6/action-download-artifact@v7
|
|
with:
|
|
workflow: frontend.yml
|
|
name: frontend
|
|
path: internal/embed/frontend
|
|
check_artifacts: true
|
|
- name: Set build info
|
|
id: build_info
|
|
run: |
|
|
echo "version=$(git describe --tags --abbrev=0 2>/dev/null || echo '0.0.0')" >> $GITHUB_OUTPUT
|
|
echo "build_time=$(date -u '+%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
|
|
echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
echo "go_version=$(go version | cut -d' ' -f3)" >> $GITHUB_OUTPUT
|
|
echo "platform=$(go version | cut -d' ' -f4)" >> $GITHUB_OUTPUT
|
|
echo "build_user=$(whoami)" >> $GITHUB_OUTPUT
|
|
echo "build_host=$(hostname)" >> $GITHUB_OUTPUT
|
|
echo "build_id=${{ github.run_id }}" >> $GITHUB_OUTPUT
|
|
- name: Build ${{ matrix.goarch }}
|
|
env:
|
|
CGO_ENABLED: 0
|
|
GOOS: linux
|
|
GOARCH: ${{ matrix.goarch }}
|
|
run: |
|
|
LDFLAGS="-s -w --extldflags '-static'"
|
|
LDFLAGS="${LDFLAGS} -X 'github.com/TheTNB/panel/internal/app.Version=${{ steps.build_info.outputs.version }}'"
|
|
LDFLAGS="${LDFLAGS} -X 'github.com/TheTNB/panel/internal/app.BuildTime=${{ steps.build_info.outputs.build_time }}'"
|
|
LDFLAGS="${LDFLAGS} -X 'github.com/TheTNB/panel/internal/app.CommitHash=${{ steps.build_info.outputs.commit_hash }}'"
|
|
LDFLAGS="${LDFLAGS} -X 'github.com/TheTNB/panel/internal/app.GoVersion=${{ steps.build_info.outputs.go_version }}'"
|
|
LDFLAGS="${LDFLAGS} -X 'github.com/TheTNB/panel/internal/app.Platform=${{ steps.build_info.outputs.platform }}'"
|
|
LDFLAGS="${LDFLAGS} -X 'github.com/TheTNB/panel/internal/app.BuildUser=${{ steps.build_info.outputs.build_user }}'"
|
|
LDFLAGS="${LDFLAGS} -X 'github.com/TheTNB/panel/internal/app.BuildHost=${{ steps.build_info.outputs.build_host }}'"
|
|
LDFLAGS="${LDFLAGS} -X 'github.com/TheTNB/panel/internal/app.BuildID=${{ steps.build_info.outputs.build_id }}'"
|
|
go build -ldflags "${LDFLAGS}" -o web-${{ matrix.goarch }} ./cmd/web
|
|
go build -ldflags "${LDFLAGS}" -o cli-${{ matrix.goarch }} ./cmd/cli
|
|
- name: Compress ${{ matrix.goarch }}
|
|
run: |
|
|
upx --best --lzma web-${{ matrix.goarch }}
|
|
upx --best --lzma cli-${{ matrix.goarch }}
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.goarch }}
|
|
path: |
|
|
web-${{ matrix.goarch }}
|
|
cli-${{ matrix.goarch }} |