Skip to content

Commit a156a2b

Browse files
committed
add version support and release configuration
1 parent ffef3c6 commit a156a2b

File tree

12 files changed

+690
-16
lines changed

12 files changed

+690
-16
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: '1.20'
24+
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v4
27+
with:
28+
version: latest
29+
args: release --clean
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: 2
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- id: memex
9+
main: ./cmd/memex
10+
binary: memex
11+
goos:
12+
- linux
13+
- darwin
14+
- windows
15+
goarch:
16+
- amd64
17+
- arm64
18+
env:
19+
- CGO_ENABLED=0
20+
ldflags:
21+
- -s -w -X main.version={{.Version}}
22+
23+
- id: memexd
24+
main: ./cmd/memexd
25+
binary: memexd
26+
goos:
27+
- linux
28+
- darwin
29+
- windows
30+
goarch:
31+
- amd64
32+
- arm64
33+
env:
34+
- CGO_ENABLED=0
35+
ldflags:
36+
- -s -w -X main.version={{.Version}}
37+
38+
archives:
39+
- id: memex-archive
40+
builds:
41+
- memex
42+
- memexd
43+
name_template: >-
44+
{{ .ProjectName }}_
45+
{{- title .Os }}_
46+
{{- if eq .Arch "amd64" }}x86_64
47+
{{- else if eq .Arch "386" }}i386
48+
{{- else }}{{ .Arch }}{{ end }}
49+
format_overrides:
50+
- goos: windows
51+
format: zip
52+
files:
53+
- README.md
54+
- LICENSE
55+
- docs/*
56+
57+
checksum:
58+
name_template: 'checksums.txt'
59+
60+
changelog:
61+
sort: asc
62+
filters:
63+
exclude:
64+
- '^docs:'
65+
- '^test:'
66+
- '^ci:'
67+
- Merge pull request
68+
- Merge branch
69+
70+
brews:
71+
- repository:
72+
owner: systemshift
73+
name: homebrew-memex
74+
homepage: "https://github.com/systemshift/memex"
75+
description: "Graph-oriented data management tool"
76+
install: |
77+
bin.install "memex"
78+
bin.install "memexd"

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,39 @@ Memex is a graph-oriented data management tool.
1818

1919
## Installation
2020

21+
### From Pre-built Binaries
22+
23+
Download the latest pre-built binaries for your platform from the [GitHub Releases](https://github.com/systemshift/memex/releases) page.
24+
25+
#### Linux and macOS
26+
```bash
27+
# Download and extract the archive
28+
tar xzf memex_<OS>_<ARCH>.tar.gz
29+
30+
# Move binaries to your PATH
31+
sudo mv memex /usr/local/bin/
32+
sudo mv memexd /usr/local/bin/
33+
34+
# Verify installation
35+
memex --version
36+
memexd --version
37+
```
38+
39+
#### Windows
40+
1. Download the ZIP archive for Windows
41+
2. Extract the contents
42+
3. Add the extracted directory to your PATH
43+
4. Verify installation by running `memex --version` and `memexd --version`
44+
45+
### Using Homebrew (macOS)
46+
47+
```bash
48+
# Install both memex and memexd
49+
brew install systemshift/memex/memex
50+
```
51+
52+
### Build from Source
53+
2154
```bash
2255
# Build the CLI tool
2356
go build -o ~/bin/memex ./cmd/memex
@@ -40,6 +73,9 @@ memex connect myrepo.mx
4073
# Show repository status
4174
memex status
4275

76+
# Show version information
77+
memex version
78+
4379
# Add a file
4480
memex add document.txt
4581

cmd/memex/main.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ import (
66
"os"
77
"path/filepath"
88

9-
"github.com/systemshift/memex/pkg/memex"
9+
"github.com/systemshift/memex/internal/memex"
1010
)
1111

12+
var (
13+
showVersion = flag.Bool("version", false, "Show version information")
14+
)
15+
16+
func printVersion() {
17+
fmt.Println(memex.BuildInfo())
18+
os.Exit(0)
19+
}
20+
1221
func usage() {
1322
fmt.Printf(`Usage: %s <command> [arguments]
1423
@@ -21,6 +30,7 @@ Built-in Commands:
2130
link <src> <dst> <type> Create a link between nodes
2231
links <id> Show links for a node
2332
status Show repository status
33+
version Show version information
2434
export <path> Export repository to tar archive
2535
import <path> Import repository from tar archive
2636
@@ -47,6 +57,10 @@ func main() {
4757
flag.Usage = usage
4858
flag.Parse()
4959

60+
if *showVersion {
61+
printVersion()
62+
}
63+
5064
cmds := memex.NewCommands()
5165
defer cmds.Close()
5266

@@ -138,6 +152,15 @@ func main() {
138152
}
139153
err = cmds.Status()
140154

155+
case "version":
156+
if err := cmds.AutoConnect(); err == nil {
157+
// If connected to a repo, show its version too
158+
err = cmds.ShowVersion()
159+
} else {
160+
// Just show memex version
161+
fmt.Println(memex.BuildInfo())
162+
}
163+
141164
case "export":
142165
if len(args) != 1 {
143166
usage()

cmd/memexd/main.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@ import (
99
"net/http"
1010
"os"
1111
"path/filepath"
12+
"strings"
1213

1314
"github.com/go-chi/chi/v5"
1415
"github.com/go-chi/chi/v5/middleware"
16+
"github.com/systemshift/memex/internal/memex"
1517
"github.com/systemshift/memex/internal/memex/core"
1618
"github.com/systemshift/memex/internal/memex/repository"
1719
)
1820

21+
// VersionResponse represents version information
22+
type VersionResponse struct {
23+
Version string `json:"version"`
24+
Commit string `json:"commit"`
25+
BuildDate string `json:"buildDate"`
26+
}
27+
1928
// Server handles HTTP requests and manages the repository
2029
type Server struct {
2130
repo core.Repository
@@ -51,8 +60,14 @@ func main() {
5160
// Parse command line flags
5261
addr := flag.String("addr", ":3000", "HTTP service address")
5362
repoPath := flag.String("repo", "", "Repository path")
63+
showVersion := flag.Bool("version", false, "Show version information")
5464
flag.Parse()
5565

66+
if *showVersion {
67+
fmt.Println(memex.BuildInfo())
68+
os.Exit(0)
69+
}
70+
5671
if *repoPath == "" {
5772
log.Fatal("Repository path required")
5873
}
@@ -87,6 +102,7 @@ func main() {
87102
// Routes
88103
r.Get("/", server.handleIndex)
89104
r.Route("/api", func(r chi.Router) {
105+
r.Get("/version", server.handleVersion)
90106
r.Get("/graph", server.handleGraph)
91107
r.Get("/nodes/{id}", server.handleGetNode)
92108
r.Get("/nodes/{id}/content", server.handleGetContent)
@@ -242,3 +258,23 @@ func (s *Server) handleGetContent(w http.ResponseWriter, r *http.Request) {
242258

243259
w.Write(content)
244260
}
261+
262+
// handleVersion returns version information
263+
func (s *Server) handleVersion(w http.ResponseWriter, r *http.Request) {
264+
info := strings.Split(memex.BuildInfo(), "\n")
265+
version := strings.TrimPrefix(info[0], "Version: ")
266+
commit := strings.TrimPrefix(info[1], "Commit: ")
267+
date := strings.TrimPrefix(info[2], "Build Date: ")
268+
269+
response := VersionResponse{
270+
Version: version,
271+
Commit: commit,
272+
BuildDate: date,
273+
}
274+
275+
w.Header().Set("Content-Type", "application/json")
276+
if err := json.NewEncoder(w).Encode(response); err != nil {
277+
http.Error(w, fmt.Sprintf("Error encoding response: %v", err), http.StatusInternalServerError)
278+
return
279+
}
280+
}

docs/VERSION.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Version Compatibility Guide
2+
3+
Memex uses semantic versioning for both the application and repository format to ensure safe upgrades and compatibility.
4+
5+
## Version Types
6+
7+
### Application Version
8+
- The version of the memex binaries (e.g., 1.2.3)
9+
- Follows semantic versioning (MAJOR.MINOR.PATCH)
10+
- Displayed with `memex --version`
11+
12+
### Repository Format Version
13+
- The version of the .mx file format (e.g., 1.0)
14+
- Uses MAJOR.MINOR format
15+
- Stored in repository header
16+
- Checked when opening repositories
17+
18+
## Compatibility Rules
19+
20+
When opening a repository, Memex checks:
21+
1. Repository format version compatibility
22+
2. Records which version of memex created the repository
23+
24+
Version compatibility rules:
25+
- Major version must match exactly (e.g., 1.x can't open 2.x repositories)
26+
- Minor version of the repository must be <= current version
27+
- The version that created a repository is stored in its header
28+
29+
## Version Information
30+
31+
Use `memex version` to check:
32+
- Current memex version
33+
- Repository format version
34+
- Which memex version created the repository
35+
36+
Example output:
37+
```
38+
Memex Version: 1.2.3
39+
Commit: abc123
40+
Build Date: 2024-01-01
41+
42+
Repository Format Version: 1.0
43+
Created by Memex Version: 1.2.0
44+
```
45+
46+
## Version History
47+
48+
### Repository Format Versions
49+
50+
- 1.0: Initial stable format
51+
- Content-addressable storage
52+
- DAG structure
53+
- Transaction log
54+
- Basic metadata
55+
56+
Future versions will maintain backward compatibility within the same major version.
57+
58+
## Upgrading Repositories
59+
60+
When a new version of Memex is released:
61+
62+
1. If only PATCH version changes:
63+
- No action needed
64+
- Full compatibility maintained
65+
66+
2. If MINOR version changes:
67+
- Repository format is compatible
68+
- New features may be available
69+
- No migration needed
70+
71+
3. If MAJOR version changes:
72+
- Repository format may be incompatible
73+
- Migration tool will be provided
74+
- Check release notes for upgrade path

0 commit comments

Comments
 (0)