Skip to content

Commit 15e018d

Browse files
committed
add ffmpeg workflow
1 parent 3733f4c commit 15e018d

File tree

4 files changed

+250
-16
lines changed

4 files changed

+250
-16
lines changed

.github/workflows/ffmpeg.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
on:
2+
# push:
3+
# branches: [master]
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [master]
7+
8+
name: Create ffmpeg Release
9+
10+
jobs:
11+
build:
12+
name: compile github ffmpeg then deploy
13+
runs-on: macos-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
- name: Read Tag Version
18+
run: |
19+
# https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything
20+
# git describe --tags --always | awk -F . '{printf "RELEASE_VERSION=%s.%d",$1,$2+1}' | xargs > constants.env
21+
# git describe --tags --always | awk -F - '{printf "RELEASE_VERSION=V1.0-%s",$NF}' | xargs > constants.env
22+
d=$(TZ=UTC-8 date +'%y%m%d%H%M%S')
23+
grep GIT_FFMPEG_VERSION= ./init-cfgs/ffmpeg | awk -F = '{printf "RELEASE_VERSION=%s",$2}' | xargs > constants.env
24+
echo "RELEASE_DATE=$d" >> constants.env
25+
cat constants.env
26+
- name: Export Env
27+
uses: cardinalby/export-env-action@v2
28+
with:
29+
envFile: 'constants.env'
30+
- run: |
31+
export SKIP_FFMPEG_PATHCHES=1
32+
./init-any.sh all ffmpeg
33+
./install-pre-any.sh all 'libyuv openssl opus bluray dav1d'
34+
- name: generate src log
35+
run: |
36+
cd build/src/macos
37+
ls | awk -F ' ' '{printf "echo %s\n echo -------------\ngit -C %s log -n 1 | cat\n",$0,$0}' | bash > ../macos-src-log.md
38+
cd ../ios
39+
ls | awk -F ' ' '{printf "echo %s\n echo -------------\ngit -C %s log -n 1 | cat\n",$0,$0}' | bash > ../ios-src-log.md
40+
- name: do compile macos platform
41+
run: |
42+
./macos/compile-any.sh build ffmpeg
43+
./macos/compile-any.sh lipo ffmpeg
44+
- name: do compile ios platform
45+
run: |
46+
./ios/compile-any.sh build ffmpeg
47+
./ios/compile-any.sh lipo ffmpeg
48+
- name: Zip macos ffmpeg
49+
run: |
50+
cd build/product/macos/universal
51+
zip -rq macos-universal.zip ./ffmpeg/*
52+
- name: Zip ios ffmpeg
53+
run: |
54+
cd build/product/ios/universal
55+
zip -rq ios-universal.zip ./ffmpeg/*
56+
- name: Create Release
57+
id: create_release
58+
uses: actions/create-release@v1
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
with:
62+
tag_name: ffmpeg-${{ env.RELEASE_VERSION }}-${{ env.RELEASE_DATE }}
63+
release_name: ffmpeg-${{ env.RELEASE_VERSION }}
64+
draft: false
65+
prerelease: false
66+
- name: Upload macos Release Asset
67+
uses: actions/upload-release-asset@v1
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
72+
asset_path: build/product/macos/universal/macos-universal.zip
73+
asset_name: "ffmpeg-macos-universal-${{ env.RELEASE_VERSION }}.zip"
74+
asset_content_type: application/zip
75+
- name: Upload ios Release Asset
76+
uses: actions/upload-release-asset@v1
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
with:
80+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
81+
asset_path: build/product/ios/universal/ios-universal.zip
82+
asset_name: "ffmpeg-ios-universal-${{ env.RELEASE_VERSION }}.zip"
83+
asset_content_type: application/zip
84+
- name: Upload macos src md
85+
uses: actions/upload-release-asset@v1
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
with:
89+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
90+
asset_path: build/src/macos-src-log.md
91+
asset_name: "macos-src-log-${{ env.RELEASE_VERSION }}.md"
92+
asset_content_type: application/text
93+
- name: Upload ios src md
94+
uses: actions/upload-release-asset@v1
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
with:
98+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
99+
asset_path: build/src/ios-src-log.md
100+
asset_name: "ios-src-log-${{ env.RELEASE_VERSION }}.md"
101+
asset_content_type: application/text

init-cfgs/ffmpeg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ fi
3030

3131
export GIT_LOCAL_REPO=build/extra/ffmpeg
3232
export REPO_DIR=ffmpeg
33+
export GIT_FFMPEG_VERSION=5.1

install-pre-any.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Copyright (C) 2022 Matt Reach<qianlongxu@gmail.com>
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# ./install-pre-any.sh all
18+
# ./install-pre-any.sh ios 'libyuv openssl opus bluray dav1d'
19+
# ./install-pre-any.sh macos 'openssl'
20+
# ./install-pre-any.sh macos 'openssl ffmpeg'
21+
22+
23+
#----------------------------------------------------------
24+
# 当发布新版本库时,修改对应的 TAG 值
25+
#----------------------------------------------------------
26+
LIBYUV_TAG='libyuv-main-231127113441'
27+
OPUS_TAG='opus-1.3.1-231127113458'
28+
MAC_BLURAY_TAG='bluray-1.3.1-231127113451'
29+
DAV1D_TAG='dav1d-1.2.0-231127113745'
30+
OPENSSL_TAG='openssl-1.1.1u-231127113504'
31+
FFMPEG_TAG=
32+
#----------------------------------------------------------
33+
34+
set -e
35+
36+
PLAT=$1
37+
LIBS=$2
38+
39+
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
40+
cd "$THIS_DIR"
41+
42+
function install_lib ()
43+
{
44+
local plat=$1
45+
46+
if [[ "$plat" == 'ios' || "$plat" == 'macos' ]]; then
47+
./tools/install-pre-lib.sh "$plat" "$TAG"
48+
else
49+
./tools/install-pre-lib.sh 'ios' "$TAG"
50+
./tools/install-pre-lib.sh 'macos' "$TAG"
51+
fi
52+
}
53+
54+
function usage() {
55+
echo "=== useage ===================="
56+
echo "Download pre-compiled libs from github:"
57+
echo " $0 [ios,macos,all] [all|ffmpeg|libyuv|openssl|opus|bluray|dav1d]"
58+
exit
59+
}
60+
61+
if [[ -z "$LIBS" || "$LIBS" == "all" ]]; then
62+
LIBS=$(ls init-cfgs)
63+
fi
64+
65+
if [[ "$PLAT" == 'ios' || "$PLAT" == 'macos' || "$PLAT" == 'all' ]]; then
66+
for lib in $LIBS
67+
do
68+
plat=$PLAT
69+
TAG=
70+
if [[ $lib == 'bluray' ]];then
71+
if [[ $plat == 'macos' || $plat == 'all' ]];then
72+
plat='macos'
73+
else
74+
echo "===[bluray] not support iOS platform, just skip it.===================="
75+
continue
76+
fi
77+
fi
78+
79+
echo "===[install pre-compile $lib]===================="
80+
81+
case $lib in
82+
'ffmpeg')
83+
TAG=$FFMPEG_TAG
84+
;;
85+
'libyuv')
86+
TAG=$LIBYUV_TAG
87+
;;
88+
'openssl')
89+
TAG=$OPENSSL_TAG
90+
;;
91+
'opus')
92+
TAG=$OPUS_TAG
93+
;;
94+
'bluray')
95+
TAG=$MAC_BLURAY_TAG
96+
;;
97+
'dav1d')
98+
TAG=$DAV1D_TAG
99+
;;
100+
*)
101+
echo "wrong lib name:$lib"
102+
usage
103+
;;
104+
esac
105+
106+
if [[ -z "$TAG" ]]; then
107+
echo "== $lib tag is empty,just skip it."
108+
else
109+
echo "== $plat $lib -> $TAG"
110+
install_lib $plat
111+
fi
112+
echo "===================================="
113+
done
114+
else
115+
usage
116+
fi

download-pre.sh renamed to tools/install-pre-lib.sh

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,57 +18,73 @@
1818
set -e
1919

2020
PLAT=$1
21-
VER=$2
22-
23-
if test -z $PLAT ;then
24-
PLAT='all'
25-
fi
21+
TAG=$2
2622

2723
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
2824
cd "$THIS_DIR"
25+
cd ../
2926

3027
function usage() {
3128
echo "=== useage ===================="
3229
echo "Download precompiled libs from github,The usage is as follows:"
3330
echo "$0 [ios|macos|all] [<release tag>]"
3431
}
3532

33+
function fix_prefix(){
34+
local plat=$1
35+
local UNI_PC_DIR="build/product/$plat/universal/$LIB_NAME/lib/pkgconfig"
36+
if ls ${UNI_PC_DIR}/*.pc >/dev/null 2>&1;then
37+
echo "fix $plat $LIB_NAME pc file prefix"
38+
p=$(cd "build/product/$plat/universal/$LIB_NAME";pwd)
39+
escaped_p=$(echo $p | sed 's/\//\\\//g')
40+
sed -i "" "s/^prefix=.*/prefix=$escaped_p/" "$UNI_PC_DIR/"*.pc
41+
fi
42+
}
43+
3644
function download() {
3745
local plat=$1
38-
echo "===[download $plat $VER]===================="
39-
mkdir -p build/pre
40-
cd build/pre
41-
local fname="$plat-universal-$VER.zip"
42-
local url="https://github.com/debugly/MRFFToolChainBuildShell/releases/download/$VER/$fname"
46+
local fname="$LIB_NAME-$plat-universal-$VER.zip"
47+
local url="https://github.com/debugly/MRFFToolChainBuildShell/releases/download/$TAG/$fname"
48+
echo "---[download $fname]-----------------"
4349
echo "$url"
50+
mkdir -p build/pre && cd build/pre
4451
curl -LO "$url"
4552
mkdir -p ../product/$plat/universal
4653
unzip -oq $fname -d ../product/$plat/universal
4754
if command -v tree >/dev/null 2>&1; then
4855
tree -L 2 ../product/$plat/universal
4956
fi
50-
echo "===================================="
57+
echo ""
5158
cd - >/dev/null
5259
}
5360

61+
function install(){
62+
download "$*"
63+
fix_prefix "$*"
64+
}
65+
5466
if [[ "$PLAT" != 'ios' && "$PLAT" != 'macos' && "$PLAT" != 'all' ]]; then
55-
echo 'wrong plat,use ios or macos or all!'
67+
echo 'plat must use ios or macos'
5668
usage
5769
exit
5870
fi
5971

60-
if test -z $VER ;then
61-
#VER=$(git describe --abbrev=0 --tag | awk -F - '{printf "%s-%s",$1,$2}')
72+
if test -z $TAG ;then
73+
echo "tag can't be nil"
6274
usage
6375
exit
6476
fi
6577

78+
# opus-1.3.1-231124151836
79+
LIB_NAME=$(echo $TAG | awk -F - '{print $1}')
80+
VER=$(echo $TAG | awk -F - '{print $2}')
81+
6682
if [[ "$PLAT" == 'ios' || "$PLAT" == 'macos' ]]; then
67-
download $PLAT
83+
install $PLAT
6884
elif [[ "$PLAT" == 'all' ]]; then
6985
plats="ios macos"
7086
for plat in $plats; do
71-
download $plat
87+
install $plat
7288
done
7389
else
7490
usage

0 commit comments

Comments
 (0)