Skip to content

Commit fbe6705

Browse files
Copilotcxfksword
andauthored
Migrate libdav1d build pipeline to BuildShared and tighten workflow token permissions (#3)
* refactor: migrate build scripts and workflows to BuildShared Agent-Logs-Url: https://github.com/mpvkit/libdav1d-build/sessions/d3ef942b-dd78-4c16-8d93-67aceeaaa85a Co-authored-by: cxfksword <718792+cxfksword@users.noreply.github.com> * chore: finalize docs template formatting update Agent-Logs-Url: https://github.com/mpvkit/libdav1d-build/sessions/d3ef942b-dd78-4c16-8d93-67aceeaaa85a Co-authored-by: cxfksword <718792+cxfksword@users.noreply.github.com> * fix: avoid force unwrap in BuildShared release URL generation Agent-Logs-Url: https://github.com/mpvkit/libdav1d-build/sessions/d3ef942b-dd78-4c16-8d93-67aceeaaa85a Co-authored-by: cxfksword <718792+cxfksword@users.noreply.github.com> * fix: require initialized BuildRunner options for target URLs Agent-Logs-Url: https://github.com/mpvkit/libdav1d-build/sessions/d3ef942b-dd78-4c16-8d93-67aceeaaa85a Co-authored-by: cxfksword <718792+cxfksword@users.noreply.github.com> * fix: add explicit token permissions to reusable workflows Agent-Logs-Url: https://github.com/mpvkit/libdav1d-build/sessions/3007cad1-1654-4172-92cb-b238b78dbc5e Co-authored-by: cxfksword <718792+cxfksword@users.noreply.github.com> * chore: clarify releaseVersion precondition message Agent-Logs-Url: https://github.com/mpvkit/libdav1d-build/sessions/3007cad1-1654-4172-92cb-b238b78dbc5e Co-authored-by: cxfksword <718792+cxfksword@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: cxfksword <718792+cxfksword@users.noreply.github.com>
1 parent d8e86b1 commit fbe6705

8 files changed

Lines changed: 34 additions & 1597 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -11,79 +11,8 @@ jobs:
1111
build:
1212
permissions:
1313
contents: write
14-
runs-on: macos-14
15-
steps:
16-
- uses: actions/checkout@v4
17-
18-
- name: Install dependencies
19-
run: |
20-
brew install autoconf
21-
brew install automake
22-
brew install libtool
23-
python -m pip install meson==1.4.2
24-
brew install ninja
25-
brew install nasm
26-
27-
- name: Setup Xcode to support visionOS
28-
run: |
29-
sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
30-
xcodebuild -showsdks
31-
32-
33-
- name: Check version to release
34-
uses: jannekem/run-python-script-action@v1
35-
with:
36-
script: |
37-
import re
38-
39-
def normalize_version(version_string):
40-
version_string = re.sub(r'[^.0-9]+|-.+', '', version_string)
41-
parts = re.split(r'\.', version_string)
42-
major = int(parts[0])
43-
minor = int(parts[1]) if len(parts) > 1 else 0
44-
patch = int(parts[2]) if len(parts) > 2 else 0
45-
return f"{major}.{minor}.{patch}"
46-
47-
file_path = './Sources/BuildScripts/XCFrameworkBuild/main.swift'
48-
with open(file_path, 'r', encoding='utf-8') as file:
49-
content = file.read()
50-
buildVersion = re.search(r'(case .libdav1d[^"]+?)"(.+?)"', content).group(2)
51-
print(f'build version: {buildVersion}')
52-
releaseVersion = '${{ github.event.inputs.version }}' or normalize_version(buildVersion)
53-
print(f'release version: {releaseVersion}')
54-
set_env('BUILD_VERSION', buildVersion)
55-
set_env('RELEASE_VERSION', releaseVersion)
56-
57-
- name: Build
58-
run: |
59-
make build version=${{ env.RELEASE_VERSION }}
60-
61-
- name: Update Package.swift
62-
run: |
63-
rm -rf ./Package.swift
64-
cp -f ./dist/release/Package.swift ./Package.swift
65-
66-
- name: Push Package.swift
67-
uses: EndBug/add-and-commit@v9
68-
with:
69-
default_author: github_actions
70-
add: |
71-
- Package.swift
72-
message: "chore: bump version to ${{ env.BUILD_VERSION }}"
73-
push: "origin HEAD:${{ github.ref_name }}"
74-
75-
- name: Upload binary to GitHub Release
76-
uses: softprops/action-gh-release@v2
77-
with:
78-
name: ${{ contains(env.RELEASE_VERSION, '-') && env.RELEASE_VERSION || env.BUILD_VERSION }}
79-
tag_name: ${{ env.RELEASE_VERSION }}
80-
files: |
81-
./dist/release/*.txt
82-
./dist/release/*.zip
83-
prerelease: ${{ contains(env.RELEASE_VERSION, '-') }}
84-
generate_release_notes: true
85-
fail_on_unmatched_files: true
86-
body: |
87-
https://github.com/videolan/dav1d/releases/tag/${{ env.BUILD_VERSION }}
88-
89-
![download](https://img.shields.io/github/downloads/${{ github.repository }}/${{ env.RELEASE_VERSION }}/total?label=Downloads)
14+
uses: mpvkit/BuildShared/.github/workflows/build.yml@main
15+
secrets: inherit
16+
with:
17+
version: '${{ github.event.inputs.version }}'
18+
library: 'libdav1d'

.github/workflows/check_version.yml

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,12 @@ on:
44
workflow_dispatch:
55

66
jobs:
7-
build:
7+
check_version:
88
permissions:
99
contents: write
1010
pull-requests: write
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
15-
- name: Checkout latest code
16-
uses: actions/checkout@v4
17-
with:
18-
repository: "videolan/dav1d"
19-
path: 'latest_code'
20-
fetch-depth: 0
21-
22-
- name: Get latest version
23-
id: version
24-
run: |
25-
cd ./latest_code
26-
latest_tag=$(git tag --sort=-v:refname | grep -v "-" | head -n 1)
27-
echo "latest tag: $latest_tag"
28-
echo "LATEST_VERSION=$latest_tag" >> $GITHUB_ENV
29-
rm -rf ../latest_code
30-
31-
- name: update to new version
32-
uses: jannekem/run-python-script-action@v1
33-
with:
34-
script: |
35-
import re
36-
37-
def parse_version(ver):
38-
if '-' in ver or ver == '':
39-
return 0
40-
return int(re.sub(r'[^0-9]+', r'', ver))
41-
42-
file_path = './Sources/BuildScripts/XCFrameworkBuild/main.swift'
43-
with open(file_path, 'r', encoding='utf-8') as file:
44-
content = file.read()
45-
oldVersion = re.search(r'(case .libdav1d[^"]+?)"(.+?)"', content).group(2)
46-
print("old version:", oldVersion)
47-
set_env('OLD_VERSION', oldVersion)
48-
newVersion = '${{ env.LATEST_VERSION }}'
49-
print("new version:", newVersion)
50-
if parse_version(newVersion) > parse_version(oldVersion):
51-
content = re.sub(r'(case .libdav1d[^"]+?)"(.+?)"', r'\1"${{ env.LATEST_VERSION }}"', content, count=1)
52-
set_env('FOUND_NEW_VERSION', '1')
53-
with open(file_path, 'w', encoding='utf-8') as file:
54-
file.write(content)
55-
56-
57-
- name: Create Pull Request
58-
if: env.FOUND_NEW_VERSION
59-
uses: peter-evans/create-pull-request@v6
60-
with:
61-
add-paths: |
62-
./Sources/BuildScripts/XCFrameworkBuild/main.swift
63-
title: "bump version to ${{ env.LATEST_VERSION }}"
64-
body: |
65-
https://github.com/videolan/dav1d/releases/tag/${{ env.LATEST_VERSION }}
66-
67-
https://github.com/videolan/dav1d/compare/${{ env.OLD_VERSION }}...${{ env.LATEST_VERSION }}
68-
commit-message: "chore: bump version to ${{ env.LATEST_VERSION }}"
11+
uses: mpvkit/BuildShared/.github/workflows/check_version.yml@main
12+
secrets: inherit
13+
with:
14+
repository: 'videolan/dav1d'
15+
library: 'libdav1d'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,5 @@ temp/
118118
dist/
119119
*.log
120120
*.xcframework
121-
.vscode
121+
.vscode
122+
Sources/BuildScripts/Package.resolved

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
build scripts for [dav1d](https://github.com/videolan/dav1d)
44

5+
> This is a component of the [MPVKit](https://github.com/mpvkit/MPVKit) project.
6+
57
## Installation
68

79
### Swift Package Manager
@@ -18,4 +20,4 @@ make build
1820
make build platform=ios,macos
1921
# or see help
2022
make help
21-
```
23+
```

Sources/BuildScripts/Package.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ import PackageDescription
44

55
let package = Package(
66
name: "build",
7+
platforms: [.macOS(.v11)],
78
products: [
9+
.executable(name: "build", targets: ["build"])
10+
],
11+
dependencies: [
12+
.package(url: "https://github.com/mpvkit/BuildShared.git", branch: "main")
813
],
914
targets: [
1015
.executableTarget(
1116
name: "build",
17+
dependencies: ["BuildShared"],
1218
path: "XCFrameworkBuild"
1319
)
1420
]

0 commit comments

Comments
 (0)