Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 5 additions & 73 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,76 +12,8 @@ jobs:
build:
permissions:
contents: write
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
brew install autoconf
brew install automake
brew install libtool
python -m pip install meson==1.4.2
brew install ninja

- name: Setup Xcode to support visionOS
run: |
sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
xcodebuild -showsdks


- 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()
buildVersion = re.search(r'(case .libbluray[^"]+?)"(.+?)"', content).group(2)
print(f'build version: {buildVersion}')
releaseVersion = '${{ github.event.inputs.version }}' or normalize_version(buildVersion)
print(f'release version: {releaseVersion}')
set_env('BUILD_VERSION', buildVersion)
set_env('RELEASE_VERSION', releaseVersion)

- name: Build
run: |
make build version=${{ env.RELEASE_VERSION }}

- name: Update Package.swift
run: |
rm -rf ./Package.swift
cp -f ./dist/release/Package.swift ./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.BUILD_VERSION }}"
push: "origin HEAD:${{ github.ref_name }}"

- name: Upload binary to GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ contains(env.RELEASE_VERSION, '-') && env.RELEASE_VERSION || env.BUILD_VERSION }}
tag_name: ${{ env.RELEASE_VERSION }}
files: |
./dist/release/*.txt
./dist/release/*.zip
prerelease: ${{ contains(env.RELEASE_VERSION, '-') }}
generate_release_notes: true
fail_on_unmatched_files: true
body: |
https://code.videolan.org/videolan/libbluray/-/tree/${{ env.BUILD_VERSION }}?ref_type=tags
uses: mpvkit/BuildShared/.github/workflows/build.yml@main
secrets: inherit
with:
version: '${{ github.event.inputs.version }}'
library: 'libbluray'
62 changes: 8 additions & 54 deletions .github/workflows/check_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,14 @@ on:
# - cron: '0 0 1 * *' # every month first day

jobs:
build:
check_version:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Checkout latest code
run: |
git clone https://code.videolan.org/videolan/libbluray.git latest_code

- 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
return int(re.sub(r'[^0-9]+', r'', ver))

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 .libbluray[^"]+?)"(.+?)"', content).group(2)
print("old version:", oldVersion)
set_env('OLD_VERSION', oldVersion)
newVersion = '${{ env.LATEST_VERSION }}'
print("new version:", newVersion)
if parse_version(newVersion) > parse_version(oldVersion):
content = re.sub(r'(case .libbluray[^"]+?)"(.+?)"', r'\1"${{ env.LATEST_VERSION }}"', content, count=1)
set_env('FOUND_NEW_VERSION', '1')
with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)


- name: Create Pull Request
if: env.FOUND_NEW_VERSION
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
title: "bump version to ${{ env.LATEST_VERSION }}"
body: |
https://code.videolan.org/videolan/libbluray/-/blob/${{ env.LATEST_VERSION }}/ChangeLog?ref_type=tags
commit-message: "chore: bump version to ${{ env.LATEST_VERSION }}"
uses: mpvkit/BuildShared/.github/workflows/check_version.yml@main
secrets: inherit
with:
repository: 'videolan/libbluray'
library: 'libbluray'
pr_body: |
{REPOSITORY_URL}/-/blob/{NEW_VERSION}/ChangeLog?ref_type=tags
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,5 @@ temp/
dist/
*.log
*.xcframework
.vscode
.vscode
Sources/BuildScripts/Package.resolved
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

build scripts for [libbluray](https://code.videolan.org/videolan/libbluray)

> This is a component of the [MPVKit](https://github.com/mpvkit/MPVKit) project.

## Installation

### Swift Package Manager
Expand Down
6 changes: 6 additions & 0 deletions Sources/BuildScripts/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ import PackageDescription

let package = Package(
name: "build",
platforms: [.macOS(.v11)],
products: [
.executable(name: "build", targets: ["build"])
],
dependencies: [
.package(url: "https://github.com/mpvkit/BuildShared.git", branch: "main")
],
targets: [
.executableTarget(
name: "build",
dependencies: ["BuildShared"],
path: "XCFrameworkBuild"
)
]
Expand Down
Loading