Skip to content

Commit 39e0655

Browse files
committed
Extract binary download logic into shell function
1 parent 965107f commit 39e0655

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

.github/actions/setup-ffmpeg/action.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ runs:
1818
1919
echo "Installing FFmpeg and FFprobe $FF_VERSION on ${{ runner.os }}"
2020
21+
download_binary() {
22+
local url="$1"
23+
local binary_name="${2:-FFmpeg}"
24+
local output_file="$(echo "$binary_name" | tr '[:upper:]' '[:lower:]').zip"
25+
26+
curl -sS -f -L --retry 3 --retry-delay 5 "$url" -o "$output_file" -w "Downloaded $binary_name from %{url_effective}\n"
27+
unzip -q "$output_file"
28+
rm -f "$output_file"
29+
}
30+
2131
if [[ "${{ runner.os }}" == "Linux" ]]; then
2232
docker pull mwader/static-ffmpeg:$FF_VERSION
2333
CID=$(docker create mwader/static-ffmpeg:$FF_VERSION)
@@ -28,26 +38,15 @@ runs:
2838
2939
elif [[ "${{ runner.os }}" == "macOS" ]]; then
3040
FF_VERSION=$(echo "$FF_VERSION" | awk -F. '{print $1 $2}')
31-
curl -sS -f -L --retry 3 --retry-delay 5 \
32-
"https://www.osxexperts.net/ffmpeg${FF_VERSION}arm.zip" \
33-
-o ffmpeg.zip -w "Downloaded FFmpeg from %{url_effective}\n"
34-
unzip -q ffmpeg.zip
41+
download_binary "https://www.osxexperts.net/ffmpeg${FF_VERSION}arm.zip"
3542
mv ffmpeg "$INSTALL_DIR/ffmpeg"
36-
curl -sS -f -L --retry 3 --retry-delay 5 \
37-
"https://www.osxexperts.net/ffprobe${FF_VERSION}arm.zip" \
38-
-o ffprobe.zip -w "Downloaded FFprobe from %{url_effective}"
39-
unzip -q ffprobe.zip
43+
download_binary "https://www.osxexperts.net/ffprobe${FF_VERSION}arm.zip" "FFprobe"
4044
mv ffprobe "$INSTALL_DIR/ffprobe"
4145
chmod +x "$INSTALL_DIR/"*
42-
rm -f ffmpeg.zip ffprobe.zip
4346
4447
elif [[ "${{ runner.os }}" == "Windows" ]]; then
45-
curl -sS -f -L --retry 3 --retry-delay 5 \
46-
"https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-$FF_VERSION-essentials_build.zip" \
47-
-o ffmpeg.zip -w "Downloaded FFmpeg and FFprobe from %{url_effective}"
48-
unzip -q ffmpeg.zip
48+
download_binary "https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-$FF_VERSION-essentials_build.zip"
4949
find . -type f \( -name ffmpeg.exe -o -name ffprobe.exe \) -exec mv {} "$INSTALL_DIR/" \;
50-
rm -f ffmpeg.zip
5150
fi
5251
5352
echo "$INSTALL_DIR" >> "$GITHUB_PATH"

0 commit comments

Comments
 (0)