ci: upload packages to github packages registry #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Windows builds | |
| - os: windows-latest | |
| rid: win-x64 | |
| platform: Windows | |
| arch: x64 | |
| cmake_target_arch: x64 | |
| lib_extension: ".dll" | |
| toolchain: "Visual Studio 17 2022" | |
| - os: windows-latest | |
| rid: win-x86 | |
| platform: Windows | |
| arch: x86 | |
| cmake_target_arch: Win32 | |
| lib_extension: ".dll" | |
| toolchain: "Visual Studio 17 2022" | |
| - os: windows-latest | |
| rid: win-arm64 | |
| platform: Windows | |
| arch: ARM64 | |
| cmake_target_arch: ARM64 | |
| lib_extension: ".dll" | |
| toolchain: "Visual Studio 17 2022" | |
| # Linux builds | |
| - os: ubuntu-22.04 | |
| rid: linux-x64 | |
| platform: Linux | |
| arch: x86_64 | |
| cmake_target_arch: x64 | |
| lib_extension: ".so" | |
| - os: ubuntu-22.04-arm | |
| rid: linux-arm64 | |
| platform: Linux | |
| arch: aarch64 | |
| cmake_target_arch: aarch64 | |
| lib_extension: ".so" | |
| # macOS builds | |
| - os: macos-latest | |
| rid: osx-arm64 | |
| platform: macOS | |
| arch: arm64 | |
| cmake_target_arch: arm64 | |
| lib_extension: ".dylib" | |
| - os: macos-latest | |
| rid: osx-x64 | |
| platform: macOS | |
| arch: x86_64 | |
| cmake_target_arch: x86_64 | |
| lib_extension: ".dylib" | |
| # iOS builds | |
| - os: macos-latest | |
| rid: ios-arm64 | |
| platform: iOS | |
| arch: arm64 | |
| cmake_target_arch: arm64 | |
| lib_extension: ".framework" | |
| # Android builds | |
| - os: ubuntu-22.04 | |
| rid: android-arm | |
| platform: Android | |
| arch: armeabi-v7a | |
| cmake_target_arch: armeabi-v7a | |
| lib_extension: ".so" | |
| - os: ubuntu-22.04 | |
| rid: android-arm64 | |
| platform: Android | |
| arch: arm64-v8a | |
| cmake_target_arch: arm64-v8a | |
| lib_extension: ".so" | |
| - os: ubuntu-22.04 | |
| rid: android-x64 | |
| platform: Android | |
| arch: x86_64 | |
| cmake_target_arch: x86_64 | |
| lib_extension: ".so" | |
| name: Build for ${{ matrix.platform }} - ${{ matrix.arch }} | |
| container: ${{ matrix.platform == 'Linux' && 'debian:buster-slim' || '' }} | |
| steps: | |
| - name: UpdateSource (Linux) | |
| if: matrix.platform == 'Linux' | |
| run: | | |
| rm /etc/apt/sources.list | |
| echo 'deb http://archive.debian.org/debian buster main contrib non-free' >> /etc/apt/sources.list | |
| echo 'deb http://archive.debian.org/debian buster-updates main contrib non-free' >> /etc/apt/sources.list | |
| echo 'deb http://archive.debian.org/debian-security buster/updates main contrib non-free' >> /etc/apt/sources.list | |
| - name: InstallTool (Linux) | |
| if: matrix.platform == 'Linux' | |
| run: | | |
| dpkg --add-architecture arm64 | |
| apt-get clean | |
| apt-get update | |
| apt-get install libicu-dev -y | |
| apt-get install libssl-dev -y | |
| apt-get install wget -y | |
| apt-get install curl -y | |
| apt-get install clang llvm -y | |
| apt-get install gcc-aarch64-linux-gnu -y | |
| apt-get install binutils-aarch64-linux-gnu -y | |
| apt-get install zlib1g-dev -y | |
| apt-get install zlib1g-dev:arm64 -y | |
| apt-get install git -y | |
| apt-get install sudo -y | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Create Build Directories | |
| shell: bash | |
| run: | | |
| mkdir -p ${{ github.workspace }}/Native/build | |
| mkdir -p ${{ github.workspace }}/Native/cmake | |
| # Windows-specific setup | |
| - name: Setup Visual Studio (Windows) | |
| if: matrix.platform == 'Windows' | |
| uses: microsoft/setup-msbuild@v2 | |
| # - name: Install Windows SDK (Windows) | |
| # if: matrix.platform == 'Windows' | |
| # uses: GuillaumeFalourd/setup-windows10-sdk-action@v2.4 | |
| - name: Install VS Build Tools | |
| if: matrix.platform == 'Windows' | |
| shell: powershell | |
| run: | | |
| # Install Chocolatey | |
| Set-ExecutionPolicy Bypass -Scope Process -Force; | |
| [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; | |
| iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
| # Install Visual Studio Build Tools | |
| choco install visualstudio2019buildtools --package-parameters "--includeRecommended --includeOptional --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" --no-progress | |
| # Find and set dumpbin path | |
| $vsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC" | |
| $latestVersion = (Get-ChildItem -Path $vsPath | Sort-Object Name -Descending | Select-Object -First 1).Name | |
| $dumpbinPath = "$vsPath\$latestVersion\bin\Hostx64\x64" | |
| # Add to PATH | |
| "DUMPBIN_PATH=$dumpbinPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| "PATH=$dumpbinPath;$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| # Linux/Android dependencies | |
| - name: Install Dependencies (Linux) | |
| if: matrix.platform == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake gcc g++ file binutils | |
| - name: Install Dependencies (Android) | |
| if: matrix.platform == 'Android' | |
| uses: android-actions/setup-android@v2 | |
| - name: Install Cross-Compilation tools (Linux) | |
| if: matrix.platform == 'Linux' && (matrix.arch == 'armv7l' || matrix.arch == 'aarch64') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qemu-user-static | |
| if [ "${{ matrix.arch }}" == "armv7l" ]; then | |
| sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf | |
| elif [ "${{ matrix.arch }}" == "aarch64" ]; then | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| fi | |
| - name: Configure CMake (Windows) | |
| if: matrix.platform == 'Windows' | |
| shell: cmd | |
| working-directory: ${{ github.workspace }}/Native | |
| run: | | |
| cmake -B build -G "%TOOLCHAIN%" -A %CMAKE_TARGET_ARCH% -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.26100.0 | |
| env: | |
| TOOLCHAIN: ${{ matrix.toolchain }} | |
| CMAKE_TARGET_ARCH: ${{ matrix.cmake_target_arch }} | |
| - name: Configure CMake (Unix) | |
| if: matrix.platform != 'Windows' | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/Native | |
| run: | | |
| CMAKE_FLAGS="" | |
| if [ "${{ matrix.platform }}" == "Android" ]; then | |
| CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.arch }} -DANDROID_PLATFORM=android-21 -DCMAKE_ANDROID_ARCH_ABI=${{ matrix.cmake_target_arch }}" | |
| elif [ "${{ matrix.platform }}" == "iOS" ]; then | |
| CMAKE_FLAGS="-G Xcode \ | |
| -DCMAKE_SYSTEM_NAME=iOS \ | |
| -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_target_arch }} \ | |
| -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \ | |
| -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY="" \ | |
| -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=NO \ | |
| -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO" | |
| elif [ "${{ matrix.platform }}" == "macOS" ]; then | |
| CMAKE_FLAGS="-DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_target_arch }}" | |
| elif [ "${{ matrix.platform }}" == "Linux" ]; then | |
| # Add specific flags for Linux cross-compilation | |
| if [ "${{ matrix.arch }}" == "armv7l" ]; then | |
| CMAKE_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=arm -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++" | |
| elif [ "${{ matrix.arch }}" == "aarch64" ]; then | |
| CMAKE_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++" | |
| else | |
| CMAKE_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=x86_64" | |
| fi | |
| fi | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release $CMAKE_FLAGS | |
| # Build steps | |
| - name: Build (Windows) | |
| if: matrix.platform == 'Windows' | |
| shell: cmd | |
| working-directory: ${{ github.workspace }}/Native/build | |
| run: | | |
| cmake --build . --config Release | |
| - name: Build (iOS) | |
| if: matrix.platform == 'iOS' | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/Native/build | |
| run: | | |
| xcodebuild \ | |
| -project *.xcodeproj \ | |
| -configuration Release \ | |
| -sdk iphoneos \ | |
| CODE_SIGN_IDENTITY="" \ | |
| CODE_SIGNING_REQUIRED=NO \ | |
| CODE_SIGNING_ALLOWED=NO | |
| - name: Build (Unix) | |
| if: matrix.platform != 'Windows' && matrix.platform != 'iOS' | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/Native/build | |
| run: | | |
| cmake --build . --config Release | |
| # Artifact collection | |
| - name: Create Output Directory | |
| shell: bash | |
| run: | | |
| mkdir -p runtimes/${{ matrix.rid }}/native | |
| - name: Copy Library | |
| shell: bash | |
| run: | | |
| mkdir -p runtimes/${{ matrix.rid }}/native | |
| if [ "${{ matrix.platform }}" == "Windows" ]; then | |
| cp "${{ github.workspace }}/Native/build/Release/miniaudio.dll" "runtimes/${{ matrix.rid }}/native/" | |
| elif [ "${{ matrix.platform }}" == "iOS" ]; then | |
| cp -r "${{ github.workspace }}/Native/build/Release-iphoneos/miniaudio.framework" "runtimes/${{ matrix.rid }}/native/" | |
| else | |
| cp "./Native/build/libminiaudio${{ matrix.lib_extension }}" "runtimes/${{ matrix.rid }}/native/" | |
| fi | |
| # Dependency analysis | |
| - name: Analyze Dependencies and Exports (Windows) | |
| if: matrix.platform == 'Windows' | |
| shell: powershell | |
| run: | | |
| $libPath = "runtimes/${{ matrix.rid }}/native/miniaudio.dll" | |
| Write-Host "--- Dependencies for $libPath ---" | |
| & "$env:DUMPBIN_PATH\dumpbin.exe" /DEPENDENTS "$libPath" | |
| Write-Host "--- Exports for $libPath ---" | |
| & "$env:DUMPBIN_PATH\dumpbin.exe" /EXPORTS "$libPath" | |
| - name: Analyze Dependencies and Exports (iOS) | |
| if: matrix.platform == 'iOS' | |
| shell: bash | |
| run: | | |
| LIB_PATH="runtimes/${{ matrix.rid }}/native/miniaudio.framework/miniaudio" | |
| echo "--- Dependencies for iOS ---" | |
| otool -L "$LIB_PATH" | |
| echo "--- Symbols ---" | |
| nm -g "$LIB_PATH" | grep " T " | |
| - name: Analyze Dependencies and Exports (Android) | |
| if: matrix.platform == 'Android' | |
| shell: bash | |
| run: | | |
| LIB_PATH="runtimes/${{ matrix.rid }}/native/libminiaudio.so" | |
| echo "--- Dependencies for Android ---" | |
| readelf -d "$LIB_PATH" | |
| echo "--- Symbols ---" | |
| nm -g "$LIB_PATH" | grep " T " | |
| - name: Analyze Dependencies and Exports (Linux) | |
| if: matrix.platform == 'Linux' | |
| shell: bash | |
| run: | | |
| LIB_PATH="runtimes/${{ matrix.rid }}/native/libminiaudio.so" | |
| echo "=== Library Information ===" | |
| file "$LIB_PATH" | |
| echo -e "\n=== Dependencies ===" | |
| if [[ "${{ matrix.arch }}" == "x86_64" ]]; then | |
| ldd "$LIB_PATH" || true | |
| else | |
| readelf -d "$LIB_PATH" | grep "NEEDED" || true | |
| fi | |
| echo -e "\n=== Symbols ===" | |
| if [[ "${{ matrix.arch }}" == "x86_64" || "${{ matrix.arch }}" == "aarch64" ]]; then | |
| nm -g "$LIB_PATH" | grep " T " || true | |
| else | |
| arm-linux-gnueabihf-nm -g "$LIB_PATH" | grep " T " || true | |
| fi | |
| echo -e "\n=== SONAME ===" | |
| readelf -d "$LIB_PATH" | grep "SONAME" || true | |
| - name: Analyze Dependencies and Exports (macOS) | |
| if: matrix.platform == 'macOS' | |
| shell: bash | |
| run: | | |
| LIB_PATH="runtimes/${{ matrix.rid }}/native/libminiaudio.dylib" | |
| echo "--- Dependencies for macOS ---" | |
| otool -L "$LIB_PATH" | |
| echo "--- Symbols ---" | |
| nm -g "$LIB_PATH" | grep " T " | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.rid }} | |
| path: runtimes/${{ matrix.rid }} | |
| package: | |
| needs: [build] | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create final package | |
| run: | | |
| mkdir -p runtimes | |
| cp -r artifacts/* runtimes/ | |
| zip -r native-libraries.zip runtimes | |
| - name: Upload final package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-libraries | |
| path: native-libraries.zip | |
| build_nupkg: | |
| needs: [package] | |
| runs-on: windows-latest | |
| name: Build Nuget Packages | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: List files | |
| run: ls | |
| # Install the .NET Core workload | |
| - name: Install .NET Core | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: native-libraries | |
| path: ./native-libraries | |
| - name: Install Native Libraries | |
| run: | | |
| Expand-Archive -Path "./native-libraries/native-libraries.zip" -DestinationPath "./Src/Backends/MiniAudio/" -Force | |
| - name: Build Nuget packages | |
| env: | |
| is_release: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| run: | | |
| ls | |
| pwsh -ep Bypass -c ./tools/publish-nupkg.ps1 $env:is_release | |
| - name: Upload Nuget Packages to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: out_nupkgs | |
| path: ./out/*.nupkg | |
| - name: Upload Nuget packages to GitHub registry | |
| if: ${{ github.event_name != 'pull_request' }} | |
| env: | |
| GHPKG_KEY: ${{ secrets.GHPKG_KEY }} | |
| run: | | |
| dotnet nuget add source --username HelloWRC --password $env:GHPKG_KEY --store-password-in-clear-text --name github "https://nuget.pkg.github.com/ClassIsland/index.json" | |
| dotnet nuget push .\out\*.nupkg -k $env:GHPKG_KEY --source "github" --skip-duplicate |