Skip to content

Commit db75d8a

Browse files
edyedy
authored andcommitted
feat: add one-line install script
1 parent b45e565 commit db75d8a

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
cd packages/opencode/dist/opencode-darwin-arm64/bin
3333
tar czf "../../../../../release-assets/opencode-darwin-arm64.tar.gz" opencodex
3434
cd -
35+
cp script/install.sh release-assets/
3536
ls -la release-assets/
3637
3738
- name: Create or Update Release
@@ -40,5 +41,7 @@ jobs:
4041
tag_name: ${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}
4142
name: ${{ github.ref_type == 'tag' && github.ref_name || 'Latest macOS Build' }}
4243
prerelease: ${{ github.ref_type != 'tag' }}
43-
files: release-assets/opencode-darwin-arm64.tar.gz
44+
files: |
45+
release-assets/opencode-darwin-arm64.tar.gz
46+
release-assets/install.sh
4447
fail_on_unmatched_files: true

script/install.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
REPO="3kaiu/opencode-x"
5+
BIN_NAME="opencodex"
6+
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
7+
8+
if [[ "${OSTYPE}" != "darwin"* ]] || [[ "$(uname -m)" != "arm64" ]]; then
9+
echo "Only macOS arm64 is supported." >&2
10+
exit 1
11+
fi
12+
13+
echo "Fetching latest release from ${REPO}..."
14+
LATEST=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
15+
echo "Latest version: ${LATEST}"
16+
17+
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST}/opencode-darwin-arm64.tar.gz"
18+
TMPDIR=$(mktemp -d)
19+
trap 'rm -rf "${TMPDIR}"' EXIT
20+
21+
echo "Downloading ${DOWNLOAD_URL}..."
22+
curl -fsSL "${DOWNLOAD_URL}" -o "${TMPDIR}/opencode.tar.gz"
23+
tar xzf "${TMPDIR}/opencode.tar.gz" -C "${TMPDIR}"
24+
25+
echo "Installing ${BIN_NAME} to ${INSTALL_DIR}..."
26+
install -d "${INSTALL_DIR}"
27+
install "${TMPDIR}/${BIN_NAME}" "${INSTALL_DIR}/${BIN_NAME}"
28+
29+
echo "Installed ${BIN_NAME} ${LATEST} to ${INSTALL_DIR}/${BIN_NAME}"

0 commit comments

Comments
 (0)