69 lines
1.8 KiB
YAML

name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
repository_dispatch:
types: [trigger-backend-workflow]
env:
GIT_TERMINAL_PROMPT: 1
GOPRIVATE: git.liteyuki.icu
GONOSUMDB: git.liteyuki.icu
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ linux, windows, darwin ]
goarch: [ amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.22
- name: Auth For Private Dependencies
run: git config --global url."https://${{ secrets.GITEA_TOKEN }}@git.liteyuki.icu".insteadOf "https://git.liteyuki.icu"
- name: Install dependencies
run: go mod tidy
- name: Pull and build front-end
run: |
git clone https://github.com/snowykami/server-status-web
cd server-status-web
npm install -g pnpm
pnpm install --no-frozen-lockfile
pnpm run build
mkdir -p ../api/frontend/web
cp -r dist ../api/frontend/web
- name: Compile
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
OUTPUT_NAME=server-status-server
if [ "${{ matrix.goos }}" == "windows" ]; then OUTPUT_NAME="${OUTPUT_NAME}.exe"; fi
go build -o build/${GOOS}-${GOARCH}/${OUTPUT_NAME} main.go
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: server-status-server-${{ matrix.goos }}-${{ matrix.goarch }}
path: build/${{ matrix.goos }}-${{ matrix.goarch }}/server-status-server*
if-no-files-found: warn