mirror of
https://github.com/Dvorinka/Primora.git
synced 2026-10-28 07:41:23 +00:00
Security:
- Graceful shutdown: http.Server + signal.NotifyContext, 10s drain,
retention sweeper cancelled before pool close
- Scoped API keys (migration 00006): ingest/read/write/admin enforced in
auth middleware; scope picker + badges in Settings UI; scopeless legacy
keys act as admin. Read-only keys now get 403 on ingest (verified live)
- nginx: baseline security headers on all responses, CSP scoped to SPA;
fixed add_header inheritance shadowing
- better-auth rate limit enabled unconditionally (was gated on NODE_ENV,
which the shipped .env sets to development)
- Mailpit moved to docker-compose.dev.yml; prod compose cannot expose it
- setup.sh generates PRIMORA_ENCRYPTION_KEY
Reliability/ops:
- Retention: per-project retention_{events,audit,webhook}_days
(migration 00007, 0=off) + hourly RetentionSweeper; edit UI in Projects
- GET /api/v1/metrics Prometheus exposition
- compose: healthchecks + restart policies everywhere, dragonfly pinned
to v2.0.0, depends_on service_healthy
- backup.sh/restore.sh (pg_dump -Fc + storage volume); restore verified
against scratch postgres+volume
- .dockerignore: exclude target dirs (build context was 4.7GB)
Correctness/testing:
- DBX transfer endpoint: POST /db-connections/:id/transfer — SQL or Redis
target, 1000-row bound, server-side creds (verified live pg→dragonfly)
- Pagination audit: ListComponents capped at 500 (auto-registers)
- CI: goose up/reset/up job + compose e2e-smoke job (smoke-e2e.sh
verified locally: signup, bootstrap, scoped keys, ingest, metrics)
- k6 load sanity script: 6650 reqs, ~217/s, 0 real failures, p95 221ms
(429s = configured rate limiter working)
Docs: DEPLOYMENT_GUIDE.md, PRODUCTION_READINESS.md; verify script
repaired (stale refs + set -e arithmetic abort). ROADMAP: phase 2 +
phase 6 marked complete.
Authored By: TDvorak <[email protected]>
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
195 lines
6.3 KiB
YAML
195 lines
6.3 KiB
YAML
name: Release
|
|
|
|
# Triggered by semver tags: git tag v0.3.0 && git push --tags
|
|
# Tag must match the root package.json version.
|
|
on:
|
|
push:
|
|
tags: ["v*.*.*"]
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
VERSION: ${{ github.ref_name }}
|
|
|
|
jobs:
|
|
verify:
|
|
name: Verify tag
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Check tag matches package version
|
|
run: |
|
|
PKG=$(node -p "require('./package.json').version")
|
|
if [ "v$PKG" != "$VERSION" ]; then
|
|
echo "tag $VERSION does not match package.json version $PKG"
|
|
exit 1
|
|
fi
|
|
|
|
images:
|
|
name: Build + push ${{ matrix.app }}
|
|
needs: verify
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
app: [backend, auth, frontend]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: apps/${{ matrix.app }}/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ github.repository_owner }}/primora-${{ matrix.app }}:${{ env.VERSION }}
|
|
ghcr.io/${{ github.repository_owner }}/primora-${{ matrix.app }}:latest
|
|
cache-from: type=gha,scope=${{ matrix.app }}
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.app }}
|
|
|
|
cli-binaries:
|
|
name: Compile ${{ matrix.name }}
|
|
needs: verify
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- { target: bun-linux-x64, name: linux-x64 }
|
|
- { target: bun-linux-arm64, name: linux-arm64 }
|
|
- { target: bun-darwin-x64, name: darwin-x64 }
|
|
- { target: bun-darwin-arm64, name: darwin-arm64 }
|
|
- { target: bun-windows-x64, name: windows-x64, ext: .exe }
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v2
|
|
- run: npm ci
|
|
- name: Compile primora + primora-mcp
|
|
run: |
|
|
set -e
|
|
mkdir -p dist-release
|
|
bun build --compile apps/cli/src/cli.ts --target=${{ matrix.target }} --outfile dist-release/primora-${{ matrix.name }}${{ matrix.ext }}
|
|
bun build --compile apps/mcp/src/server.ts --target=${{ matrix.target }} --outfile dist-release/primora-mcp-${{ matrix.name }}${{ matrix.ext }}
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: binaries-${{ matrix.name }}
|
|
path: dist-release/
|
|
if-no-files-found: error
|
|
|
|
desktop:
|
|
name: Desktop bundle (${{ matrix.name }})
|
|
needs: verify
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- { os: ubuntu-22.04, name: linux }
|
|
- { os: macos-latest, name: macos }
|
|
- { os: windows-latest, name: windows }
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
- run: npm ci
|
|
- name: Install Linux webview dependencies
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
|
- name: Build Tauri bundles
|
|
run: npm run bundle --workspace @primora/desktop
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: desktop-${{ matrix.name }}
|
|
path: |
|
|
apps/desktop/src-tauri/target/release/bundle/**/*.AppImage
|
|
apps/desktop/src-tauri/target/release/bundle/**/*.deb
|
|
apps/desktop/src-tauri/target/release/bundle/**/*.rpm
|
|
apps/desktop/src-tauri/target/release/bundle/**/*.dmg
|
|
apps/desktop/src-tauri/target/release/bundle/**/*.msi
|
|
apps/desktop/src-tauri/target/release/bundle/**/*.exe
|
|
if-no-files-found: error
|
|
|
|
npm-packages:
|
|
name: Pack npm tarballs
|
|
needs: verify
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
- run: npm ci
|
|
- run: |
|
|
npm run build --workspace @primora/cli
|
|
npm run build --workspace @primora/mcp
|
|
mkdir -p dist-release
|
|
cd apps/cli && npm pack --pack-destination ../../dist-release
|
|
cd ../mcp && npm pack --pack-destination ../../dist-release
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: npm-tarballs
|
|
path: dist-release/
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: GitHub Release
|
|
needs: [images, cli-binaries, desktop, npm-packages]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
pattern: "*"
|
|
merge-multiple: true
|
|
path: dist-release
|
|
- name: Extract changelog section
|
|
run: |
|
|
awk -v ver="${VERSION#v}" '
|
|
$0 ~ "^## \\[" ver "\\]" { flag=1; next }
|
|
/^## \[/ && flag { exit }
|
|
flag
|
|
' CHANGELOG.md > notes.md
|
|
[ -s notes.md ] || echo "Release ${VERSION}" > notes.md
|
|
- name: Create release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: gh release create "$VERSION" --title "$VERSION" --notes-file notes.md dist-release/*
|
|
|
|
npm-publish:
|
|
name: Publish to npm
|
|
needs: release
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
registry-url: https://registry.npmjs.org
|
|
- run: npm ci
|
|
- run: npm run build --workspace @primora/cli && npm run build --workspace @primora/mcp
|
|
- name: Publish @primora/cli + @primora/mcp
|
|
if: env.NPM_TOKEN != ''
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
npm publish --workspace @primora/cli --access public
|
|
npm publish --workspace @primora/mcp --access public
|
|
- name: Note skipped publish
|
|
if: env.NPM_TOKEN == ''
|
|
run: echo "NPM_TOKEN secret not set — tarballs attached to the GitHub release instead."
|