feat: add native Android/Termux binary support (#887)

feat: added android support for running with termux

Adds GOOS=android arm64 build to goreleaser and platform detection in npm postinstall.

Tested by contributor on Termux where os.platform() returns 'android' and Linux binaries fail due to bionic vs glibc.
This commit is contained in:
Ariff Azman
2026-01-06 12:06:25 +08:00
committed by GitHub
parent a61cbde692
commit 2a579a539b
4 changed files with 34 additions and 13 deletions

View File

@@ -43,6 +43,22 @@ builds:
- -X main.Commit={{.Commit}}
- -X main.Branch={{.Branch}}
- id: bd-android-arm64
main: ./cmd/bd
binary: bd
env:
- CGO_ENABLED=0
goos:
- android
goarch:
- arm64
ldflags:
- -s -w
- -X main.Version={{.Version}}
- -X main.Build={{.ShortCommit}}
- -X main.Commit={{.Commit}}
- -X main.Branch={{.Branch}}
- id: bd-darwin-amd64
main: ./cmd/bd
binary: bd
@@ -184,8 +200,8 @@ release:
name_template: "v{{.Version}}"
header: |
## beads v{{.Version}}
Pre-compiled binaries for Linux, macOS (Intel & Apple Silicon), Windows (AMD64 & ARM64), and FreeBSD.
Pre-compiled binaries for Linux, macOS (Intel & Apple Silicon), Windows (AMD64 & ARM64), Android/Termux (ARM64), and FreeBSD.
### Installation

View File

@@ -39,7 +39,8 @@
"os": [
"darwin",
"linux",
"win32"
"win32",
"android"
],
"cpu": [
"x64",

View File

@@ -27,6 +27,9 @@ function getPlatformInfo() {
case 'linux':
platformName = 'linux';
break;
case 'android':
platformName = 'android';
break;
case 'win32':
platformName = 'windows';
binaryName = 'bd.exe';
@@ -109,7 +112,7 @@ function extractTarGz(tarGzPath, destDir, binaryName) {
throw new Error(`Binary not found after extraction: ${extractedBinary}`);
}
// Make executable on Unix-like systems
// Make executable on Unix-like systems (Linux, macOS, Android)
if (os.platform() !== 'win32') {
fs.chmodSync(extractedBinary, 0o755);
}
@@ -177,16 +180,8 @@ async function install() {
console.log(`Installing bd v${VERSION} for ${platformName}-${archName}...`);
// Construct download URL
// Format: https://github.com/steveyegge/beads/releases/download/v0.21.5/beads_0.21.5_darwin_amd64.tar.gz
const releaseVersion = VERSION;
const archiveExt = platformName === 'windows' ? 'zip' : 'tar.gz';
const archiveName = `beads_${releaseVersion}_${platformName}_${archName}.${archiveExt}`;
const downloadUrl = `https://github.com/steveyegge/beads/releases/download/v${releaseVersion}/${archiveName}`;
// Determine destination paths
const binDir = path.join(__dirname, '..', 'bin');
const archivePath = path.join(binDir, archiveName);
const binaryPath = path.join(binDir, binaryName);
// Ensure bin directory exists
@@ -194,6 +189,14 @@ async function install() {
fs.mkdirSync(binDir, { recursive: true });
}
// Construct download URL
// Format: https://github.com/steveyegge/beads/releases/download/v0.21.5/beads_0.21.5_darwin_amd64.tar.gz
const releaseVersion = VERSION;
const archiveExt = platformName === 'windows' ? 'zip' : 'tar.gz';
const archiveName = `beads_${releaseVersion}_${platformName}_${archName}.${archiveExt}`;
const downloadUrl = `https://github.com/steveyegge/beads/releases/download/v${releaseVersion}/${archiveName}`;
const archivePath = path.join(binDir, archiveName);
// Download the archive
console.log(`Downloading bd binary...`);
await downloadFile(downloadUrl, archivePath);
@@ -213,7 +216,7 @@ async function install() {
const output = execSync(`"${binaryPath}" version`, { encoding: 'utf8' });
console.log(`✓ bd installed successfully: ${output.trim()}`);
} catch (err) {
console.warn('Warning: Could not verify binary version');
throw new Error(`Binary verification failed: ${err.message}`);
}
} catch (err) {

View File

@@ -371,6 +371,7 @@ async function testPlatformDetection() {
const supportedPlatforms = {
darwin: ['x64', 'arm64'],
linux: ['x64', 'arm64'],
android: ['x64', 'arm64'],
win32: ['x64', 'arm64']
};