Skip to content

feat: surface backup failure details #23

feat: surface backup failure details

feat: surface backup failure details #23

Workflow file for this run

name: Binary Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build-web:
name: Build embedded web UI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: "26"
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install web dependencies
run: npm --prefix web ci
- name: Build web UI
run: npm --prefix web run build
- name: Upload web dist
uses: actions/upload-artifact@v7
with:
name: web-dist
path: web/dist
retention-days: 1
build-binary:
name: Build ${{ matrix.platform }}
runs-on: ubuntu-latest
needs:
- build-web
if: ${{ needs.build-web.result == 'success' }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux-amd64
goos: linux
goarch: amd64
exe: nowledge-mem-snap
archive: tar.gz
- platform: linux-arm64
goos: linux
goarch: arm64
exe: nowledge-mem-snap
archive: tar.gz
- platform: linux-armv7
goos: linux
goarch: arm
goarm: "7"
exe: nowledge-mem-snap
archive: tar.gz
- platform: linux-armv6
goos: linux
goarch: arm
goarm: "6"
exe: nowledge-mem-snap
archive: tar.gz
- platform: windows-amd64
goos: windows
goarch: amd64
exe: nowledge-mem-snap.exe
archive: zip
- platform: darwin-amd64
goos: darwin
goarch: amd64
exe: nowledge-mem-snap
archive: tar.gz
- platform: darwin-arm64
goos: darwin
goarch: arm64
exe: nowledge-mem-snap
archive: tar.gz
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.27"
check-latest: true
- name: Download web dist
uses: actions/download-artifact@v8
with:
name: web-dist
path: web/dist
- name: Verify generated ent code
run: |
go generate ./internal/persist/ent
git diff --exit-code -- go.mod go.sum internal/persist/ent
- name: Set build metadata
id: meta
run: echo "build_time=$(date -u '+%Y-%m-%d_%H:%M:%S_UTC')" >> "$GITHUB_OUTPUT"
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: "0"
run: |
test -f web/dist/index.html
mkdir -p dist
go build -trimpath \
-ldflags="-s -w \
-X 'github.com/ca-x/nowledge-mem-snap/version.Version=${{ github.ref_name }}' \
-X 'github.com/ca-x/nowledge-mem-snap/version.BuildTime=${{ steps.meta.outputs.build_time }}' \
-X 'github.com/ca-x/nowledge-mem-snap/version.GitCommit=${{ github.sha }}'" \
-o dist/${{ matrix.exe }} .
- name: Create archive
run: |
cd dist
base="nowledge-mem-snap-${{ github.ref_name }}-${{ matrix.platform }}"
if [ "${{ matrix.archive }}" = "zip" ]; then
zip "${base}.zip" "${{ matrix.exe }}"
else
tar czf "${base}.tar.gz" "${{ matrix.exe }}"
fi
- name: Upload build artifact
uses: actions/upload-artifact@v7
with:
name: nowledge-mem-snap-${{ matrix.platform }}
path: dist/nowledge-mem-snap-${{ github.ref_name }}-${{ matrix.platform }}.*
retention-days: 14
publish-release:
name: Publish release assets
runs-on: ubuntu-latest
needs:
- build-binary
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download binary archives
uses: actions/download-artifact@v8
with:
pattern: nowledge-mem-snap-*
path: release-assets
merge-multiple: true
- name: List release assets
run: ls -lah release-assets
- name: Create draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
printf '%s\n' \
'## Downloads' \
'' \
'Download the archive for your platform, extract it, and run `nowledge-mem-snap`.' \
'' \
'Docker images are published separately by the Docker Build and Push workflow.' \
> release-notes.md
gh release create "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--draft \
--title "$GITHUB_REF_NAME" \
--notes-file release-notes.md
for file in release-assets/*; do
gh release upload "$GITHUB_REF_NAME" "$file" \
--repo "$GITHUB_REPOSITORY" \
--clobber
done