Skip to content

Commit 64505d1

Browse files
committed
fix(builder): improve static library combination for macOS and Linux
- Replace libtool with ar for macOS library combining to avoid compatibility issues - Implement extract-and-recombine approach with separate subdirectories to prevent name collisions - Add batching for object files to avoid ARG_MAX limitations - Use thin archive approach for Linux to prevent memory exhaustion when combining multiple libraries - Add better error handling with stderr capture for improved diagnostics - Add write permissions to GitHub workflow to allow release uploads
1 parent 1227533 commit 64505d1

8 files changed

Lines changed: 530 additions & 310 deletions

File tree

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: FFmpeg library release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Library version (e.g., 8.0.0.0)'
8+
required: true
9+
push:
10+
tags:
11+
- 'lib-*'
12+
13+
permissions:
14+
pull-requests: write
15+
contents: write
16+
17+
jobs:
18+
ffmpeg-release:
19+
name: Release FFmpeg library for ${{ matrix.os }} ${{ matrix.arch }}
20+
runs-on: ${{ matrix.runner }}
21+
strategy:
22+
matrix:
23+
include:
24+
- os: linux
25+
arch: amd64
26+
runner: ubuntu-24.04
27+
- os: linux
28+
arch: arm64
29+
runner: ubuntu-24.04-arm
30+
- os: darwin
31+
arch: amd64
32+
runner: macos-15-intel
33+
- os: darwin
34+
arch: arm64
35+
runner: macos-latest
36+
fail-fast: false
37+
38+
steps:
39+
- name: Validate version format
40+
if: github.event_name == 'workflow_dispatch'
41+
run: |
42+
if [[ ! "${{ inputs.version }}" =~ ^lib- ]]; then
43+
echo "Error: Version must start with 'lib-' prefix (e.g., 'lib-8.0.0.0')"
44+
exit 1
45+
fi
46+
47+
- name: Checkout code
48+
uses: actions/checkout@v6
49+
50+
- name: Set up Go
51+
uses: actions/setup-go@v6
52+
with:
53+
go-version: '1.24'
54+
55+
- name: Cache Go modules and build cache
56+
uses: actions/cache@v4
57+
with:
58+
path: |
59+
~/go/pkg/mod
60+
~/.cache/go-build
61+
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('go.sum', 'go.mod') }}
62+
restore-keys: |
63+
${{ runner.os }}-${{ runner.arch }}-go-
64+
65+
- name: Install Rust toolchain
66+
uses: dtolnay/rust-toolchain@stable
67+
with:
68+
toolchain: stable
69+
70+
- name: Cache Rust cargo
71+
uses: actions/cache@v4
72+
with:
73+
path: |
74+
~/.cargo/bin/
75+
~/.cargo/registry/index/
76+
~/.cargo/registry/cache/
77+
~/.cargo/git/db/
78+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-stable
79+
restore-keys: |
80+
${{ runner.os }}-${{ runner.arch }}-cargo-
81+
82+
- name: Install cargo-c
83+
run: cargo install cargo-c
84+
85+
- name: Install Linux dependencies
86+
if: matrix.os == 'linux'
87+
run: sudo apt-get update && sudo apt-get install -y yasm nasm meson gperf python3
88+
89+
- name: Install macOS dependencies
90+
if: matrix.os == 'darwin'
91+
run: brew update && brew install yasm autoconf ragel meson nasm automake libtool python3
92+
93+
- name: Cache FFmpeg source downloads
94+
uses: actions/cache@v4
95+
with:
96+
path: .build/downloads
97+
key: ${{ runner.os }}-${{ runner.arch }}-ffmpeg-downloads-${{ hashFiles('internal/builder/libraries.go') }}
98+
restore-keys: |
99+
${{ runner.os }}-${{ runner.arch }}-ffmpeg-downloads-
100+
101+
- name: Cache compiled dependencies
102+
uses: actions/cache@v4
103+
with:
104+
path: |
105+
.build/staging
106+
.build/build
107+
key: ${{ runner.os }}-${{ runner.arch }}-ffmpeg-deps-${{ hashFiles('internal/builder/libraries.go', 'internal/builder/buildsystems.go') }}
108+
restore-keys: |
109+
${{ runner.os }}-${{ runner.arch }}-ffmpeg-deps-
110+
111+
- name: Clean FFmpeg build
112+
run: go run ./internal/builder/ ffmpeg --clean
113+
114+
- name: Build FFmpeg library
115+
run: go run ./internal/builder/
116+
117+
- name: List built files
118+
run: ls -lh lib/${{ matrix.os }}_${{ matrix.arch }}/
119+
120+
- name: Create tarball
121+
run: |
122+
cd lib
123+
tar -czf ../ffmpeg-${{ matrix.os }}-${{ matrix.arch }}.tar.gz ${{ matrix.os }}_${{ matrix.arch }}/libffmpeg.a
124+
125+
- name: Create Release
126+
uses: softprops/action-gh-release@v2
127+
with:
128+
files: ffmpeg-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
129+
tag_name: ${{ inputs.version }}
130+
body: |
131+
## FFmpeg Static Libraries
132+
133+
**Version:** ${{ inputs.version }}
134+
135+
**Platforms:**
136+
- Linux amd64
137+
- Linux arm64
138+
- macOS x86 (Intel)
139+
- macOS arm64 (Apple Silicon)
140+

.github/workflows/ffmpeg-test.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: FFmpeg library test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- '.github/workflows/ffmpeg-test.yml'
8+
- 'internal/builder/**'
9+
- '*.gen.go'
10+
workflow_dispatch:
11+
12+
permissions:
13+
pull-requests: write
14+
contents: write
15+
16+
jobs:
17+
ffmpeg-test:
18+
name: Build FFmpeg library for ${{ matrix.os }} ${{ matrix.arch }}
19+
runs-on: ${{ matrix.runner }}
20+
strategy:
21+
matrix:
22+
include:
23+
- os: linux
24+
arch: amd64
25+
runner: ubuntu-24.04
26+
- os: linux
27+
arch: arm64
28+
runner: ubuntu-24.04-arm
29+
- os: darwin
30+
arch: amd64
31+
runner: macos-15-intel
32+
- os: darwin
33+
arch: arm64
34+
runner: macos-latest
35+
fail-fast: false
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v6
40+
41+
- name: Set up Go
42+
uses: actions/setup-go@v6
43+
with:
44+
go-version: '1.24'
45+
46+
- name: Cache Go modules and build cache
47+
uses: actions/cache@v4
48+
with:
49+
path: |
50+
~/go/pkg/mod
51+
~/.cache/go-build
52+
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('go.sum', 'go.mod') }}
53+
restore-keys: |
54+
${{ runner.os }}-${{ runner.arch }}-go-
55+
56+
- name: Install Rust toolchain
57+
uses: dtolnay/rust-toolchain@stable
58+
with:
59+
toolchain: stable
60+
61+
- name: Cache Rust cargo
62+
uses: actions/cache@v4
63+
with:
64+
path: |
65+
~/.cargo/bin/
66+
~/.cargo/registry/index/
67+
~/.cargo/registry/cache/
68+
~/.cargo/git/db/
69+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-stable
70+
restore-keys: |
71+
${{ runner.os }}-${{ runner.arch }}-cargo-
72+
73+
- name: Install cargo-c
74+
run: cargo install cargo-c
75+
76+
- name: Install Linux dependencies
77+
if: matrix.os == 'linux'
78+
run: sudo apt-get update && sudo apt-get install -y yasm nasm meson gperf python3
79+
80+
- name: Install macOS dependencies
81+
if: matrix.os == 'darwin'
82+
run: brew update && brew install yasm autoconf ragel meson nasm automake libtool python3
83+
84+
- name: Cache FFmpeg source downloads
85+
uses: actions/cache@v4
86+
with:
87+
path: .build/downloads
88+
key: ${{ runner.os }}-${{ runner.arch }}-ffmpeg-downloads-${{ hashFiles('internal/builder/libraries.go') }}
89+
restore-keys: |
90+
${{ runner.os }}-${{ runner.arch }}-ffmpeg-downloads-
91+
92+
- name: Cache compiled dependencies
93+
uses: actions/cache@v4
94+
with:
95+
path: |
96+
.build/staging
97+
.build/build
98+
key: ${{ runner.os }}-${{ runner.arch }}-ffmpeg-deps-${{ hashFiles('internal/builder/libraries.go', 'internal/builder/buildsystems.go') }}
99+
restore-keys: |
100+
${{ runner.os }}-${{ runner.arch }}-ffmpeg-deps-
101+
102+
- name: Build FFmpeg library
103+
run: go run ./internal/builder/
104+
105+
- name: List built files
106+
run: ls -lh lib/${{ matrix.os }}_${{ matrix.arch }}/

.github/workflows/ffmpeg.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

.github/workflows/go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Go
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: [ "main" ]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: [ "main" ]
88
workflow_dispatch:
99

1010
jobs:

0 commit comments

Comments
 (0)