Skip to content

Check new version

Check new version #140

Workflow file for this run

name: Check new version
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1'
jobs:
check:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout ffmpeg
uses: actions/checkout@v4
with:
repository: "FFmpeg/FFmpeg"
path: 'ffmpeg'
fetch-depth: 0
- name: Checkout mpv
uses: actions/checkout@v4
with:
repository: "mpv-player/mpv"
path: 'mpv'
fetch-depth: 0
- name: Get latest verion
id: version
run: |
cd ./ffmpeg
latest_tag=$(git tag | grep n | grep -v "-" | sort -r | head -n 1)
echo "ffmpeg latest tag: $latest_tag"
echo "FFMPEG_LATEST_VERSION=$latest_tag" >> $GITHUB_ENV
cd ..
cd ./mpv
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "mpv latest tag: $latest_tag"
echo "MPV_LATEST_VERSION=$latest_tag" >> $GITHUB_ENV
cd ..
rm -rf ./ffmpeg
rm -rf ./mpv
- name: update to new version
uses: jannekem/run-python-script-action@v1
with:
script: |
import re
def parse_version(ver):
if '-' in ver or ver == '':
return 0
version_string = re.sub(r'[^.0-9]+', r'', ver)
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 int(f"{major}{minor}{patch}")
file_path = './Sources/BuildScripts/XCFrameworkBuild/main.swift'
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
mpvOldVersion = re.search(r'(case .libmpv[^"]+?)"(.+?)"', content).group(2)
print("mpv old version:", mpvOldVersion)
set_env('MPV_OLD_VERSION', mpvOldVersion)
mpvNewVersion = '${{ env.MPV_LATEST_VERSION }}'
if parse_version(mpvNewVersion) > parse_version(mpvOldVersion) and not mpvOldVersion.startswith(mpvNewVersion):
content = re.sub(r'(case .libmpv[^"]+?)"(.+?)"', r'\1"${{ env.MPV_LATEST_VERSION }}"', content, count=1)
set_env('FOUND_NEW_MPV_VERSION', '1')
ffmpegOldVersion = re.search(r'(case .FFmpeg[^"]+?)"(.+?)"', content).group(2)
print("ffmpeg old version:", ffmpegOldVersion)
set_env('FFMPEG_OLD_VERSION', ffmpegOldVersion)
ffmpegNewVersion = '${{ env.FFMPEG_LATEST_VERSION }}'
if parse_version(ffmpegNewVersion) > parse_version(ffmpegOldVersion) and not ffmpegOldVersion.startswith(ffmpegNewVersion):
content = re.sub(r'(case .FFmpeg[^"]+?)"(.+?)"', r'\1"${{ env.FFMPEG_LATEST_VERSION }}"', content, count=1)
set_env('FOUND_NEW_FFMPEG_VERSION', '1')
with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)
file_path = './README.md'
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
if parse_version(mpvNewVersion) > parse_version(mpvOldVersion):
content = re.sub(r'mpv-.*-blue', r'mpv-${{ env.MPV_LATEST_VERSION }}-blue', content, count=1)
if parse_version(ffmpegNewVersion) > parse_version(ffmpegOldVersion):
content = re.sub(r'ffmpeg-.*-blue', r'ffmpeg-${{ env.FFMPEG_LATEST_VERSION }}-blue', content, count=1)
with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)
- name: Create Pull Request
if: env.FOUND_NEW_MPV_VERSION && !env.FOUND_NEW_FFMPEG_VERSION
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
./README.md
title: "mpv bump version to ${{ env.MPV_LATEST_VERSION }}"
body: |
https://github.com/mpv-player/mpv/releases/tag/${{ env.MPV_LATEST_VERSION }}
https://github.com/mpv-player/mpv/compare/${{ env.MPV_OLD_VERSION }}...${{ env.MPV_LATEST_VERSION }}
commit-message: "chore: mpv bump version to ${{ env.MPV_LATEST_VERSION }}"
- name: Create Pull Request
if: env.FOUND_NEW_FFMPEG_VERSION && !env.FOUND_NEW_MPV_VERSION
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
./README.md
title: "FFmpeg bump version to ${{ env.FFMPEG_LATEST_VERSION }}"
body: |
https://github.com/FFmpeg/FFmpeg/blob/${{ env.FFMPEG_LATEST_VERSION }}/Changelog
https://github.com/FFmpeg/FFmpeg/compare/${{ env.FFMPEG_OLD_VERSION }}...${{ env.FFMPEG_LATEST_VERSION }}
commit-message: "chore: FFmpeg bump version to ${{ env.FFMPEG_LATEST_VERSION }}"
- name: Create Pull Request
if: env.FOUND_NEW_FFMPEG_VERSION && env.FOUND_NEW_MPV_VERSION
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
./README.md
title: "mpv ${{ env.MPV_LATEST_VERSION }} && FFmpeg ${{ env.FFMPEG_LATEST_VERSION }}"
body: |
https://github.com/mpv-player/mpv/releases/tag/${{ env.MPV_LATEST_VERSION }}
https://github.com/mpv-player/mpv/compare/${{ env.MPV_OLD_VERSION }}...${{ env.MPV_LATEST_VERSION }}
https://github.com/FFmpeg/FFmpeg/blob/${{ env.FFMPEG_LATEST_VERSION }}/Changelog
https://github.com/FFmpeg/FFmpeg/compare/${{ env.FFMPEG_OLD_VERSION }}...${{ env.FFMPEG_LATEST_VERSION }}
commit-message: "chore: mpv ${{ env.MPV_LATEST_VERSION }} && FFmpeg ${{ env.FFMPEG_LATEST_VERSION }}"
check-deps:
permissions:
contents: write
pull-requests: write
strategy:
matrix:
library:
- name: libass
repository: "mpvkit/libass-build"
- name: vulkan
repository: "mpvkit/moltenvk-build"
- name: libplacebo
repository: "mpvkit/libplacebo-build"
- name: libshaderc
repository: "mpvkit/libshaderc-build"
- name: libdovi
repository: "mpvkit/libdovi-build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout latest code
uses: actions/checkout@v4
with:
repository: ${{ matrix.library.repository }}
path: 'latest_code'
fetch-depth: 0
- name: Get latest verion
id: version
run: |
cd ./latest_code
latest_tag=$(git tag --sort=-v:refname | grep -v "-" | head -n 1)
echo "latest tag: $latest_tag"
echo "LATEST_VERSION=$latest_tag" >> $GITHUB_ENV
rm -rf ../latest_code
- name: update to new version
uses: jannekem/run-python-script-action@v1
with:
script: |
import re
def parse_version(ver):
if '-' in ver or ver == '':
return 0
version_string = re.sub(r'[^.0-9]+', r'', ver)
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 int(f"{major}{minor}{patch}")
file_path = './Sources/BuildScripts/XCFrameworkBuild/main.swift'
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
oldVersion = re.search(r'(case .${{ matrix.library.name }}[^"]+?)"(.+?)"', content).group(2)
print("old version:", oldVersion)
newVersion = '${{ env.LATEST_VERSION }}'
print("new version:", newVersion)
if parse_version(newVersion) > parse_version(oldVersion) and not oldVersion.startswith(newVersion):
content = re.sub(r'(case .${{ matrix.library.name }}[^"]+?)"(.+?)"', r'\1"${{ env.LATEST_VERSION }}"', content, count=1)
set_env('FOUND_NEW_VERSION', '1')
# If libass is being updated, also update its dependencies
if '${{ matrix.library.name }}' == 'libass':
deps = ['libunibreak', 'libfreetype', 'libfribidi', 'libharfbuzz']
for dep in deps:
content = re.sub(r'(case .' + dep + r'[^"]+?)"(.+?)"', r'\1"${{ env.LATEST_VERSION }}"', content, count=1)
with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)
- name: Check PR already exists
id: check_pr_matrix
env:
GH_TOKEN: ${{ github.token }}
run: |
EXISTS=$(gh pr list --search '"${{ matrix.library.name }} bump version to ${{ env.LATEST_VERSION }}"' --state open --json title --jq 'length')
echo "exists=$([ "$EXISTS" -gt 0 ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: env.FOUND_NEW_VERSION && steps.check_pr_matrix.outputs.exists == 'false'
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
branch: "create-pull-request/${{ matrix.library.name }}"
delete-branch: true
title: "${{ matrix.library.name }} bump version to ${{ env.LATEST_VERSION }}"
body: |
https://github.com/${{ matrix.library.repository }}/releases/tag/${{ env.LATEST_VERSION }}
commit-message: "chore: ${{ matrix.library.name }} bump version to ${{ env.LATEST_VERSION }}"
update-min-versions:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout MoltenVK
uses: actions/checkout@v4
with:
repository: KhronosGroup/MoltenVK
path: moltenvk
fetch-depth: 0
- name: Get latest release tag
id: moltenvk_tag
run: |
cd moltenvk
latest_tag=$(git tag --sort=-v:refname | grep -v "-" | head -n 1)
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
rm -rf ../moltenvk
- name: Fetch and parse MoltenVK deployment targets
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const tagName = process.env.LATEST_TAG;
core.info(`Latest MoltenVK tag: ${tagName}`);
const projectUrl = `https://raw.githubusercontent.com/KhronosGroup/MoltenVK/refs/tags/${tagName}/MoltenVK/MoltenVK.xcodeproj/project.pbxproj`;
core.info(`Fetching project file from: ${projectUrl}`);
const projectResp = await fetch(projectUrl);
if (!projectResp.ok) {
core.setFailed(`Failed to fetch project file: ${projectResp.status} ${projectResp.statusText}`);
return;
}
const text = await projectResp.text();
const targets = {};
const patterns = {
ios: /IPHONEOS_DEPLOYMENT_TARGET\s*=\s*([\d.]+)/,
macos: /MACOSX_DEPLOYMENT_TARGET\s*=\s*([\d.]+)/,
tvos: /TVOS_DEPLOYMENT_TARGET\s*=\s*([\d.]+)/,
};
for (const [key, regex] of Object.entries(patterns)) {
const match = text.match(regex);
if (match) {
targets[key] = match[1];
}
}
core.info(`Parsed targets: ${JSON.stringify(targets)}`);
const baseFile = 'Sources/BuildScripts/XCFrameworkBuild/base.swift';
const templateFile = 'docs/Package.template.swift';
let baseContent = fs.readFileSync(baseFile, 'utf8');
let templateContent = fs.readFileSync(templateFile, 'utf8');
let hasChanges = false;
const versionMap = {
ios: targets.ios,
tvos: targets.tvos,
macos: targets.macos,
};
for (const [platform, newVersion] of Object.entries(versionMap)) {
const pattern = new RegExp(`(case \\.${platform}(?:,|:)[\\s\\S]*?return )"(\\d+\\.\\d+)"`);
const match = baseContent.match(pattern);
if (match) {
const oldVersion = match[2];
if (newVersion !== oldVersion) {
baseContent = baseContent.replace(pattern, `$1"${newVersion}"`);
core.info(`base.swift ${platform}: ${oldVersion} -> ${newVersion}`);
hasChanges = true;
}
}
}
const pkgVersionMap = {
iOS: targets.ios,
macOS: targets.macos,
tvOS: targets.tvos,
};
for (const [key, newVersion] of Object.entries(pkgVersionMap)) {
const pkgPattern = new RegExp(`\\.${key}\\(\\.[vV](\\d+)\\)`);
const pkgMatch = templateContent.match(pkgPattern);
if (pkgMatch) {
const oldMajor = pkgMatch[1];
const newMajor = newVersion.split('.')[0];
if (newMajor !== oldMajor) {
templateContent = templateContent.replace(pkgPattern, `.${key}(.v${newMajor})`);
core.info(`Package.template.swift ${key}: v${oldMajor} -> v${newMajor}`);
hasChanges = true;
}
}
}
if (hasChanges) {
fs.writeFileSync(baseFile, baseContent, 'utf8');
fs.writeFileSync(templateFile, templateContent, 'utf8');
core.info('Files updated');
core.exportVariable('NEW_IOS', targets.ios);
core.exportVariable('NEW_MACOS', targets.macos);
core.exportVariable('NEW_TVOS', targets.tvos);
core.exportVariable('NEW_TAG', tagName);
} else {
core.info('No version changes needed');
}
core.exportVariable('HAS_CHANGES', hasChanges ? 'true' : 'false');
- name: Create Pull Request
if: env.HAS_CHANGES == 'true'
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/base.swift
./docs/Package.template.swift
title: "raise minimum OS versions to iOS ${{ env.NEW_IOS }} / macOS ${{ env.NEW_MACOS }} / tvOS ${{ env.NEW_TVOS }}"
body: |
Updates minimum OS deployment targets to match MoltenVK ${{ env.NEW_TAG }}.
- iOS: ${{ env.NEW_IOS }}
- macOS: ${{ env.NEW_MACOS }}
- tvOS: ${{ env.NEW_TVOS }}
Source: https://raw.githubusercontent.com/KhronosGroup/MoltenVK/refs/tags/${{ env.NEW_TAG }}/MoltenVK/MoltenVK.xcodeproj/project.pbxproj
commit-message: "chore: raise minimum OS versions to iOS ${{ env.NEW_IOS }} / macOS ${{ env.NEW_MACOS }} / tvOS ${{ env.NEW_TVOS }}"