commit 463b052a3aad6e4635bad484964b45a0e73258ec Author: tuankiet2s Date: Mon Aug 11 11:10:09 2025 +0700 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..372e8c3 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +## Act Runner Installer + +Simple installer to fetch and install the latest `gitea/act_runner` release for your Linux machine. + +### Quick start + +Run the installer directly: + +```bash +curl -fSSL https:///install.sh | bash +``` + +If your environment requires elevated permissions to write to `/usr/local/bin`, run with sudo: + +```bash +curl -fSSL https:///install.sh | sudo bash +``` + +### What it does + +- Detects your CPU architecture +- Fetches the latest `act_runner` release info +- Downloads the appropriate Linux binary +- Installs it to `/usr/local/bin/act_runner` and makes it executable + +### Requirements + +- Linux +- `curl`, `jq`, `wget`, `unxz`, `sha256sum` + +### Notes + +- The script will update an existing installation if a newer version is available. +- You may need network access to `gitea.com` to retrieve release metadata. + +### Uninstall + +```bash +sudo rm -f /usr/local/bin/act_runner +``` diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..6d80928 --- /dev/null +++ b/install.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +check_command() { + command -v $1 >/dev/null 2>&1 +} + +check_version() { + act_runner_version=$(act_runner -v | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+') + echo $act_runner_version +} + +if check_command act_runner; then + current_version=$(check_version) + echo "Current act_runner version: $current_version" +fi + +required_commands=("curl" "jq" "wget" "unxz" "sha256sum") +for cmd in "${required_commands[@]}"; do + if ! check_command $cmd; then + echo "Error: '$cmd' command not found. Please make sure all required commands are installed." + exit 1 + fi +done + +arch=$(uname -m) +if [ "$arch" = "x86_64" ]; then + arch="amd64" +fi + +json=$(curl -s https://gitea.com/api/v1/repos/gitea/act_runner/releases/latest) +latest_version=$(echo $json | jq -r '.tag_name') +url_checksum=$(echo $json | jq -r '.assets[] | select(.name | contains("linux-'$arch'") and contains(".xz.sha256")) | .browser_download_url') +url_binary=$(echo $json | jq -r '.assets[] | select(.name | contains("linux-'$arch'") and contains(".xz")) | .browser_download_url') +checksum_filename=$(basename $url_checksum) +filename=$(basename $url_binary) + +if [ -z "$current_version" ] || [ "$current_version" != "$latest_version" ]; then + echo "Updating act_runner to version: $latest_version" + wget $url_binary + sha256sum -c $checksum_filename + rm $checksum_filename + unxz $filename + filename=$(echo $filename | sed 's/\.xz$//') + mv $filename '/usr/local/bin/act_runner' + chmod +x /usr/local/bin/act_runner + echo "Update completed." +else + echo "act_runner is up to date." +fi