mirror of https://github.com/mono/CppSharp.git
c-sharpdotnetmonobindingsbridgecclangcpluspluscppsharpglueinteropparserparsingpinvokeswigsyntax-treevisitorsxamarinxamarin-bindings
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
189 lines
6.4 KiB
189 lines
6.4 KiB
name: CI |
|
|
|
on: [push, pull_request, workflow_dispatch] |
|
|
|
# Cancel any previous workflows if the pull request was updated |
|
concurrency: |
|
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
|
cancel-in-progress: true |
|
|
|
jobs: |
|
build: |
|
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
|
strategy: |
|
fail-fast: false |
|
matrix: |
|
os: [ubuntu-22.04, windows-2022] |
|
platform: [x64] |
|
build-cfg: [Debug, DebugOpt, Release] |
|
include: |
|
- os: windows-2022 |
|
platform: x64 |
|
build-cfg: Debug |
|
|
|
runs-on: ${{ matrix.os }} |
|
|
|
env: |
|
CC: ${{ startsWith(matrix.os, 'ubuntu') && 'gcc-11' || 'clang' }} |
|
CXX: ${{ startsWith(matrix.os, 'ubuntu') && 'g++-11' || 'clang++' }} |
|
VS_VERSION: "Program Files/Microsoft Visual Studio/2022" |
|
PLATFORM: ${{ matrix.platform }} |
|
BUILD_CONFIGURATION: ${{ matrix.build-cfg }} |
|
DOTNET_NOLOGO: true |
|
DOTNET_CLI_TELEMETRY_OPTOUT: true |
|
EMSCRIPTEN_VERSION: 3.1.65 |
|
|
|
steps: |
|
- uses: actions/checkout@v4 |
|
with: |
|
fetch-depth: 0 |
|
|
|
- name: Free Disk Space |
|
if: startsWith(matrix.os, 'ubuntu') |
|
uses: endersonmenezes/free-disk-space@v2 |
|
with: |
|
remove_android: true |
|
remove_haskell: true |
|
remove_tool_cache: true |
|
remove_swap: true |
|
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*" |
|
remove_packages_one_command: true |
|
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle" |
|
testing: false |
|
|
|
- name: Free Disk Space |
|
if: startsWith(matrix.os, 'macos') |
|
run: | |
|
sudo rm -rf /Library/Frameworks/Mono.framework |
|
sudo rm -rf /Library/Frameworks/Xamarin.iOS.framework |
|
sudo rm -rf /Library/Frameworks/Xamarin.Android.framework |
|
sudo rm -rf /Users/runner/Library/Android |
|
sudo rm -rf /usr/local/share/powershell |
|
sudo find /Applications -type d -name "Xcode_*.app" ! -name "Xcode_$XCODE_VERSION.app" -prune -exec rm -rf "{}" \; |
|
- run: df -h |
|
|
|
- name: Setup emsdk |
|
uses: pyodide/setup-emsdk@v15 |
|
with: |
|
version: ${{ env.EMSCRIPTEN_VERSION }} |
|
actions-cache-folder: emsdk-cache-${{ runner.os }} |
|
|
|
- name: Setup cmake |
|
uses: jwlawson/actions-setup-cmake@v2 |
|
with: |
|
cmake-version: '3.30.x' |
|
|
|
- name: Install nbgv |
|
if: startsWith(matrix.os, 'macos') |
|
run: | |
|
dotnet tool install -g nbgv |
|
|
|
- name: Set version |
|
run: nbgv cloud --all-vars |
|
|
|
- name: Environment |
|
if: startsWith(matrix.os, 'windows') |
|
shell: bash |
|
run: echo "/c/$VS_VERSION/Enterprise/MSBuild/Current/Bin" >> $GITHUB_PATH |
|
|
|
- name: Setup |
|
shell: bash |
|
run: | |
|
build/build.sh generate -platform $PLATFORM -configuration $BUILD_CONFIGURATION |
|
build/build.sh download_llvm -platform $PLATFORM -configuration $BUILD_CONFIGURATION |
|
|
|
- name: Restore |
|
shell: bash |
|
run: build/build.sh restore -platform $PLATFORM -configuration $BUILD_CONFIGURATION |
|
|
|
- name: Build |
|
shell: bash |
|
run: build/build.sh -platform $PLATFORM -build_only -configuration $BUILD_CONFIGURATION |
|
|
|
- name: Test (.NET) |
|
# Disable test for debug configs, since they take over 6 hours to complete |
|
if: matrix.build-cfg != 'Debug' |
|
shell: bash |
|
run: build/test.sh -platform $PLATFORM -configuration $BUILD_CONFIGURATION |
|
|
|
- name: Build (QuickJS runtime) |
|
if: runner.os != 'Windows' |
|
shell: bash |
|
run: tests/quickjs/bootstrap.sh |
|
|
|
- name: Test (QuickJS) |
|
if: runner.os != 'Windows' |
|
shell: bash |
|
run: tests/quickjs/test.sh --dotnet-config $BUILD_CONFIGURATION |
|
|
|
- name: Test (Emscripten) |
|
if: runner.os != 'Windows' |
|
shell: bash |
|
run: tests/emscripten/test.sh --dotnet-config $BUILD_CONFIGURATION |
|
|
|
- name: Pack |
|
if: matrix.build-cfg == 'Release' |
|
shell: bash |
|
run: build/build.sh prepack -platform $PLATFORM -configuration $BUILD_CONFIGURATION |
|
|
|
- name: Upload Artifacts |
|
# We only need a release version of this in the create_package job |
|
if: matrix.build-cfg == 'Release' |
|
uses: actions/upload-artifact@v4 |
|
with: |
|
name: intermediate-${{ matrix.build-cfg }}-${{ matrix.platform }} |
|
retention-days: 7 |
|
overwrite: true |
|
path: | |
|
artifacts |
|
include/**/*.h |
|
|
|
create_package: |
|
runs-on: windows-2022 |
|
needs: build |
|
if: | |
|
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || contains(github.ref, 'nuget') || startsWith(github.ref, 'refs/tags/v'))) || |
|
(github.event.pull_request.head.repo.full_name != github.repository && (contains(github.event.pull_request.head.ref, 'nuget') || startsWith(github.event.pull_request.head.ref, 'refs/tags/v'))) |
|
|
|
env: |
|
DOTNET_NOLOGO: true |
|
DOTNET_CLI_TELEMETRY_OPTOUT: true |
|
BUILD_CONFIGURATION: Release |
|
|
|
steps: |
|
- uses: actions/checkout@v4 |
|
with: |
|
fetch-depth: 0 |
|
|
|
- name: Set version |
|
run: nbgv cloud --all-vars |
|
|
|
- uses: actions/download-artifact@v4 |
|
with: |
|
name: intermediate-Release-x64 |
|
|
|
- name: Setup |
|
shell: bash |
|
run: build/build.sh generate_config -configuration $BUILD_CONFIGURATION |
|
|
|
- name: Create package |
|
shell: bash |
|
run: build/build.sh pack -configuration $BUILD_CONFIGURATION |
|
|
|
- name: Upload package |
|
uses: actions/upload-artifact@v4 |
|
with: |
|
name: CppSharp.nupkg |
|
path: | |
|
artifacts/*.nupkg |
|
|
|
- name: Upload package to GitHub Packages |
|
run: | |
|
cd artifacts |
|
dotnet nuget push "*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/mono/index.json" --skip-duplicate |
|
|
|
- name: Publish package to nuget.org |
|
if: startsWith(github.ref, 'refs/tags/v') |
|
run: | |
|
cd artifacts |
|
dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json" --skip-duplicate
|
|
|