Skip to content

Commit 672b146

Browse files
authored
Update build-xcframework.yml
1 parent e4eeb27 commit 672b146

File tree

1 file changed

+63
-54
lines changed

1 file changed

+63
-54
lines changed

.github/workflows/build-xcframework.yml

Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build XCFramework
1+
name: Build and Release XCFramework
22

33
on:
44
push:
@@ -10,53 +10,62 @@ on:
1010
workflow_dispatch:
1111
inputs:
1212
release_version:
13-
description: 'Release version (e.g., 0.1.6)'
13+
description: 'Release version (must start with "v", e.g., v0.1.6)'
1414
required: false
1515
default: ''
1616

17+
env:
18+
OUTPUT_DIR: ${{ github.workspace }}/output
19+
1720
jobs:
1821
build:
1922
runs-on: macos-latest
20-
21-
env:
22-
OUTPUT_DIR: ${{ github.workspace }}/output
23+
strategy:
24+
matrix:
25+
config:
26+
- { sdk: 'macosx', arch: 'arm64', platform: 'MacOSX' }
27+
- { sdk: 'macosx', arch: 'x86_64', platform: 'MacOSX' }
28+
- { sdk: 'iphoneos', arch: 'arm64', platform: 'iPhoneOS' }
29+
- { sdk: 'iphonesimulator', arch: 'x86_64', platform: 'iPhoneSimulator' }
30+
- { sdk: 'iphonesimulator', arch: 'arm64', platform: 'iPhoneSimulator' }
2331

2432
steps:
25-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v3
2634

2735
- name: Set up Xcode
2836
uses: maxim-lobanov/setup-xcode@v1
2937
with:
3038
xcode-version: latest-stable
3139

3240
- name: Install autotools
33-
run: |
34-
brew install autoconf automake libtool
41+
run: brew install autoconf automake libtool
3542

3643
- name: Setup build environment
3744
run: |
3845
aclocal && autoconf && automake --add-missing
3946
mkdir -p "$OUTPUT_DIR"
4047
41-
- name: Build for macOS arm64
42-
run: |
43-
./.github/actions/build_library.sh macosx arm64 MacOSX
44-
45-
- name: Build for macOS x86_64
48+
- name: Build for ${{ matrix.config.sdk }} ${{ matrix.config.arch }}
4649
run: |
47-
./.github/actions/build_library.sh macosx x86_64 MacOSX
50+
./.github/actions/build_library.sh ${{ matrix.config.sdk }} ${{ matrix.config.arch }} ${{ matrix.config.platform }}
4851
49-
- name: Build for iOS arm64
50-
run: |
51-
./.github/actions/build_library.sh iphoneos arm64 iPhoneOS
52+
- name: Upload build artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: build-${{ matrix.config.sdk }}-${{ matrix.config.arch }}
56+
path: ${{ env.OUTPUT_DIR }}
57+
retention-days: 1
5258

53-
- name: Build for iOS Simulator x86_64
54-
run: |
55-
./.github/actions/build_library.sh iphonesimulator x86_64 iPhoneSimulator
59+
create-xcframework:
60+
needs: build
61+
runs-on: macos-latest
62+
steps:
63+
- uses: actions/checkout@v3
5664

57-
- name: Build for iOS Simulator arm64
58-
run: |
59-
./.github/actions/build_library.sh iphonesimulator arm64 iPhoneSimulator
65+
- name: Download all build artifacts
66+
uses: actions/download-artifact@v4
67+
with:
68+
path: ${{ env.OUTPUT_DIR }}
6069

6170
- name: Create XCFrameworks
6271
run: |
@@ -72,28 +81,6 @@ jobs:
7281
cp -a amrwb/{dec_if,if_rom}.h ${OUTPUT_DIR}/Headers/
7382
./.github/actions/create_xcframework.sh opencore-amrwb
7483
75-
- name: Determine Release Version
76-
id: version
77-
run: |
78-
if [[ $GITHUB_REF == refs/tags/* ]]; then
79-
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
80-
elif [ -n "${{ github.event.inputs.release_version }}" ]; then
81-
echo "version=${{ github.event.inputs.release_version }}" >> $GITHUB_OUTPUT
82-
else
83-
echo "version=v${{ github.run_number }}" >> $GITHUB_OUTPUT
84-
fi
85-
86-
- name: List output directory
87-
run: |
88-
echo "Current working directory: $(pwd)"
89-
echo "OUTPUT_DIR: ${{ env.OUTPUT_DIR }}"
90-
echo "Contents of OUTPUT_DIR:"
91-
ls -la ${{ env.OUTPUT_DIR }}
92-
echo "Full paths of .xcframework directories:"
93-
find ${{ env.OUTPUT_DIR }} -name "*.xcframework" -type d
94-
echo "Structure of .xcframework directories:"
95-
find ${{ env.OUTPUT_DIR }} -name "*.xcframework" -type d -exec sh -c 'echo "{}:"; ls -R "{}"' \;
96-
9784
- name: Zip XCFrameworks
9885
run: |
9986
cd ${{ env.OUTPUT_DIR }}
@@ -102,9 +89,38 @@ jobs:
10289
done
10390
ls -la
10491
92+
- name: Upload XCFrameworks
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: XCFrameworks
96+
path: ${{ env.OUTPUT_DIR }}/*.xcframework.zip
97+
if-no-files-found: error
98+
99+
release:
100+
needs: create-xcframework
101+
runs-on: ubuntu-latest
102+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
103+
steps:
104+
- name: Download XCFrameworks
105+
uses: actions/download-artifact@v4
106+
with:
107+
name: XCFrameworks
108+
109+
- name: Determine Release Version
110+
id: version
111+
run: |
112+
if [[ $GITHUB_REF == refs/tags/* ]]; then
113+
VERSION=${GITHUB_REF#refs/tags/}
114+
elif [[ "${{ github.event.inputs.release_version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
115+
VERSION=${{ github.event.inputs.release_version }}
116+
else
117+
echo "Error: Invalid version format. Must start with 'v' followed by semantic versioning."
118+
exit 1
119+
fi
120+
echo "version=$VERSION" >> $GITHUB_OUTPUT
121+
105122
- name: Create Release and Upload XCFrameworks
106123
uses: softprops/action-gh-release@v2
107-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
108124
with:
109125
tag_name: ${{ steps.version.outputs.version }}
110126
name: Release ${{ steps.version.outputs.version }}
@@ -113,7 +129,7 @@ jobs:
113129
generate_release_notes: true
114130
fail_on_unmatched_files: true
115131
files: |
116-
${{ env.OUTPUT_DIR }}/*.xcframework.zip
132+
*.xcframework.zip
117133
env:
118134
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119135

@@ -127,10 +143,3 @@ jobs:
127143
assets=$(echo "$release_info" | jq -r '.assets[].name')
128144
echo "Release assets:"
129145
echo "$assets"
130-
131-
- name: Upload XCFrameworks as Workflow Artifacts
132-
uses: actions/upload-artifact@v4
133-
with:
134-
name: XCFrameworks
135-
path: ${{ env.OUTPUT_DIR }}/*.xcframework.zip
136-
if-no-files-found: error

0 commit comments

Comments
 (0)