Skip to content

mpv

mpv #851

Workflow file for this run

name: mpv
defaults:
run:
shell: bash
on:
workflow_dispatch:
inputs:
command:
description: 'Run custom command before building'
required: false
type: string
sourceforge:
description: 'Upload to Sourceforge'
required: false
default: true
type: boolean
github_release:
description: 'Upload to Github release'
required: false
default: true
type: boolean
mpv_tarball:
description: 'Build latest mpv tarball'
required: false
default: false
type: boolean
jobs:
build_mpv:
name: Building mpv
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
bit: [32, 64, 64-v3]
env:
BIT: ${{ matrix.bit }}
container:
image: docker://ghcr.io/shinchiro/archlinux:latest
outputs:
mpv_ver: ${{ steps.build_mpv_step.outputs.mpv_ver }}
steps:
- name: Init variable
run: |
if [[ $BIT == 32 ]]; then
echo "arch=i686" >> $GITHUB_ENV
elif [[ $BIT == 64 ]]; then
echo "arch=x86_64" >> $GITHUB_ENV
elif [[ $BIT == 64-v3 ]]; then
echo "arch=x86_64" >> $GITHUB_ENV
echo "gcc_arch=-DGCC_ARCH=x86-64-v3" >> $GITHUB_ENV
echo "x86_64_level=-v3" >> $GITHUB_ENV
fi
- name: Setup git config
run: |
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global pull.rebase true
git config --global rebase.autoStash true
git config --global fetch.prune true
git config --global --add safe.directory $PWD
- uses: actions/checkout@main
with:
ref: master
- name: Loading build${{ matrix.bit }} cache
uses: actions/cache/restore@main
with:
path: build${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-build${{ matrix.bit }}-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-build${{ matrix.bit }}
- name: Loading repository cache
uses: actions/cache/restore@main
with:
path: src_packages
key: ${{ secrets.CACHE_VERSION }}-repository-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-repository
- name: Loading rust toolchain cache
uses: actions/cache/restore@main
with:
path: install_rustup
key: ${{ secrets.CACHE_VERSION }}-rust_toolchain-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-rust_toolchain
- name: Running custom command
if: ${{ github.event.inputs.command != '' }}
continue-on-error: true
run: ${{ github.event.inputs.command }}
- name: Downloading source
run: |
cmake -DTARGET_ARCH=${{ env.arch }}-w64-mingw32 ${{ env.gcc_arch }} -DALWAYS_REMOVE_BUILDFILES=ON -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/install_rustup -G Ninja -Bbuild$BIT -H.
ninja -C build$BIT download || true
- name: Building toolchain
run: |
if [[ ! "$(ls -A build$BIT/install/bin)" ]]; then ninja -C build$BIT gcc; fi
- name: Building mpv
id: build_mpv_step
env:
MPV_TARBALL: ${{ github.event.inputs.mpv_tarball }}
run: |
ninja -C build$BIT update
$MPV_TARBALL && ninja -C build$BIT mpv-release || ninja -C build$BIT mpv
$MPV_TARBALL && echo "mpv_ver=$(cat build$BIT/packages/mpv-release-prefix/VERSION)" >> $GITHUB_OUTPUT || echo "mpv_ver=UNKNOWN" >> $GITHUB_OUTPUT
- name: Packaging mpv
run: |
mkdir -p release$BIT
rm -rf build$BIT/mpv-debug*; ninja -C build$BIT mpv-packaging; mv build$BIT/mpv*.7z release$BIT
- name: Copying ffmpeg
run: |
hash=$(git -C src_packages/ffmpeg rev-parse --short HEAD)
7z a -m0=lzma2 -mx=9 -ms=on release$BIT/ffmpeg-${{ env.arch }}${{ env.x86_64_level }}-git-$hash.7z ./build$BIT/install/mingw/bin/ffmpeg.exe
- name: Collecting logs
if: always()
run: |
mkdir -p build${BIT}_logs
cp -fr $(find build$BIT -type f -iname "*-*.log" -or -wholename "*/ffbuild/config.log") build${BIT}_logs || true
7z a -m0=lzma2 -mx=9 -ms=on logs.7z build*logs
- name: Uploading logs
uses: actions/upload-artifact@master
if: always()
with:
name: logs_${{ matrix.bit }}
path: logs.7z
retention-days: 1
- name: Cleaning build directory
if: always()
run: |
rm -rf build$BIT/mpv*
- name: Cleaning rust toolchain directory
if: always()
run: |
ninja -C build$BIT cargo-clean
- name: Saving build${{ matrix.bit }} cache
uses: actions/cache/save@main
if: always()
with:
path: build${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-build${{ matrix.bit }}-${{ github.run_id }}
- name: Saving repository cache
uses: actions/cache/save@main
if: ${{ always() && matrix.bit == '32' }}
with:
path: src_packages
key: ${{ secrets.CACHE_VERSION }}-repository-${{ github.run_id }}
- name: Saving rust toolchain cache
uses: actions/cache/save@main
if: ${{ always() && matrix.bit == '64' }}
with:
path: install_rustup
key: ${{ secrets.CACHE_VERSION }}-rust_toolchain-${{ github.run_id }}
- name: Saving release${{ matrix.bit }} cache
uses: actions/cache/save@main
with:
path: release${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-release${{ matrix.bit }}-${{ github.run_id }}
release:
name: Upload releases
runs-on: ubuntu-latest
needs: build_mpv
env:
GH_TOKEN: ${{ github.token }}
CURL_RETRIES: "--connect-timeout 60 --retry 999 --retry-delay 5 --retry-all-errors"
release32_key: ${{ secrets.CACHE_VERSION }}-release32-${{ github.run_id }}
release64_key: ${{ secrets.CACHE_VERSION }}-release64-${{ github.run_id }}
release64_v3_key: ${{ secrets.CACHE_VERSION }}-release64-v3-${{ github.run_id }}
container:
image: docker://alpine:latest
steps:
- name: Installing dependencies
shell: sh
run: |
apk add --update --no-cache bash git file openssh curl tar zstd jq
git config --global pull.rebase true
git config --global fetch.prune true
git config --global --add safe.directory $PWD
- uses: actions/checkout@main
with:
ref: master
- name: Loading release32 cache
uses: actions/cache/restore@main
with:
path: release32
key: ${{ env.release32_key }}
- name: Loading release64 cache
uses: actions/cache/restore@main
with:
path: release64
key: ${{ env.release64_key }}
- name: Loading release64-v3 cache
uses: actions/cache/restore@main
with:
path: release64-v3
key: ${{ env.release64_v3_key }}
- name: Moving archives
run: |
mkdir -p release
mv release32/* release64/* release64-v3/* release
du -ah release/*
- name: Uploading packages to Sourceforge
id: upload_packages_sf
if: ${{ github.event.inputs.sourceforge == 'true' }}
continue-on-error: true
env:
MPV_VER: ${{ needs.build_mpv.outputs.mpv_ver }}
run: |
mkdir -p /root/.ssh/
echo "${{ secrets.SF_PRIVATE_KEY }}" > sf_key
pubkey=$(cat <<END
frs.sourceforge.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQD35Ujalhh+JJkPvMckDlhu4dS7WH6NsOJ15iGCJLC
END
)
echo $pubkey > /root/.ssh/known_hosts
chmod 400 sf_key
chmod -R 700 /root
sftp -i sf_key [email protected]:/home/frs/project/mpv-player-windows <<END
put release/mpv-dev* libmpv
put release/mpv-i686* 32bit
put release/mpv-x86_64-[!v3]* 64bit
put release/mpv-x86_64-v3* 64bit-v3
put release/mpv-$MPV_VER* release
END
- name: Uploading packages to Github release
id: upload_packages_gh
if: ${{ github.event.inputs.github_release == 'true' && github.event.inputs.mpv_tarball == 'false' }}
continue-on-error: true
run: |
short_date=$(date "+%Y%m%d")
body=$(cat <<END
![GitHub release (by tag)](https://img.shields.io/github/downloads/shinchiro/mpv-winbuild-cmake/$short_date/total?label=Downloads)
END
)
id=$(curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases -d @- <<END | jq -r '.id'
{
"tag_name": "$short_date",
"name": "$short_date",
"body": "$(echo ${body//$'\n'/'\n'})"
}
END
)
for file in release/*.7z; do curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -X POST -H "Accept: application/vnd.github.v3+json" -H "Content-Type: $(file -b --mime-type $file)" https://uploads.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/$id/assets?name=$(basename $file) --data-binary @$file; done
- name: Pruning tags
continue-on-error: true
run: |
# Keep latest 30 tags/releases
git fetch --tags
tag_list=($(git tag | sort -r))
old=${tag_list[@]:30}
for tag in ${old[@]}; do
id=$(curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -X GET -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/tags/$tag | jq -r '.id')
curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/$id
git tag -d $tag
done
git push --tags --prune https://shinchiro:[email protected]/shinchiro/mpv-winbuild-cmake
- name: Delete releases cache
if: ${{ github.event.inputs.github_release == 'false' || steps.upload_packages_gh.outcome == 'success' }}
run: |
curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -o /dev/null -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/caches?key=$release32_key
curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -o /dev/null -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/caches?key=$release64_key
curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -o /dev/null -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/caches?key=$release64_v3_key
gist:
name: Gist
runs-on: ubuntu-latest
needs: build_mpv
if: ${{ always() }}
env:
GH_TOKEN: ${{ secrets.GIST_TOKEN }}
RUN_ID: ${{ github.run_id }}
steps:
- name: Setup git credentials
run: |
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Upload job logs to gist
run: |
url=$(curl -su shinchiro:$GH_TOKEN -X GET -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/runs/$RUN_ID/jobs | jq -r '.jobs[0] | .url')
curl -sLu shinchiro:$GH_TOKEN -X GET -H "Accept: application/vnd.github.v3+json" $url/logs -o mpv_log
git clone --depth 1 https://shinchiro:[email protected]/90308c6632c9010d03b325c9ca6a4b6f job_log
cp -f mpv_log job_log/mpv_log
git -C job_log add .
git -C job_log commit --amend --no-edit
git -C job_log push -f https://shinchiro:[email protected]/90308c6632c9010d03b325c9ca6a4b6f