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:
@@ -43,6 +43,22 @@ builds:
|
|||||||
- -X main.Commit={{.Commit}}
|
- -X main.Commit={{.Commit}}
|
||||||
- -X main.Branch={{.Branch}}
|
- -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
|
- id: bd-darwin-amd64
|
||||||
main: ./cmd/bd
|
main: ./cmd/bd
|
||||||
binary: bd
|
binary: bd
|
||||||
@@ -184,8 +200,8 @@ release:
|
|||||||
name_template: "v{{.Version}}"
|
name_template: "v{{.Version}}"
|
||||||
header: |
|
header: |
|
||||||
## beads v{{.Version}}
|
## 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
|
### Installation
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,8 @@
|
|||||||
"os": [
|
"os": [
|
||||||
"darwin",
|
"darwin",
|
||||||
"linux",
|
"linux",
|
||||||
"win32"
|
"win32",
|
||||||
|
"android"
|
||||||
],
|
],
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64",
|
"x64",
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ function getPlatformInfo() {
|
|||||||
case 'linux':
|
case 'linux':
|
||||||
platformName = 'linux';
|
platformName = 'linux';
|
||||||
break;
|
break;
|
||||||
|
case 'android':
|
||||||
|
platformName = 'android';
|
||||||
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
platformName = 'windows';
|
platformName = 'windows';
|
||||||
binaryName = 'bd.exe';
|
binaryName = 'bd.exe';
|
||||||
@@ -109,7 +112,7 @@ function extractTarGz(tarGzPath, destDir, binaryName) {
|
|||||||
throw new Error(`Binary not found after extraction: ${extractedBinary}`);
|
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') {
|
if (os.platform() !== 'win32') {
|
||||||
fs.chmodSync(extractedBinary, 0o755);
|
fs.chmodSync(extractedBinary, 0o755);
|
||||||
}
|
}
|
||||||
@@ -177,16 +180,8 @@ async function install() {
|
|||||||
|
|
||||||
console.log(`Installing bd v${VERSION} for ${platformName}-${archName}...`);
|
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
|
// Determine destination paths
|
||||||
const binDir = path.join(__dirname, '..', 'bin');
|
const binDir = path.join(__dirname, '..', 'bin');
|
||||||
const archivePath = path.join(binDir, archiveName);
|
|
||||||
const binaryPath = path.join(binDir, binaryName);
|
const binaryPath = path.join(binDir, binaryName);
|
||||||
|
|
||||||
// Ensure bin directory exists
|
// Ensure bin directory exists
|
||||||
@@ -194,6 +189,14 @@ async function install() {
|
|||||||
fs.mkdirSync(binDir, { recursive: true });
|
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
|
// Download the archive
|
||||||
console.log(`Downloading bd binary...`);
|
console.log(`Downloading bd binary...`);
|
||||||
await downloadFile(downloadUrl, archivePath);
|
await downloadFile(downloadUrl, archivePath);
|
||||||
@@ -213,7 +216,7 @@ async function install() {
|
|||||||
const output = execSync(`"${binaryPath}" version`, { encoding: 'utf8' });
|
const output = execSync(`"${binaryPath}" version`, { encoding: 'utf8' });
|
||||||
console.log(`✓ bd installed successfully: ${output.trim()}`);
|
console.log(`✓ bd installed successfully: ${output.trim()}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('Warning: Could not verify binary version');
|
throw new Error(`Binary verification failed: ${err.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ async function testPlatformDetection() {
|
|||||||
const supportedPlatforms = {
|
const supportedPlatforms = {
|
||||||
darwin: ['x64', 'arm64'],
|
darwin: ['x64', 'arm64'],
|
||||||
linux: ['x64', 'arm64'],
|
linux: ['x64', 'arm64'],
|
||||||
|
android: ['x64', 'arm64'],
|
||||||
win32: ['x64', 'arm64']
|
win32: ['x64', 'arm64']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user