Skip to content

Commit

Permalink
Add release for linux aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
hahnavi committed Dec 16, 2024
1 parent b05412e commit 9aff83d
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
56 changes: 47 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,76 @@ on:

jobs:
build-x86_64:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Build
run: cargo build --release --target x86_64-unknown-linux-gnu

- name: Strip binary
run: strip target/x86_64-unknown-linux-gnu/release/komandan

- name: Zip artifact
run: zip -j komandan_${{ github.ref_name }}-linux_x86_64.zip target/x86_64-unknown-linux-gnu/release/komandan
run: zip -j komandan_${{ github.ref_name }}-linux-x86_64.zip target/x86_64-unknown-linux-gnu/release/komandan

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
name: build-x86_64-artifact
path: |
komandan_${{ github.ref_name }}-linux_x86_64.zip
komandan_${{ github.ref_name }}-linux-x86_64.zip
build-aarch64:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: hahnavi/komandan

- name: Add target aarch64-unknown-linux-gnu
run: rustup target add aarch64-unknown-linux-gnu

- name: Install aarch64-linux-gnu-gcc
run: sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu

- name: Build
run: cargo build --release --target aarch64-unknown-linux-gnu

- name: Strip binary
run: aarch64-linux-gnu-strip target/aarch64-unknown-linux-gnu/release/komandan

- name: Zip artifact
run: zip -j komandan_${{ github.ref_name }}-linux-aarch64.zip target/aarch64-unknown-linux-gnu/release/komandan

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-aarch64-artifact
path: |
komandan_${{ github.ref_name }}-linux-aarch64.zip
release:
runs-on: ubuntu-latest
needs: [build-x86_64]
runs-on: ubuntu-22.04
needs: [build-x86_64, build-aarch64]
permissions:
contents: write
steps:
- name: Download artifacts
- name: Download artifact x86_64
uses: actions/download-artifact@v4
with:
name: build-x86_64-artifact

- name: Download artifact aarch64
uses: actions/download-artifact@v4
with:
name: build-artifacts
name: build-aarch64-artifact

- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
name: ${{ github.ref_name }}
body: Release ${{ github.ref_name }}
artifacts: |
komandan_${{ github.ref_name }}-linux_x86_64.zip
komandan_${{ github.ref_name }}-linux-x86_64.zip
komandan_${{ github.ref_name }}-linux-aarch64.zip
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Komandan is a server automation tool that simplifies remote server management by

## Installation

Pre-built binaries for Komandan are available for Linux (x86_64 architecture only) on the [GitHub Releases](https://github.com/hahnavi/komandan/releases) page.
Pre-built binaries for Komandan are available for Linux on the [GitHub Releases](https://github.com/hahnavi/komandan/releases) page.

An installation script is provided for easy installation:

Expand Down
30 changes: 23 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

set -e

get_os_arch() {
local os_name
local arch_name
Expand All @@ -12,12 +14,12 @@ get_os_arch() {
exit 1
fi

if [ "$arch_name" != "x86_64" ]; then
echo "Komandan currently only supports x86_64 architecture. Your architecture: $arch_name"
if [ "$arch_name" = "x86_64" ] || [ "$arch_name" = "aarch64" ]; then
echo "${os_name}-${arch_name}"
else
echo "Komandan currently only supports x86_64 and aarch64 architectures. Your architecture: $arch_name"
exit 1
fi

echo "${os_name}_${arch_name}"
}

install_komandan() {
Expand All @@ -26,10 +28,18 @@ install_komandan() {
local temp_dir
local release_tag
local install_dir
local release_json

os_arch=$(get_os_arch)

release_tag=$(curl -s "https://api.github.com/repos/hahnavi/komandan/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
release_json=$(curl -fs "https://api.github.com/repos/hahnavi/komandan/releases/latest")

if [ $? -ne 0 ]; then
echo "Failed to fetch the latest release information. Please check your network connection and try again."
exit 1
fi

release_tag=$(echo "$release_json" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

if [ -z "$release_tag" ]; then
echo "Could not find the latest release tag."
Expand All @@ -44,7 +54,7 @@ install_komandan() {
mkdir -p "$install_dir"

echo "Downloading Komandan from $download_url"
curl -sSL "$download_url" -o "$temp_dir/$file_name"
curl -fsSL "$download_url" -o "$temp_dir/$file_name"

if [ $? -ne 0 ]; then
echo "Failed to download Komandan."
Expand All @@ -53,13 +63,19 @@ install_komandan() {
fi

unzip -q -o "$temp_dir/$file_name" -d "$install_dir"

if [ $? -ne 0 ]; then
echo "Failed to unzip Komandan."
rm -rf "$temp_dir"
exit 1
fi

chmod +x "$install_dir/komandan"

rm -rf "$temp_dir"

echo "Komandan installed successfully to $install_dir"

# Check if $install_dir is already in PATH
if ! echo "$PATH" | grep -q "$install_dir"; then
echo "Please add $install_dir to your PATH environment variable."
echo "You can do this by adding the following line to your shell's configuration file:"
Expand Down

0 comments on commit 9aff83d

Please sign in to comment.