mirror of
https://github.com/Walter-Sparrow/lunar-tear.git
synced 2026-07-02 05:43:41 +03:00
118 lines
3.4 KiB
YAML
118 lines
3.4 KiB
YAML
name: Build and Publish Release Binaries
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- { goos: linux, goarch: amd64, archive: tar.gz }
|
|
- { goos: linux, goarch: arm64, archive: tar.gz }
|
|
- { goos: darwin, goarch: amd64, archive: tar.gz }
|
|
- { goos: darwin, goarch: arm64, archive: tar.gz }
|
|
- { goos: windows, goarch: amd64, archive: zip }
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.25'
|
|
cache-dependency-path: server/go.sum
|
|
|
|
- name: Install protoc
|
|
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
|
|
|
|
- name: Install protoc-gen-go plugins
|
|
run: |
|
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
|
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
|
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Generate proto stubs
|
|
working-directory: server
|
|
run: make proto
|
|
|
|
- name: Cross-compile binaries
|
|
working-directory: server
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: '0'
|
|
run: |
|
|
set -euo pipefail
|
|
stage="staging"
|
|
mkdir -p "$stage/bin"
|
|
|
|
ext=""
|
|
if [ "$GOOS" = "windows" ]; then ext=".exe"; fi
|
|
|
|
build() {
|
|
local name="$1" dest="$2"
|
|
go build -trimpath -ldflags="-s -w" -o "$dest/${name}${ext}" "./cmd/${name}"
|
|
}
|
|
|
|
# Wizard sits at the root so end-users see it immediately.
|
|
build wizard "$stage"
|
|
|
|
# Sub-services and admin tools go in bin/ to match the runtime layout.
|
|
for name in dev lunar-tear octo-cdn auth-server import-snapshot claim-account register-account wizard-restore; do
|
|
build "$name" "$stage/bin"
|
|
done
|
|
|
|
- name: Stage docs
|
|
working-directory: server
|
|
run: |
|
|
cp ../README.md staging/README.md
|
|
cp ../LICENSE staging/LICENSE
|
|
|
|
- name: Archive
|
|
working-directory: server
|
|
run: |
|
|
set -euo pipefail
|
|
name="lunar-tear-server-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
|
mv staging "$name"
|
|
if [ "${{ matrix.archive }}" = "zip" ]; then
|
|
zip -r "${name}.zip" "$name"
|
|
else
|
|
tar -czf "${name}.tar.gz" "$name"
|
|
fi
|
|
ls -lh "${name}".*
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: lunar-tear-server-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
path: server/lunar-tear-server-*.${{ matrix.archive }}
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: Attach archives to GitHub Release
|
|
needs: build
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
merge-multiple: true
|
|
|
|
- name: List downloaded artifacts
|
|
run: ls -lh artifacts/
|
|
|
|
- uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: artifacts/*
|
|
generate_release_notes: true
|
|
draft: true
|