Skip to content

fix: Delete conversations' both perspectives at once #23

fix: Delete conversations' both perspectives at once

fix: Delete conversations' both perspectives at once #23

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Target release tag (e.g., v0.2.2). Binaries and Docker image are published to this release."
required: true
from_master:
description: "Build from master instead of the tag's code"
type: boolean
default: false
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
resolve:
runs-on: ubuntu-latest
outputs:
build_ref: ${{ steps.refs.outputs.build_ref }}
release_tag: ${{ steps.refs.outputs.release_tag }}
docker_tags: ${{ steps.refs.outputs.docker_tags }}
steps:
- name: Resolve refs
id: refs
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
if [ "${{ inputs.from_master }}" = "true" ]; then
echo "build_ref=master" >> "$GITHUB_OUTPUT"
else
echo "build_ref=${TAG}" >> "$GITHUB_OUTPUT"
fi
echo "release_tag=${TAG}" >> "$GITHUB_OUTPUT"
VERSION="${TAG#v}"
MAJOR="${VERSION%%.*}"
MINOR="${VERSION#*.}"; MINOR="${MINOR%%.*}"
echo "docker_tags<<EOF" >> "$GITHUB_OUTPUT"
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG}" >> "$GITHUB_OUTPUT"
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${MAJOR}.${MINOR}" >> "$GITHUB_OUTPUT"
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${MAJOR}" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
else
TAG="${GITHUB_REF#refs/tags/}"
echo "build_ref=${GITHUB_REF}" >> "$GITHUB_OUTPUT"
echo "release_tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "docker_tags=" >> "$GITHUB_OUTPUT"
fi
binaries:
needs: resolve
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
runner: ubuntu-latest
- goos: linux
goarch: arm64
runner: ubuntu-latest
cross: true
zig_target: aarch64-linux-gnu
- goos: darwin
goarch: arm64
runner: macos-latest
- goos: windows
goarch: amd64
runner: ubuntu-latest
cross: true
zig_target: x86_64-windows-gnu
runs-on: ${{ matrix.runner }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.resolve.outputs.build_ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Build frontend
run: |
cd frontend/admin-ui && npm install --silent && npx vite build && cd ../..
cd frontend/voice-ui && npm install --silent && npx vite build && cd ../..
rm -rf server/frontend/admin-ui && cp -r frontend/admin-ui/dist server/frontend/admin-ui
rm -rf server/frontend/voice-ui && cp -r frontend/voice-ui/dist server/frontend/voice-ui
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: server/go.mod
cache-dependency-path: server/go.sum
- name: Embed models
run: |
go run scripts/download-model.go
rm -rf server/models/wakeword server/models/auxiliary
cp -r models/wakeword server/models/wakeword
cp -r models/auxiliary server/models/auxiliary
- name: Setup Zig
if: matrix.cross
uses: mlugg/setup-zig@v2
with:
version: 0.14.1
- name: Create zig wrapper scripts
if: matrix.cross
run: |
mkdir -p /tmp/zigcc
printf '#!/bin/sh\nexec zig cc -target %s "$@"\n' "${{ matrix.zig_target }}" > /tmp/zigcc/zcc
printf '#!/bin/sh\nexec zig c++ -target %s "$@"\n' "${{ matrix.zig_target }}" > /tmp/zigcc/zxx
chmod +x /tmp/zigcc/zcc /tmp/zigcc/zxx
- name: Build binary
working-directory: server
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "1"
CC: ${{ matrix.cross && '/tmp/zigcc/zcc' || '' }}
CXX: ${{ matrix.cross && '/tmp/zigcc/zxx' || '' }}
run: |
EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then EXT=".exe"; fi
go build -trimpath -ldflags="-s -w" -o ../magec-${{ matrix.goos }}-${{ matrix.goarch }}${EXT} .
- name: Package
run: |
GOOS="${{ matrix.goos }}"
GOARCH="${{ matrix.goarch }}"
NAME="magec-${GOOS}-${GOARCH}"
mkdir -p dist
if [ "$GOOS" = "windows" ]; then
cp "magec-${GOOS}-${GOARCH}.exe" dist/magec.exe
else
cp "magec-${GOOS}-${GOARCH}" dist/magec
fi
cp config.example.yaml dist/
if [ "$GOOS" = "windows" ]; then
cd dist && zip -r "../${NAME}.zip" . && cd ..
else
tar czf "${NAME}.tar.gz" -C dist .
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: magec-${{ matrix.goos }}-${{ matrix.goarch }}
path: magec-${{ matrix.goos }}-${{ matrix.goarch }}.*
docker:
needs: resolve
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.resolve.outputs.build_ref }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tag push)
if: github.event_name == 'push'
id: meta_push
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=sha
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: docker/build/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ github.event_name == 'push' && steps.meta_push.outputs.tags || needs.resolve.outputs.docker_tags }}
labels: ${{ steps.meta_push.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
runs-on: ubuntu-latest
needs: [resolve, binaries, docker]
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Upload assets to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload --repo "${{ github.repository }}" \
"${{ needs.resolve.outputs.release_tag }}" \
artifacts/*.tar.gz artifacts/*.zip --clobber