Skip to content

Commit 7cc5dbc

Browse files
authored
Merge pull request #5 from Gladium-AI/codex/release-install-flow
ci: add release binary automation and installer
2 parents e15c0c7 + b3037cb commit 7cc5dbc

3 files changed

Lines changed: 267 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: release-${{ github.workflow }}-${{ github.event.release.tag_name || github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
build:
18+
name: Build Release Artifacts
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 20
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- goos: linux
26+
goarch: amd64
27+
archive_ext: tar.gz
28+
- goos: linux
29+
goarch: arm64
30+
archive_ext: tar.gz
31+
- goos: darwin
32+
goarch: amd64
33+
archive_ext: tar.gz
34+
- goos: darwin
35+
goarch: arm64
36+
archive_ext: tar.gz
37+
- goos: windows
38+
goarch: amd64
39+
archive_ext: zip
40+
- goos: windows
41+
goarch: arm64
42+
archive_ext: zip
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v6
47+
with:
48+
persist-credentials: false
49+
50+
- name: Set up Go
51+
uses: actions/setup-go@v6
52+
with:
53+
go-version-file: go.mod
54+
55+
- name: Build archive
56+
shell: bash
57+
env:
58+
BINARY: flare-edge-cli
59+
GOOS: ${{ matrix.goos }}
60+
GOARCH: ${{ matrix.goarch }}
61+
ARCHIVE_EXT: ${{ matrix.archive_ext }}
62+
TAG: ${{ github.event.release.tag_name || github.ref_name }}
63+
run: |
64+
set -euo pipefail
65+
66+
version="${TAG#refs/tags/}"
67+
staging_dir="dist/${BINARY}_${version}_${GOOS}_${GOARCH}"
68+
archive_base="${BINARY}_${version}_${GOOS}_${GOARCH}"
69+
binary_name="${BINARY}"
70+
71+
if [ "${GOOS}" = "windows" ]; then
72+
binary_name="${binary_name}.exe"
73+
fi
74+
75+
mkdir -p "${staging_dir}"
76+
GOOS="${GOOS}" GOARCH="${GOARCH}" CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o "${staging_dir}/${binary_name}" ./cmd/flare-edge-cli
77+
cp LICENSE README.md "${staging_dir}/"
78+
79+
pushd dist >/dev/null
80+
if [ "${ARCHIVE_EXT}" = "zip" ]; then
81+
zip -rq "${archive_base}.zip" "${archive_base}"
82+
else
83+
tar -czf "${archive_base}.tar.gz" "${archive_base}"
84+
fi
85+
popd >/dev/null
86+
87+
- name: Upload artifact
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: release-${{ matrix.goos }}-${{ matrix.goarch }}
91+
path: |
92+
dist/*.tar.gz
93+
dist/*.zip
94+
if-no-files-found: error
95+
96+
publish:
97+
name: Publish Release Assets
98+
needs: build
99+
runs-on: ubuntu-latest
100+
timeout-minutes: 10
101+
102+
steps:
103+
- name: Download artifacts
104+
uses: actions/download-artifact@v5
105+
with:
106+
path: dist
107+
pattern: release-*
108+
merge-multiple: true
109+
110+
- name: Generate checksums
111+
shell: bash
112+
run: |
113+
set -euo pipefail
114+
cd dist
115+
shasum -a 256 *.tar.gz *.zip > checksums.txt
116+
117+
- name: Upload release assets
118+
uses: softprops/action-gh-release@v2
119+
with:
120+
files: |
121+
dist/*.tar.gz
122+
dist/*.zip
123+
dist/checksums.txt

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,26 @@ The implementation is intentionally biased toward agent use:
7272

7373
## Install
7474

75-
Build the binary from the repository root:
75+
One-liner installer for Linux and macOS:
76+
77+
```bash
78+
curl -fsSL https://raw.githubusercontent.com/Gladium-AI/flare-edge-cli/main/install.sh | sh
79+
```
80+
81+
The installer detects your OS and CPU architecture, downloads the latest GitHub release archive, and installs `flare-edge-cli` into a user-local bin directory. It prefers `INSTALL_DIR` when set, then `XDG_BIN_HOME`, then `~/.local/bin`, then `~/bin`.
82+
83+
Prebuilt release archives are attached automatically for:
84+
85+
- `linux/amd64`
86+
- `linux/arm64`
87+
- `darwin/amd64`
88+
- `darwin/arm64`
89+
- `windows/amd64`
90+
- `windows/arm64`
91+
92+
Release downloads are published on the [GitHub Releases](https://github.com/Gladium-AI/flare-edge-cli/releases) page.
93+
94+
Build from source from the repository root:
7695

7796
```bash
7897
make build

install.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
REPO="${REPO:-Gladium-AI/flare-edge-cli}"
5+
BINARY="${BINARY:-flare-edge-cli}"
6+
7+
resolve_install_dir() {
8+
if [ -n "${INSTALL_DIR:-}" ]; then
9+
printf '%s\n' "${INSTALL_DIR}"
10+
return
11+
fi
12+
13+
if [ -n "${XDG_BIN_HOME:-}" ]; then
14+
printf '%s\n' "${XDG_BIN_HOME}"
15+
return
16+
fi
17+
18+
if [ -d "${HOME}/.local/bin" ]; then
19+
printf '%s\n' "${HOME}/.local/bin"
20+
return
21+
fi
22+
23+
if [ -d "${HOME}/bin" ]; then
24+
printf '%s\n' "${HOME}/bin"
25+
return
26+
fi
27+
28+
printf '%s\n' "${HOME}/.local/bin"
29+
}
30+
31+
detect_platform() {
32+
case "$(uname -s)" in
33+
Linux*)
34+
GOOS="linux"
35+
;;
36+
Darwin*)
37+
GOOS="darwin"
38+
;;
39+
*)
40+
echo "Unsupported OS: $(uname -s)" >&2
41+
exit 1
42+
;;
43+
esac
44+
45+
case "$(uname -m)" in
46+
x86_64|amd64)
47+
GOARCH="amd64"
48+
;;
49+
arm64|aarch64)
50+
GOARCH="arm64"
51+
;;
52+
*)
53+
echo "Unsupported architecture: $(uname -m)" >&2
54+
exit 1
55+
;;
56+
esac
57+
}
58+
59+
fetch_latest_tag() {
60+
api_url="https://api.github.com/repos/${REPO}/releases/latest"
61+
62+
if command -v curl >/dev/null 2>&1; then
63+
curl -fsSL "${api_url}" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n 1
64+
return
65+
fi
66+
67+
if command -v wget >/dev/null 2>&1; then
68+
wget -qO- "${api_url}" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n 1
69+
return
70+
fi
71+
72+
echo "Error: curl or wget is required" >&2
73+
exit 1
74+
}
75+
76+
download_archive() {
77+
url="$1"
78+
out="$2"
79+
80+
if command -v curl >/dev/null 2>&1; then
81+
curl -fsSL "${url}" -o "${out}"
82+
return
83+
fi
84+
85+
wget -q "${url}" -O "${out}"
86+
}
87+
88+
INSTALL_DIR="$(resolve_install_dir)"
89+
detect_platform
90+
91+
echo "Detected platform: ${GOOS}/${GOARCH}"
92+
93+
TAG="${TAG:-$(fetch_latest_tag)}"
94+
if [ -z "${TAG}" ]; then
95+
echo "Error: could not determine latest release tag" >&2
96+
exit 1
97+
fi
98+
99+
ARCHIVE="${BINARY}_${TAG}_${GOOS}_${GOARCH}.tar.gz"
100+
URL="https://github.com/${REPO}/releases/download/${TAG}/${ARCHIVE}"
101+
TMPDIR="$(mktemp -d)"
102+
trap 'rm -rf "${TMPDIR}"' EXIT INT TERM
103+
104+
echo "Latest release: ${TAG}"
105+
echo "Downloading ${URL}"
106+
download_archive "${URL}" "${TMPDIR}/${ARCHIVE}"
107+
108+
tar -xzf "${TMPDIR}/${ARCHIVE}" -C "${TMPDIR}"
109+
EXTRACTED_DIR="${TMPDIR}/${BINARY}_${TAG}_${GOOS}_${GOARCH}"
110+
111+
mkdir -p "${INSTALL_DIR}"
112+
install -m 0755 "${EXTRACTED_DIR}/${BINARY}" "${INSTALL_DIR}/${BINARY}"
113+
114+
echo "Installed ${BINARY} ${TAG} to ${INSTALL_DIR}/${BINARY}"
115+
116+
case ":${PATH}:" in
117+
*":${INSTALL_DIR}:"*)
118+
;;
119+
*)
120+
echo
121+
echo "Add ${INSTALL_DIR} to your PATH:"
122+
echo " export PATH=\"${INSTALL_DIR}:\$PATH\""
123+
;;
124+
esac

0 commit comments

Comments
 (0)