Skip to content

Build and Release

Build and Release #57

Workflow file for this run

name: Build and Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release tag name (default use mpv version)'
default: ''
jobs:
build:
permissions:
contents: write
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Check version to release
uses: jannekem/run-python-script-action@v1
with:
script: |
import re
def normalize_version(version_string):
version_string = re.sub(r'[^.0-9]+|-.+', '', version_string)
parts = re.split(r'\.', version_string)
major = int(parts[0])
minor = int(parts[1]) if len(parts) > 1 else 0
patch = int(parts[2]) if len(parts) > 2 else 0
return f"{major}.{minor}.{patch}"
file_path = './Sources/BuildScripts/XCFrameworkBuild/main.swift'
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
mpvVersion = re.search(r'(case .libmpv[^"]+?)"(.+?)"', content).group(2)
ffmpegVersion = re.search(r'(case .FFmpeg[^"]+?)"(.+?)"', content).group(2)
libplaceboVersion = re.search(r'(case .libplacebo[^"]+?)"(.+?)"', content).group(2)
vulkanVersion = re.search(r'(case .vulkan[^"]+?)"(.+?)"', content).group(2)
print(f'mpv version: {mpvVersion}')
print(f'ffmpeg version: {ffmpegVersion}')
releaseVersion = '${{ github.event.inputs.version }}' or normalize_version(mpvVersion)
print(f'release version: {releaseVersion}')
set_env('MPV_VERSION', mpvVersion)
set_env('RELEASE_VERSION', releaseVersion)
with open('/tmp/RELEASE_NOTE.txt', 'w', encoding='utf-8') as file:
file.write(f'''
* mpv version: {mpvVersion}
* ffmpeg version: {ffmpegVersion}
* placebo version: v{libplaceboVersion}
* MoltenVK version: v{vulkanVersion}
''')
- name: Install dependencies
run: |
brew install autoconf
brew install automake
brew install libtool
python -m pip install meson==1.4.2
brew install ninja
brew install rename
- name: Setup Xcode to support visionOS
run: |
sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
xcodebuild -showsdks
- name: Build GPL version
run: |
make build enable-gpl version=${{ env.RELEASE_VERSION }} platform=xros
cd ./dist/release
rename 's/-all\.zip/-GPL-all\.zip/' *-all.zip
rename 's/\.xcframework\.zip/-GPL\.xcframework\.zip/' *.xcframework.zip
rename 's/\.xcframework\.checksum\.txt/-GPL\.xcframework\.checksum\.txt/' *.xcframework.checksum.txt
- name: Clean GPL build files
run: |
# remove libbluray, same as LGPL version
rm -rf ./dist/release/libbluray*.zip
rm -rf ./dist/release/Libbluray*.zip
rm -rf ./dist/release/Libbluray*.txt
rm -rf ./dist/FFmpeg*
rm -rf ./dist/release/FFmpeg
rm -rf ./dist/libmpv*
rm -rf ./dist/release/libmpv
rm -rf ./dist/release/xcframework
- name: Build LGPL version
run: |
make build version=${{ env.RELEASE_VERSION }}
- name: Update Package.swift
run: |
rm -rf ./Package.swift
cp -f ./dist/release/Package.swift ./Package.swift
LibmpvGPL_url="https://github.com/mpvkit/MPVKit/releases/download/${{ env.RELEASE_VERSION }}/Libmpv-GPL.xcframework.zip"
LibmpvGPL_checksum=$(cat ./dist/release/Libmpv-GPL.xcframework.checksum.txt)
sed -i '' "s#\\\(Libmpv-GPL_url)#${LibmpvGPL_url}#g" ./Package.swift
sed -i '' "s#\\\(Libmpv-GPL_checksum)#${LibmpvGPL_checksum}#g" ./Package.swift
LibavcodecGPL_url="https://github.com/mpvkit/MPVKit/releases/download/${{ env.RELEASE_VERSION }}/Libavcodec-GPL.xcframework.zip"
LibavcodecGPL_checksum=$(cat ./dist/release/Libavcodec-GPL.xcframework.checksum.txt)
sed -i '' "s#\\\(Libavcodec-GPL_url)#${LibavcodecGPL_url}#g" ./Package.swift
sed -i '' "s#\\\(Libavcodec-GPL_checksum)#${LibavcodecGPL_checksum}#g" ./Package.swift
LibavformatGPL_url="https://github.com/mpvkit/MPVKit/releases/download/${{ env.RELEASE_VERSION }}/Libavformat-GPL.xcframework.zip"
LibavformatGPL_checksum=$(cat ./dist/release/Libavformat-GPL.xcframework.checksum.txt)
sed -i '' "s#\\\(Libavformat-GPL_url)#${LibavformatGPL_url}#g" ./Package.swift
sed -i '' "s#\\\(Libavformat-GPL_checksum)#${LibavformatGPL_checksum}#g" ./Package.swift
LibavfilterGPL_url="https://github.com/mpvkit/MPVKit/releases/download/${{ env.RELEASE_VERSION }}/Libavfilter-GPL.xcframework.zip"
LibavfilterGPL_checksum=$(cat ./dist/release/Libavfilter-GPL.xcframework.checksum.txt)
sed -i '' "s#\\\(Libavfilter-GPL_url)#${LibavfilterGPL_url}#g" ./Package.swift
sed -i '' "s#\\\(Libavfilter-GPL_checksum)#${LibavfilterGPL_checksum}#g" ./Package.swift
LibavutilGPL_url="https://github.com/mpvkit/MPVKit/releases/download/${{ env.RELEASE_VERSION }}/Libavutil-GPL.xcframework.zip"
LibavutilGPL_checksum=$(cat ./dist/release/Libavutil-GPL.xcframework.checksum.txt)
sed -i '' "s#\\\(Libavutil-GPL_url)#${LibavutilGPL_url}#g" ./Package.swift
sed -i '' "s#\\\(Libavutil-GPL_checksum)#${LibavutilGPL_checksum}#g" ./Package.swift
LibswresampleGPL_url="https://github.com/mpvkit/MPVKit/releases/download/${{ env.RELEASE_VERSION }}/Libswresample-GPL.xcframework.zip"
LibswresampleGPL_checksum=$(cat ./dist/release/Libswresample-GPL.xcframework.checksum.txt)
sed -i '' "s#\\\(Libswresample-GPL_url)#${LibswresampleGPL_url}#g" ./Package.swift
sed -i '' "s#\\\(Libswresample-GPL_checksum)#${LibswresampleGPL_checksum}#g" ./Package.swift
LibswscaleGPL_url="https://github.com/mpvkit/MPVKit/releases/download/${{ env.RELEASE_VERSION }}/Libswscale-GPL.xcframework.zip"
LibswscaleGPL_checksum=$(cat ./dist/release/Libswscale-GPL.xcframework.checksum.txt)
sed -i '' "s#\\\(Libswscale-GPL_url)#${LibswscaleGPL_url}#g" ./Package.swift
sed -i '' "s#\\\(Libswscale-GPL_checksum)#${LibswscaleGPL_checksum}#g" ./Package.swift
- name: Push Package.swift
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
add: |
- Package.swift
message: "chore: bump version to ${{ env.RELEASE_VERSION }}"
push: "origin HEAD:${{ github.ref_name }}"
- name: Upload binary to GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.MPV_VERSION }}
tag_name: ${{ env.RELEASE_VERSION }}
files: |
./dist/release/*.txt
./dist/release/*.zip
prerelease: ${{ contains(github.event.inputs.version, 'alpha') || contains(github.event.inputs.version, 'beta') }}
body_path: /tmp/RELEASE_NOTE.txt
generate_release_notes: true
fail_on_unmatched_files: true