-
Notifications
You must be signed in to change notification settings - Fork 6
129 lines (112 loc) · 3.84 KB
/
Copy pathcli-publish.yml
File metadata and controls
129 lines (112 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# CLI Publish (Edge) — builds platform-specific binaries on every push to main.
# Publishes to a rolling "edge" GitHub Release at:
# https://github.com/reh3376/mdemg/releases/tag/edge
#
# Binaries: mdemg-darwin-arm64, mdemg-darwin-amd64, mdemg-linux-amd64, mdemg-linux-arm64
# Consumed by: `mdemg upgrade --edge`, `scripts/install.sh` (CHANNEL=edge), manual download
#
# Uses CGO_ENABLED=1 — go-tree-sitter requires C bindings via cgo.
# Darwin builds natively on macOS; Linux cross-compiles via zig.
name: CLI Publish (Edge)
on:
push:
branches: [main]
paths:
- "cmd/**"
- "internal/**"
- "plugins/**"
- "go.mod"
- "go.sum"
workflow_dispatch:
concurrency:
group: edge-publish
cancel-in-progress: true
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
runs-on: macos-latest
strategy:
matrix:
include:
- goos: darwin
goarch: arm64
- goos: darwin
goarch: amd64
- goos: linux
goarch: amd64
cc: "zig cc -target x86_64-linux-gnu"
cxx: "zig c++ -target x86_64-linux-gnu"
- goos: linux
goarch: arm64
cc: "zig cc -target aarch64-linux-gnu"
cxx: "zig c++ -target aarch64-linux-gnu"
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
cache: true
- name: Install Zig (for CGO cross-compilation)
if: matrix.goos == 'linux'
run: brew install zig
- name: Build binary
env:
CGO_ENABLED: "1"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
VERSION="edge-$(git rev-parse --short HEAD)"
COMMIT="$(git rev-parse --short HEAD)"
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
go build \
-ldflags="-s -w -X mdemg/internal/cli.Version=${VERSION} -X mdemg/internal/cli.Commit=${COMMIT} -X mdemg/internal/cli.BuildDate=${BUILD_DATE}" \
-o mdemg-${{ matrix.goos }}-${{ matrix.goarch }} \
./cmd/mdemg
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: mdemg-${{ matrix.goos }}-${{ matrix.goarch }}
path: mdemg-${{ matrix.goos }}-${{ matrix.goarch }}
retention-days: 1
publish:
name: Publish Edge Release
needs: build
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: Generate checksums and publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd artifacts
shasum -a 256 mdemg-* > checksums.txt
cat checksums.txt
COMMIT_SHORT=$(git rev-parse --short HEAD)
COMMIT_MSG=$(git log -1 --pretty=format:"%s")
# Delete existing edge release (if any)
gh release delete edge --yes 2>/dev/null || true
git push origin :refs/tags/edge 2>/dev/null || true
# Create new edge release
gh release create edge \
--title "Edge Build (${COMMIT_SHORT})" \
--notes "**Latest main branch build — auto-updated on every merge.**
Commit: ${COMMIT_SHORT} — ${COMMIT_MSG}
Built: $(date -u +%Y-%m-%dT%H:%M:%SZ)
Download the binary for your platform, \`chmod +x\`, and replace your existing \`mdemg\` binary.
Or run: \`mdemg upgrade --edge\` (v0.4.0+)." \
--prerelease \
mdemg-* checksums.txt