Merge backend-foundation: multi-user API, three clients, Gitea CI/CD, Docker
This commit is contained in:
commit
7f0cb01954
122 files changed
+13897
-777
No files matched your search
@@ -0,0 +1,98 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
|
||||
jobs:
|
||||
go:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
# cmd/gui (Fyne) uses cgo and links against the system's OpenGL/X11
|
||||
# libraries, so building or testing ./... needs these present even
|
||||
# though the GUI itself never opens a window in CI.
|
||||
- name: Install system dependencies for the Fyne GUI build
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgl1-mesa-dev xorg-dev
|
||||
|
||||
- name: gofmt
|
||||
run: |
|
||||
fmt_out="$(gofmt -l .)"
|
||||
if [ -n "$fmt_out" ]; then
|
||||
echo "The following files are not gofmt'd:"
|
||||
echo "$fmt_out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: go vet
|
||||
run: go vet ./...
|
||||
|
||||
- name: go build
|
||||
run: go build ./...
|
||||
|
||||
- name: go test
|
||||
run: go test ./...
|
||||
|
||||
- name: go mod tidy (no diff expected)
|
||||
run: |
|
||||
go mod tidy
|
||||
git diff --exit-code -- go.mod go.sum
|
||||
|
||||
sqlc:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: sqlc-dev/setup-sqlc@v4
|
||||
with:
|
||||
sqlc-version: "1.31.1"
|
||||
|
||||
- name: sqlc diff (generated code must match the schema/queries)
|
||||
run: sqlc diff
|
||||
|
||||
web:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: web
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: npm
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Test
|
||||
run: npm test
|
||||
|
||||
# Builds the image on every push as a health check (catches a broken
|
||||
# Dockerfile immediately); doesn't push anywhere. release.yml does the
|
||||
# same build and pushes it.
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: false
|
||||
@@ -0,0 +1,217 @@
|
||||
#
|
||||
# .gitea/workflows/release.yml
|
||||
#
|
||||
# On a version tag (e.g. v1.2.3): builds every client, pushes the API's
|
||||
# Docker image, uploads all build artifacts to the Gitea generic package
|
||||
# registry, and creates a Gitea release with those same files attached.
|
||||
#
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*.*.*"]
|
||||
|
||||
env:
|
||||
PROJECT_NAME: Completed
|
||||
REGISTRY: gitea.sanplex.xyz
|
||||
REGISTRY_OWNER: sansan
|
||||
|
||||
jobs:
|
||||
# cmd/api and cmd/tui are pure Go (no cgo), so they cross-compile cleanly
|
||||
# from one Linux runner for every OS/arch below.
|
||||
build-go:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
- goos: darwin
|
||||
goarch: amd64
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
- goos: windows
|
||||
goarch: amd64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: Build api and tui
|
||||
env:
|
||||
GOOS: ${{ matrix.goos }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
CGO_ENABLED: "0"
|
||||
run: |
|
||||
mkdir -p dist
|
||||
ext=""
|
||||
if [ "${{ matrix.goos }}" = "windows" ]; then ext=".exe"; fi
|
||||
go build -o "dist/completed-api${ext}" ./cmd/api
|
||||
go build -o "dist/completed-tui${ext}" ./cmd/tui
|
||||
|
||||
- name: Archive
|
||||
run: |
|
||||
cd dist
|
||||
base="${PROJECT_NAME}_${{ matrix.goos }}_${{ matrix.goarch }}"
|
||||
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||
zip "../${base}.zip" completed-api.exe completed-tui.exe
|
||||
else
|
||||
tar czf "../${base}.tar.gz" completed-api completed-tui
|
||||
fi
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.PROJECT_NAME }}_${{ matrix.goos }}_${{ matrix.goarch }}
|
||||
path: ${{ env.PROJECT_NAME }}_${{ matrix.goos }}_${{ matrix.goarch }}.*
|
||||
retention-days: 7
|
||||
|
||||
# cmd/gui (Fyne) uses cgo, so unlike build-go above it can't just cross-
|
||||
# compile with CGO_ENABLED=0. Linux is native to this runner; Windows
|
||||
# cross-compiles cleanly with the mingw-w64 toolchain (verified locally:
|
||||
# a real PE32+ GUI-subsystem .exe, linking Fyne's OpenGL/glfw backend,
|
||||
# with no changes needed beyond CC and the usual GOOS/GOARCH). macOS
|
||||
# isn't included - cross-compiling cgo to Darwin from Linux has no
|
||||
# equivalent well-supported toolchain, so that would need an actual
|
||||
# macOS runner, which isn't registered for this repo.
|
||||
build-gui:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
packages: libgl1-mesa-dev xorg-dev
|
||||
- goos: windows
|
||||
goarch: amd64
|
||||
packages: gcc-mingw-w64-x86-64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ${{ matrix.packages }}
|
||||
|
||||
- name: Build gui
|
||||
env:
|
||||
GOOS: ${{ matrix.goos }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
CGO_ENABLED: "1"
|
||||
run: |
|
||||
mkdir -p dist
|
||||
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||
CC=x86_64-w64-mingw32-gcc go build -ldflags "-H=windowsgui" -o dist/completed-gui.exe ./cmd/gui
|
||||
else
|
||||
go build -o dist/completed-gui ./cmd/gui
|
||||
fi
|
||||
|
||||
- name: Archive
|
||||
run: |
|
||||
cd dist
|
||||
base="../${PROJECT_NAME}-gui_${{ matrix.goos }}_${{ matrix.goarch }}"
|
||||
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||
zip "${base}.zip" completed-gui.exe
|
||||
else
|
||||
tar czf "${base}.tar.gz" completed-gui
|
||||
fi
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.PROJECT_NAME }}-gui_${{ matrix.goos }}_${{ matrix.goarch }}
|
||||
path: ${{ env.PROJECT_NAME }}-gui_${{ matrix.goos }}_${{ matrix.goarch }}.*
|
||||
retention-days: 7
|
||||
|
||||
build-web:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: npm
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Build
|
||||
working-directory: web
|
||||
run: |
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- name: Archive
|
||||
run: tar czf ${PROJECT_NAME}-web_dist.tar.gz -C web/dist/web/browser .
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.PROJECT_NAME }}-web_dist
|
||||
path: ${{ env.PROJECT_NAME }}-web_dist.tar.gz
|
||||
retention-days: 7
|
||||
|
||||
# Builds and pushes the API's image, which embeds the web build as its
|
||||
# static UI (see the Dockerfile and cmd/api/main.go's registerWebUI).
|
||||
build-docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
config-inline: |
|
||||
[registry."${{ env.REGISTRY }}/${{ env.REGISTRY_OWNER }}"]
|
||||
http = true
|
||||
insecure = true
|
||||
|
||||
- name: Login to Gitea
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.REGISTRY_OWNER }}/completed:${{ gitea.ref_name }}
|
||||
${{ env.REGISTRY }}/${{ env.REGISTRY_OWNER }}/completed:latest
|
||||
|
||||
release:
|
||||
needs: [build-go, build-gui, build-web]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
|
||||
- name: Upload to the Gitea generic package registry
|
||||
env:
|
||||
VERSION: ${{ gitea.ref_name }}
|
||||
run: |
|
||||
for f in artifacts/*; do
|
||||
name="$(basename "$f")"
|
||||
echo "Uploading $name"
|
||||
curl --fail --user "${{ github.repository_owner }}:${{ secrets.TOKEN }}" \
|
||||
--upload-file "$f" \
|
||||
"https://${{ env.REGISTRY }}/api/packages/${{ env.REGISTRY_OWNER }}/generic/${{ env.PROJECT_NAME }}/${VERSION}/${name}"
|
||||
done
|
||||
|
||||
- name: Create release
|
||||
uses: akkuman/gitea-release-action@v1
|
||||
env:
|
||||
NODE_OPTIONS: "--experimental-fetch" # if nodejs < 18
|
||||
with:
|
||||
files: |-
|
||||
artifacts/**
|
||||
Reference in new issue
Block a user