17 Commits
Author SHA1 Message Date
pancake 4ae27a8b29 Release v3 2026-07-17 16:54:02 +02:00
pancake 00f94c0183 Use /usr/local for macOS 2026-07-17 16:53:38 +02:00
pancake 9b35152112 hint last actions in readme 2026-07-17 16:53:30 +02:00
pancake b634f0930a Nit about the install pfx with precompiled 2026-07-17 05:11:58 +02:00
pancake 797a7d3928 Simplify macos pkg download 2026-07-17 05:10:53 +02:00
pancake f382331e37 One curl instead of two wgets 2026-07-17 05:02:12 +02:00
pancake e61742e393 Unnecessry set -e 2026-07-17 04:47:32 +02:00
pancake ca8063dc32 Simplify r2 version code 2026-07-17 04:45:08 +02:00
pancake 93938f7352 Simplify PREFIX usage 2026-07-17 04:43:43 +02:00
pancake 7e63e8d58f Cleaner retries 2026-07-17 04:40:35 +02:00
pancake 3c92cd5304 A bit more flexible zip flatten for windows 2026-07-17 04:39:00 +02:00
pancake 5e003dc6ef Don't spam the terminal on curl 2026-07-17 04:36:05 +02:00
pancake 9480a622a6 Validate versiom before calling the gh api 2026-07-17 04:35:06 +02:00
pancake 320e303ba2 Retry on gh api failure 2026-07-17 02:29:34 +02:00
pancake 6c4ee73104 Release v2 2026-05-15 11:36:02 +02:00
pancake 1f8ec6aa3c Fix lintings issues spotted 2026-05-15 11:36:00 +02:00
pancake 1a2aa12b7a Install without symlinks when building from git 2026-05-15 11:30:16 +02:00
2 changed files with 111 additions and 83 deletions

No files matched your search

+26 -13
View File
@@ -7,7 +7,7 @@ Composite GitHub Action to install radare2 in CI workflows. Supports Linux, macO
Reference the action from your workflow:
```yaml
- uses: radareorg/github-actions@v1
- uses: radareorg/github-actions@v3
```
## Inputs
@@ -16,7 +16,7 @@ Reference the action from your workflow:
|-------|-------------|---------|
| `version` | Radare2 version to install (e.g., `6.1.2`). Empty for latest. | `""` (latest) |
| `from-git` | Build from git source instead of release packages. | `false` |
| `prefix` | Installation prefix. | `/usr` |
| `prefix` | Installation prefix. Release packages install to the platform default; a custom prefix requires `from-git`. | `/usr` on Linux, `/usr/local` on macOS, `RUNNER_TEMP/radare2` on Windows |
## Outputs
@@ -31,14 +31,14 @@ Reference the action from your workflow:
```yaml
steps:
- uses: radareorg/github-actions@v1
- uses: radareorg/github-actions@v3
```
### Install a specific version
```yaml
steps:
- uses: radareorg/github-actions@v1
- uses: radareorg/github-actions@v3
with:
version: '6.1.2'
```
@@ -47,7 +47,7 @@ steps:
```yaml
steps:
- uses: radareorg/github-actions@v1
- uses: radareorg/github-actions@v3
with:
from-git: true
```
@@ -56,7 +56,7 @@ steps:
```yaml
steps:
- uses: radareorg/github-actions@v1
- uses: radareorg/github-actions@v3
with:
version: '6.1.2'
from-git: true
@@ -66,12 +66,25 @@ steps:
```yaml
steps:
- uses: radareorg/github-actions@v1
- uses: radareorg/github-actions@v3
with:
from-git: true
prefix: '/opt/radare2'
```
### Build from git on Windows
```yaml
steps:
- uses: actions/checkout@v7
- uses: TheMrMilchmann/setup-msvc-dev@v4
with:
arch: x64
- uses: radareorg/github-actions@v3
with:
from-git: true
```
### Multi-platform CI with build matrix
```yaml
@@ -98,8 +111,8 @@ jobs:
build_system: make
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: radareorg/github-actions@v1
- uses: actions/checkout@v7
- uses: radareorg/github-actions@v3
id: r2
- name: Build with Make
if: matrix.build_system == 'make'
@@ -118,7 +131,7 @@ jobs:
```yaml
steps:
- uses: radareorg/github-actions@v1
- uses: radareorg/github-actions@v3
id: r2
- run: echo "Installed r2 ${{ steps.r2.outputs.version }} at ${{ steps.r2.outputs.prefix }}"
```
@@ -127,15 +140,15 @@ steps:
The operating system is auto-detected from the runner:
- **Linux** - Downloads and installs `.deb` packages (`radare2` + `radare2-dev`). Architecture is detected via `dpkg --print-architecture`.
- **macOS** - Downloads and installs `.pkg` package. Detects `arm64` vs `x86_64` automatically.
- **Linux** - Downloads and installs `.deb` packages (`radare2` + `radare2-dev`) under `/usr`. Architecture is detected via `dpkg --print-architecture`.
- **macOS** - Downloads and installs `.pkg` package under `/usr/local`. Detects `arm64` vs `x86_64` automatically.
- **Windows** - Downloads and extracts the `.zip` release using PowerShell, handles nested subdirectories automatically, then adds `bin/` to `PATH`.
When `from-git` is `true`, the action clones the radare2 repository and builds from source using `sys/install.sh` on Unix or `meson`/`ninja` on Windows.
## Notes
- Windows git builds use meson/ninja and require a Visual C++ environment. Add `ilammy/msvc-dev-cmd@v1` before this action if building from source on Windows.
- Windows git builds use meson/ninja and require a Visual C++ environment. Add `TheMrMilchmann/setup-msvc-dev@v4` with `arch: x64` before this action if building from source on Windows.
- Both `radare2` and `radare2-dev` packages are installed on Linux so headers and pkg-config files are available for building plugins.
- The action verifies the installation by running `radare2 -v` at the end.
- Use `concurrency` with `cancel-in-progress: true` to avoid wasting CI minutes on superseded pushes.
+85 -70
View File
@@ -14,14 +14,14 @@ inputs:
required: false
default: 'false'
prefix:
description: 'Installation prefix'
description: 'Installation prefix. Defaults to /usr on Linux, /usr/local on macOS, and RUNNER_TEMP/radare2 on Windows.'
required: false
default: '/usr'
outputs:
version:
description: 'Installed radare2 version'
value: ${{ steps.resolve.outputs.r2v }}
value: ${{ steps.verify.outputs.version }}
prefix:
description: 'Installation prefix'
value: ${{ steps.prefix.outputs.prefix }}
@@ -29,22 +29,53 @@ outputs:
runs:
using: 'composite'
steps:
- name: Resolve prefix
id: prefix
shell: bash
env:
R2_PREFIX: ${{ inputs.prefix }}
run: |
PREFIX="${R2_PREFIX:-/usr}"
case "$RUNNER_OS:$PREFIX" in
macOS:/usr) PREFIX="/usr/local" ;;
Windows:/usr) PREFIX="$RUNNER_TEMP/radare2" ;;
esac
echo "prefix=$PREFIX" >> "$GITHUB_OUTPUT"
- name: Validate release prefix
if: inputs.from-git != 'true' && runner.os != 'Windows'
shell: bash
env:
R2_PREFIX: ${{ steps.prefix.outputs.prefix }}
run: |
case "$RUNNER_OS" in
Linux) EXPECTED_PREFIX="/usr" ;;
macOS) EXPECTED_PREFIX="/usr/local" ;;
esac
if [ "$R2_PREFIX" != "$EXPECTED_PREFIX" ]; then
echo "::error::Custom prefixes are only supported for git builds on Unix; release packages install to $EXPECTED_PREFIX"
exit 1
fi
- name: Resolve version
id: resolve
shell: bash
env:
GH_TOKEN: ${{ github.token }}
R2V_INPUT: ${{ inputs.version }}
FROM_GIT: ${{ inputs.from-git }}
run: |
set -e
R2V="$R2V_INPUT"
if [ -z "$R2V" ] && [ "$FROM_GIT" != "true" ]; then
R2V=$(gh api repos/radareorg/radare2/releases/latest --jq .tag_name) || true
if [ -z "$R2V" ]; then
echo "::error::Failed to resolve latest radare2 release version"
exit 1
fi
# Resolve the tag from the releases/latest redirect: unlike the gh api,
# this needs no token and cannot return HTML instead of JSON
URL=$(curl -fsSL --retry 3 -o /dev/null -w '%{url_effective}' https://github.com/radareorg/radare2/releases/latest) || true
case "$URL" in
*/tag/*) R2V="${URL##*/tag/}" ;;
*)
echo "::error::Failed to resolve latest radare2 release version"
exit 1
;;
esac
echo "Resolved latest release: $R2V"
fi
echo "r2v=$R2V" >> "$GITHUB_OUTPUT"
@@ -55,19 +86,22 @@ runs:
shell: bash
env:
R2V: ${{ steps.resolve.outputs.r2v }}
R2_PREFIX: ${{ inputs.prefix }}
R2_PREFIX: ${{ steps.prefix.outputs.prefix }}
run: |
set -e
CLONEARGS="--depth=1"
BUILD_DIR="$(mktemp -d "${RUNNER_TEMP:-/tmp}/r2build.XXXXXX")"
trap 'rm -rf "$BUILD_DIR"' EXIT
CLONEARGS=(--depth=1)
if [ -n "$R2V" ]; then
CLONEARGS="$CLONEARGS --branch $R2V"
CLONEARGS+=(--branch "$R2V")
fi
git clone $CLONEARGS https://github.com/radareorg/radare2.git /tmp/_r2build
cd /tmp/_r2build
git clone "${CLONEARGS[@]}" https://github.com/radareorg/radare2.git "$BUILD_DIR"
cd "$BUILD_DIR"
export CFLAGS="-O2 -Wno-unused-result"
./sys/install.sh "$R2_PREFIX"
cd /
rm -rf /tmp/_r2build
./sys/install.sh --install "--prefix=$R2_PREFIX"
if [ -d "$R2_PREFIX/bin" ]; then
echo "$R2_PREFIX/bin" >> "$GITHUB_PATH"
fi
# --- BUILD FROM GIT (Windows) ---
- name: Build from git (Windows)
@@ -75,26 +109,28 @@ runs:
shell: powershell
env:
R2V: ${{ steps.resolve.outputs.r2v }}
R2_PREFIX: ${{ inputs.prefix }}
R2_PREFIX: ${{ steps.prefix.outputs.prefix }}
run: |
$ErrorActionPreference = 'Stop'
$cloneArgs = @('clone', '--depth=1')
if ($env:R2V) { $cloneArgs += @('--branch', $env:R2V) }
$buildDir = Join-Path $env:RUNNER_TEMP '_r2build'
& git @cloneArgs 'https://github.com/radareorg/radare2.git' $buildDir
Set-Location $buildDir
pip install meson ninja
$prefix = $env:R2_PREFIX
if (-not $prefix -or $prefix -eq '/usr') {
$prefix = Join-Path $env:RUNNER_TEMP 'radare2'
$buildDir = Join-Path $env:RUNNER_TEMP ([System.IO.Path]::GetRandomFileName())
try {
& git @cloneArgs 'https://github.com/radareorg/radare2.git' $buildDir
Set-Location $buildDir
pip install meson ninja
$prefix = $env:R2_PREFIX
meson setup --buildtype=release --prefix="$prefix" build
ninja -C build
ninja -C build install
$resolvedBin = (Resolve-Path "$prefix\bin").Path
$resolvedBin | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
} finally {
Set-Location $env:RUNNER_TEMP
if (Test-Path $buildDir) {
Remove-Item -Path $buildDir -Recurse -Force
}
}
meson setup --buildtype=release --prefix="$prefix" build
ninja -C build
ninja -C build install
$resolvedBin = (Resolve-Path "$prefix\bin").Path
$resolvedBin | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
Set-Location $env:RUNNER_TEMP
Remove-Item -Path $buildDir -Recurse -Force
# --- INSTALL FROM RELEASE (Linux) ---
- name: Install from release (Linux)
@@ -103,15 +139,11 @@ runs:
env:
R2V: ${{ steps.resolve.outputs.r2v }}
run: |
set -e
ARCH=$(dpkg --print-architecture 2>/dev/null || echo amd64)
BASE="https://github.com/radareorg/radare2/releases/download/${R2V}"
cd /tmp
wget -q "${BASE}/radare2_${R2V}_${ARCH}.deb"
wget -q "${BASE}/radare2-dev_${R2V}_${ARCH}.deb"
sudo dpkg -i "radare2_${R2V}_${ARCH}.deb"
sudo dpkg -i "radare2-dev_${R2V}_${ARCH}.deb"
rm -f radare2*.deb
cd "$RUNNER_TEMP"
curl -fsSL --retry 3 -O "${BASE}/radare2_${R2V}_${ARCH}.deb" -O "${BASE}/radare2-dev_${R2V}_${ARCH}.deb"
sudo dpkg -i "radare2_${R2V}_${ARCH}.deb" "radare2-dev_${R2V}_${ARCH}.deb"
# --- INSTALL FROM RELEASE (macOS) ---
- name: Install from release (macOS)
@@ -120,17 +152,14 @@ runs:
env:
R2V: ${{ steps.resolve.outputs.r2v }}
run: |
set -e
ARCH=$(uname -m)
case "$ARCH" in
arm64|aarch64) PKG_ARCH="arm64" ;;
case "$(uname -m)" in
arm64) PKG_ARCH="arm64" ;;
*) PKG_ARCH="x64" ;;
esac
BASE="https://github.com/radareorg/radare2/releases/download/${R2V}"
cd /tmp
curl -fSL "${BASE}/radare2-${PKG_ARCH}-${R2V}.pkg" -o r2.pkg
cd "$RUNNER_TEMP"
curl -fsSL --retry 3 "${BASE}/radare2-${PKG_ARCH}-${R2V}.pkg" -o r2.pkg
sudo installer -pkg r2.pkg -target /
rm -f r2.pkg
# --- INSTALL FROM RELEASE (Windows) ---
- name: Install from release (Windows)
@@ -138,7 +167,7 @@ runs:
shell: powershell
env:
R2V: ${{ steps.resolve.outputs.r2v }}
R2_PREFIX: ${{ inputs.prefix }}
R2_PREFIX: ${{ steps.prefix.outputs.prefix }}
run: |
$ErrorActionPreference = 'Stop'
$R2V = $env:R2V
@@ -152,35 +181,21 @@ runs:
$dest = Join-Path $env:RUNNER_TEMP 'radare2.zip'
Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing
$prefix = $env:R2_PREFIX
if (-not $prefix -or $prefix -eq '/usr') {
$prefix = Join-Path $env:RUNNER_TEMP 'radare2'
}
if (Test-Path $prefix) { Remove-Item -Path $prefix -Recurse -Force }
Expand-Archive -Path $dest -DestinationPath $prefix -Force
# Flatten nested subdirectory if present
# Flatten the zip's single top-level directory unless bin/ is already at the root
$subdirs = Get-ChildItem -Path $prefix -Directory
if ($subdirs.Count -eq 1) {
$subdir = $subdirs[0]
Get-ChildItem -Path $subdir.FullName | Move-Item -Destination $prefix -Force
Remove-Item -Path $subdir.FullName -Recurse -Force
if ($subdirs.Count -eq 1 -and -not (Test-Path "$prefix\bin")) {
Get-ChildItem -Path $subdirs[0].FullName | Move-Item -Destination $prefix -Force
Remove-Item -Path $subdirs[0].FullName -Recurse -Force
}
$resolvedBin = (Resolve-Path "$prefix\bin").Path
$resolvedBin | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
# --- EXPORT PREFIX ---
- name: Export prefix
id: prefix
shell: bash
env:
R2_PREFIX: ${{ inputs.prefix }}
run: |
PREFIX="$R2_PREFIX"
if [ "$RUNNER_OS" = "Windows" ] && [ "$PREFIX" = "/usr" ]; then
PREFIX="$RUNNER_TEMP/radare2"
fi
echo "prefix=$PREFIX" >> "$GITHUB_OUTPUT"
# --- VERIFY ---
- name: Verify installation
id: verify
shell: bash
run: radare2 -v
run: |
radare2 -v
echo "version=$(radare2 -qv)" >> "$GITHUB_OUTPUT"