Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
81 lines (68 loc) · 2.51 KB
/
Copy pathaction.yml
File metadata and controls
81 lines (68 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Setup Fast Down
description: Install fast-down CLI, rename to fd, and add to PATH
author: share121
branding:
icon: download
color: blue
inputs:
version:
description: 'Version to install (e.g., "latest", "v2.7.8")'
required: false
default: "latest"
runs:
using: "composite"
steps:
- name: Detect Platform and Install
shell: bash
run: |
TARGET_OS=""
case "${{ runner.os }}" in
"Linux") TARGET_OS="linux" ;;
"macOS") TARGET_OS="macos" ;;
"Windows") TARGET_OS="windows" ;;
esac
TARGET_ARCH=""
case "${{ runner.arch }}" in
"X64") TARGET_ARCH="x86_64" ;;
"ARM64") TARGET_ARCH="aarch64" ;;
"X86") TARGET_ARCH="i686" ;;
esac
# 检查不支持的组合 (macOS i686)
if [[ "$TARGET_OS" == "macos" && "$TARGET_ARCH" == "i686" ]]; then
echo "::error::macOS i686 is not supported by fast-down."
exit 1
fi
if [[ -z "$TARGET_OS" || -z "$TARGET_ARCH" ]]; then
echo "::error::Unsupported platform: ${{ runner.os }} ${{ runner.arch }}"
exit 1
fi
REPO="fast-down/cli"
if [[ "${{ inputs.version }}" == "latest" ]]; then
DOWNLOAD_URL="https://github.com/$REPO/releases/latest/download/fd-$TARGET_OS-$TARGET_ARCH"
else
DOWNLOAD_URL="https://github.com/$REPO/releases/download/${{ inputs.version }}/fd-$TARGET_OS-$TARGET_ARCH"
fi
if [[ "$TARGET_OS" == "windows" ]]; then
DOWNLOAD_URL="${DOWNLOAD_URL}.exe"
fi
echo "🚀 Installing fast-down for $TARGET_OS ($TARGET_ARCH)..."
echo "🔗 Downloading from: $DOWNLOAD_URL"
# 安装到用户目录下的 .fast-down/bin
INSTALL_DIR="$HOME/.fast-down/bin"
mkdir -p "$INSTALL_DIR"
BIN_NAME="fd"
if [[ "$TARGET_OS" == "windows" ]]; then
BIN_NAME="fd.exe"
fi
curl -L --fail "$DOWNLOAD_URL" -o "$INSTALL_DIR/$BIN_NAME"
if [[ "$TARGET_OS" != "windows" ]]; then
chmod +x "$INSTALL_DIR/$BIN_NAME"
fi
if [[ "$TARGET_OS" == "windows" ]]; then
# 使用 cygpath -w 将 /c/Users/... 转为 C:\Users\... 这样 PowerShell 才能识别
echo "$(cygpath -w "$INSTALL_DIR")" >> $GITHUB_PATH
else
echo "$INSTALL_DIR" >> $GITHUB_PATH
fi
echo "✅ fast-down installed successfully as '$BIN_NAME'!"
echo "👉 You can now use 'fd' command in subsequent steps."