Skip to content

Build and Release XCFramework #5

Build and Release XCFramework

Build and Release XCFramework #5

name: Build XCFramework
on:
push:
branches: [ main ]
tags:
- 'v*' # This will trigger the workflow on any tag starting with 'v'
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
release_version:
description: 'Release version (e.g., 0.1.6)'
required: false
default: ''
jobs:
build:
runs-on: macos-latest
env:
OUTPUT_DIR: ${{ github.workspace }}/output
steps:
- uses: actions/checkout@v2
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Install autotools
run: |
brew install autoconf automake libtool
- name: Setup build environment
run: |
aclocal && autoconf && automake --add-missing
mkdir -p "$OUTPUT_DIR"
- name: Build for macOS arm64
run: |
./.github/actions/build_library.sh macosx arm64 MacOSX
- name: Build for macOS x86_64
run: |
./.github/actions/build_library.sh macosx x86_64 MacOSX
- name: Build for iOS arm64
run: |
./.github/actions/build_library.sh iphoneos arm64 iPhoneOS
- name: Build for iOS Simulator x86_64
run: |
./.github/actions/build_library.sh iphonesimulator x86_64 iPhoneSimulator
- name: Build for iOS Simulator arm64
run: |
./.github/actions/build_library.sh iphonesimulator arm64 iPhoneSimulator
- name: Create XCFrameworks
run: |
mkdir -p "${OUTPUT_DIR}/Headers/"
rm -rf ${OUTPUT_DIR}/Headers/*
rm -rf ${OUTPUT_DIR}/opencore-amrnb.xcframework
cp -a amrnb/{interf_dec,interf_enc}.h ${OUTPUT_DIR}/Headers/
./.github/actions/create_xcframework.sh opencore-amrnb
rm -rf ${OUTPUT_DIR}/Headers/*
rm -rf ${OUTPUT_DIR}/opencore-amrwb.xcframework
cp -a amrwb/{dec_if,if_rom}.h ${OUTPUT_DIR}/Headers/
./.github/actions/create_xcframework.sh opencore-amrwb
- name: Determine Release Version
id: version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "version=${{ github.event.inputs.release_version }}" >> $GITHUB_OUTPUT
else
echo "version=v${{ github.run_number }}" >> $GITHUB_OUTPUT
fi
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
- name: Upload XCFrameworks to Release
uses: softprops/action-gh-release@v1
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
with:
files: ${{ env.OUTPUT_DIR }}/*.xcframework
tag_name: ${{ steps.version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check Release
run: |
echo "Checking release ${{ steps.version.outputs.version }}"
release_info=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.version.outputs.version }})
echo "Release info: $release_info"
assets=$(echo $release_info | jq '.assets')
echo "Release assets: $assets"
- name: Upload XCFrameworks
uses: actions/upload-artifact@v4
with:
name: XCFrameworks
path: ${{ env.OUTPUT_DIR }}/*.xcframework
if-no-files-found: error