-
Notifications
You must be signed in to change notification settings - Fork 0
/
mv-files.sh
executable file
·45 lines (36 loc) · 1.1 KB
/
mv-files.sh
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
#!/bin/bash
# 定义字典
declare -A mappings=(
["linux-386-musl"]="linux/386"
["linux-amd64-musl"]="linux/amd64"
["linux-armv6-musleabi"]="linux/arm/v6"
["linux-armv7l-musleabihf"]="linux/arm/v7"
["linux-arm64-musl"]="linux/arm64"
["linux-ppc64le-musl"]="linux/ppc64le"
["linux-riscv64-musl"]="linux/riscv64"
["linux-s390x-musl"]="linux/s390x"
)
repo=$(basename "$REPOSITORY")
string=$OUTPUT
output="${string//\$repo/$repo}"
echo "output filename: $output"
echo "output=$output" >>"$GITHUB_OUTPUT"
# Traverse the bin directory
for file in temp-bin/temp*; do
# Get filename
filename=$(basename "$file")
# Get key from filename
key="${filename#temp-}"
echo "handling $file, filename: $filename ,key: $key"
# if the key exists in the mappings
if [ -n "${mappings[$key]}" ]; then
target_dir="bin/${mappings[$key]}"
# if the target directory does not exist, create it
if [ ! -d "$target_dir" ]; then
mkdir -p "$target_dir"
fi
echo "Moving $file to $target_dir/${output}"
# Move the file to the target directory
mv "$file" "$target_dir/${output}"
fi
done