Add architecture support to build scripts and CI #779
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: GitHub CI | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| workflow_dispatch: | |
| jobs: | |
| build-native: | |
| name: 💾 Build ${{matrix.task.title}} for ${{matrix.task.os}} (${{matrix.task.arch}}) | |
| runs-on: ${{matrix.task.os}} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| task: | |
| - { title: FastText, projectName: LanguageIdentification.FastText, os: windows-2022, arch: x86_64, script: ./Scripts/run-build.ps1, artifact: fasttext.x86_64.dll } | |
| - { title: FastText, projectName: LanguageIdentification.FastText, os: windows-11-arm, arch: arm64, script: ./Scripts/run-build.ps1, artifact: fasttext.arm64.dll } | |
| - { title: FastText, projectName: LanguageIdentification.FastText, os: macos-15-intel, arch: x86_64, script: ./Scripts/run-build.macos.sh, artifact: libfasttext.x86_64.dylib } | |
| - { title: FastText, projectName: LanguageIdentification.FastText, os: macos-14, arch: arm64, script: ./Scripts/run-build.macos.sh, artifact: libfasttext.arm64.dylib } | |
| - { title: FastText, projectName: LanguageIdentification.FastText, os: ubuntu-22.04, arch: x86_64, script: ./Scripts/run-build.sh, artifact: libfasttext.x86_64.so } | |
| - { title: FastText, projectName: LanguageIdentification.FastText, os: ubuntu-22.04-arm, arch: arm64, script: ./Scripts/run-build.sh, artifact: libfasttext.arm64.so } | |
| - { title: CLD2, projectName: LanguageIdentification.CLD2, os: windows-2022, arch: x86_64, script: ./Scripts/run-build.ps1, artifact: libcld2.x86_64.dll } | |
| - { title: CLD2, projectName: LanguageIdentification.CLD2, os: windows-11-arm, arch: arm64, script: ./Scripts/run-build.ps1, artifact: libcld2.arm64.dll } | |
| - { title: CLD2, projectName: LanguageIdentification.CLD2, os: macos-15-intel, arch: x86_64, script: ./Scripts/run-build.macos.sh, artifact: libcld2.x86_64.dylib } | |
| - { title: CLD2, projectName: LanguageIdentification.CLD2, os: macos-14, arch: arm64, script: ./Scripts/run-build.macos.sh, artifact: libcld2.arm64.dylib } | |
| - { title: CLD2, projectName: LanguageIdentification.CLD2, os: ubuntu-22.04, arch: x86_64, script: ./Scripts/run-build.sh, artifact: libcld2.x86_64.so } | |
| - { title: CLD2, projectName: LanguageIdentification.CLD2, os: ubuntu-22.04-arm, arch: arm64, script: ./Scripts/run-build.sh, artifact: libcld2.arm64.so } | |
| - { title: CLD3, projectName: LanguageIdentification.CLD3, os: windows-2022, arch: x86_64, script: ./Scripts/run-build.ps1, artifact: libcld3.x86_64.dll } | |
| - { title: CLD3, projectName: LanguageIdentification.CLD3, os: windows-11-arm, arch: arm64, script: ./Scripts/run-build.ps1, artifact: libcld3.arm64.dll } | |
| - { title: CLD3, projectName: LanguageIdentification.CLD3, os: macos-15-intel, arch: x86_64, script: ./Scripts/run-build.macos.sh, artifact: libcld3.x86_64.dylib } | |
| - { title: CLD3, projectName: LanguageIdentification.CLD3, os: macos-14, arch: arm64, script: ./Scripts/run-build.macos.sh, artifact: libcld3.arm64.dylib } | |
| - { title: CLD3, projectName: LanguageIdentification.CLD3, os: ubuntu-22.04, arch: x86_64, script: ./Scripts/run-build.sh, artifact: libcld3.x86_64.so } | |
| - { title: CLD3, projectName: LanguageIdentification.CLD3, os: ubuntu-22.04-arm, arch: arm64, script: ./Scripts/run-build.sh, artifact: libcld3.arm64.so } | |
| - { title: Lingua, projectName: LanguageIdentification.Lingua, os: windows-2022, arch: x86_64, script: ./Scripts/run-build.ps1, artifact: lingua.x86_64.dll } | |
| - { title: Lingua, projectName: LanguageIdentification.Lingua, os: windows-11-arm, arch: arm64, script: ./Scripts/run-build.ps1, artifact: lingua.arm64.dll } | |
| - { title: Lingua, projectName: LanguageIdentification.Lingua, os: macos-15-intel, arch: x86_64, script: ./Scripts/run-build.macos.sh, artifact: liblingua.x86_64.dylib } | |
| - { title: Lingua, projectName: LanguageIdentification.Lingua, os: macos-14, arch: arm64, script: ./Scripts/run-build.macos.sh, artifact: liblingua.arm64.dylib } | |
| - { title: Lingua, projectName: LanguageIdentification.Lingua, os: ubuntu-22.04, arch: x86_64, script: ./Scripts/run-build.sh, artifact: liblingua.x86_64.so } | |
| - { title: Lingua, projectName: LanguageIdentification.Lingua, os: ubuntu-22.04-arm, arch: arm64, script: ./Scripts/run-build.sh, artifact: liblingua.arm64.so } | |
| - { title: Whatlang, projectName: LanguageIdentification.Whatlang, os: windows-2022, arch: x86_64, script: ./Scripts/run-build.ps1, artifact: whatlang.x86_64.dll } | |
| - { title: Whatlang, projectName: LanguageIdentification.Whatlang, os: windows-11-arm, arch: arm64, script: ./Scripts/run-build.ps1, artifact: whatlang.arm64.dll } | |
| - { title: Whatlang, projectName: LanguageIdentification.Whatlang, os: macos-15-intel, arch: x86_64, script: ./Scripts/run-build.macos.sh, artifact: libwhatlang.x86_64.dylib } | |
| - { title: Whatlang, projectName: LanguageIdentification.Whatlang, os: macos-14, arch: arm64, script: ./Scripts/run-build.macos.sh, artifact: libwhatlang.arm64.dylib } | |
| - { title: Whatlang, projectName: LanguageIdentification.Whatlang, os: ubuntu-22.04, arch: x86_64, script: ./Scripts/run-build.sh, artifact: libwhatlang.x86_64.so } | |
| - { title: Whatlang, projectName: LanguageIdentification.Whatlang, os: ubuntu-22.04-arm, arch: arm64, script: ./Scripts/run-build.sh, artifact: libwhatlang.arm64.so } | |
| - { title: MediaPipe, projectName: LanguageIdentification.MediaPipe, os: windows-2022, arch: x86_64, script: ./Scripts/run-build.ps1, artifact: mediapipe_language_detector.x86_64.dll } | |
| - { title: MediaPipe, projectName: LanguageIdentification.MediaPipe, os: windows-11-arm, arch: arm64, script: ./Scripts/run-build.ps1, artifact: mediapipe_language_detector.arm64.dll } | |
| - { title: MediaPipe, projectName: LanguageIdentification.MediaPipe, os: macos-15-intel, arch: x86_64, script: ./Scripts/run-build.macos.sh, artifact: libmediapipe_language_detector.x86_64.dylib } | |
| - { title: MediaPipe, projectName: LanguageIdentification.MediaPipe, os: macos-14, arch: arm64, script: ./Scripts/run-build.macos.sh, artifact: libmediapipe_language_detector.arm64.dylib } | |
| - { title: MediaPipe, projectName: LanguageIdentification.MediaPipe, os: ubuntu-22.04, arch: x86_64, script: ./Scripts/run-build.sh, artifact: libmediapipe_language_detector.x86_64.so } | |
| - { title: MediaPipe, projectName: LanguageIdentification.MediaPipe, os: ubuntu-22.04-arm, arch: arm64, script: ./Scripts/run-build.sh, artifact: libmediapipe_language_detector.arm64.so } | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| ROOT: ./src | |
| NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - uses: dorny/paths-filter@v3 | |
| id: changes | |
| with: | |
| filters: | | |
| src: | |
| - '${{env.ROOT}}/${{matrix.task.projectName}}/**' | |
| - uses: dorny/paths-filter@v3 | |
| id: changes-native | |
| with: | |
| filters: | | |
| src: | |
| - '${{env.ROOT}}/${{matrix.task.projectName}}.Native/**' | |
| - name: 🚀 Build ${{matrix.task.projectName}}.Native | |
| if: steps.changes.outputs.src == 'true' || steps.changes-native.outputs.src == 'true' | |
| working-directory: ${{env.ROOT}}/${{matrix.task.projectName}}.Native | |
| run: | | |
| echo $(pwd) | |
| git update-index --chmod=+x ${{matrix.task.script}} | |
| chmod +x ${{matrix.task.script}} | |
| ${{matrix.task.script}} ${{matrix.task.arch}} | |
| - uses: actions/upload-artifact@v4 | |
| if: steps.changes.outputs.src == 'true' || steps.changes-native.outputs.src == 'true' | |
| with: | |
| name: native-${{matrix.task.projectName}}.Native-${{matrix.task.os}} | |
| path: ${{env.ROOT}}/${{matrix.task.projectName}}.Native/${{matrix.task.artifact}} | |
| retention-days: 1 | |
| overwrite: 'true' | |
| compression-level: 0 | |
| if-no-files-found: 'error' | |
| build-package: | |
| name: 🚀 Pack ${{matrix.task.title}} | |
| runs-on: ${{matrix.task.os}} | |
| needs: build-native | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| task: | |
| - { title: CLD2, projectName: LanguageIdentification.CLD2, os: ubuntu-22.04 } | |
| - { title: CLD3, projectName: LanguageIdentification.CLD3, os: ubuntu-22.04 } | |
| - { title: FastText, projectName: LanguageIdentification.FastText, os: ubuntu-22.04 } | |
| - { title: Whatlang, projectName: LanguageIdentification.Whatlang, os: ubuntu-22.04 } | |
| - { title: MediaPipe, projectName: LanguageIdentification.MediaPipe, os: ubuntu-22.04 } | |
| - { title: Lingua, projectName: LanguageIdentification.Lingua, os: ubuntu-22.04 } | |
| - { title: LanguageCode, projectName: LanguageCode, os: ubuntu-22.04 } | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| ROOT: ./src | |
| NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: native-${{matrix.task.projectName}}.Native-* | |
| merge-multiple: true | |
| path: ${{env.ROOT}}/${{matrix.task.projectName}}.Native/ | |
| - uses: dorny/paths-filter@v3 | |
| id: changes | |
| with: | |
| filters: | | |
| src: | |
| - '${{env.ROOT}}/${{matrix.task.projectName}}/**' | |
| - uses: dorny/paths-filter@v3 | |
| id: changes-native | |
| with: | |
| filters: | | |
| src: | |
| - '${{env.ROOT}}/${{matrix.task.projectName}}.Native/**' | |
| - name: 📂 Setup .NET Core | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 6.0.x | |
| 7.0.x | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| source-url: https://nuget.pkg.github.com/${{github.repository_owner}}/index.json | |
| - name: 🚀 Pack ${{matrix.task.projectName}}.Native | |
| if: steps.changes-native.outputs.src == 'true' | |
| working-directory: ${{env.ROOT}}/${{matrix.task.projectName}}.Native | |
| run: dotnet pack -c Release -o out | |
| - name: 🚀 Pack ${{matrix.task.projectName}} | |
| if: steps.changes.outputs.src == 'true' | |
| working-directory: ${{env.ROOT}}/${{matrix.task.projectName}} | |
| run: dotnet pack -c Release -o out | |
| - uses: actions/upload-artifact@v4 | |
| if: steps.changes-native.outputs.src == 'true' | |
| with: | |
| name: build-${{matrix.task.projectName}}.Native | |
| path: ${{env.ROOT}}/${{matrix.task.projectName}}.Native/out | |
| retention-days: 1 | |
| overwrite: 'true' | |
| compression-level: 0 | |
| - uses: actions/upload-artifact@v4 | |
| if: steps.changes.outputs.src == 'true' | |
| with: | |
| name: build-${{matrix.task.projectName}} | |
| path: ${{env.ROOT}}/${{matrix.task.projectName}}/out | |
| retention-days: 1 | |
| overwrite: 'true' | |
| compression-level: 0 | |
| test-package: | |
| name: 🧪 Test on ${{matrix.task.os}} and .NET ${{matrix.runtime.version}} | |
| runs-on: ${{matrix.task.os}} | |
| needs: build-package | |
| strategy: | |
| fail-fast: false | |
| # Available runners: | |
| # https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#standard-github-hosted-runners-for--private-repositories | |
| matrix: | |
| task: | |
| # - { os: ubuntu-20.04 } | |
| - { os: ubuntu-22.04 } | |
| - { os: ubuntu-24.04 } | |
| - { os: ubuntu-22.04-arm } | |
| - { os: ubuntu-24.04-arm } | |
| - { os: windows-2022 } | |
| - { os: windows-2025 } | |
| - { os: windows-11-arm } | |
| - { os: macos-15-intel } | |
| - { os: macos-14 } | |
| - { os: macos-15 } | |
| runtime: | |
| - { version: 6.0.x, target: net6.0 } | |
| - { version: 7.0.x, target: net7.0 } | |
| - { version: 8.0.x, target: net8.0 } | |
| - { version: 9.0.x, target: net9.0 } | |
| - { version: 10.0.x, target: net10.0 } | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| ROOT: ./src | |
| NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| PANLINGO_TARGET_FRAMEWORK: ${{ matrix.runtime.target }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: 📂 Files | |
| working-directory: ${{env.ROOT}} | |
| run: mkdir -p local-packages | |
| - name: 📂 Setup .NET Core | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{matrix.runtime.version}} | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: build-* | |
| merge-multiple: true | |
| path: ${{env.ROOT}}/local-packages | |
| - name: 📂 Files | |
| working-directory: ${{env.ROOT}}/local-packages | |
| run: ls -R | |
| - name: 📂 Use local NuGet (Linux) | |
| if: ${{ startsWith(matrix.task.os, 'ubuntu') }} | |
| run: | | |
| path=$(realpath "${{env.ROOT}}/local-packages") | |
| dotnet nuget add source $path | |
| - name: 📂 Use local NuGet (Windows) | |
| if: ${{ startsWith(matrix.task.os, 'windows') }} | |
| run: | | |
| $path = [System.IO.Path]::GetFullPath('${{env.ROOT}}/local-packages') | |
| dotnet nuget add source $path | |
| - name: 📂 Use local NuGet (OSX) | |
| if: ${{ startsWith(matrix.task.os, 'macos') }} | |
| run: | | |
| path=$(realpath "${{env.ROOT}}/local-packages") | |
| dotnet nuget add source $path | |
| - name: 🧪 Run Tests for LanguageIdentification | |
| working-directory: ${{env.ROOT}}/LanguageIdentification.Tests | |
| run: dotnet test -c CI --blame-crash | |
| - name: 🧪 Run Tests for LanguageCode | |
| working-directory: ${{env.ROOT}}/LanguageCode.Tests | |
| run: dotnet test -c CI --blame-crash | |
| deploy-package: | |
| name: 🚚 Push ${{matrix.projectName}} | |
| runs-on: ubuntu-24.04 | |
| needs: test-package | |
| if: github.ref == 'refs/heads/master' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| projectName: | |
| - LanguageIdentification.CLD2.Native | |
| - LanguageIdentification.CLD2 | |
| - LanguageIdentification.CLD3.Native | |
| - LanguageIdentification.CLD3 | |
| - LanguageIdentification.FastText.Native | |
| - LanguageIdentification.FastText | |
| - LanguageIdentification.Whatlang.Native | |
| - LanguageIdentification.Whatlang | |
| - LanguageIdentification.MediaPipe.Native | |
| - LanguageIdentification.MediaPipe | |
| - LanguageIdentification.Lingua.Native | |
| - LanguageIdentification.Lingua | |
| - LanguageCode | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| ROOT: ./src | |
| NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| MICROSOFT_NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_WRITE_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: changes | |
| with: | |
| filters: | | |
| src: | |
| - '${{env.ROOT}}/${{matrix.projectName}}/**' | |
| - uses: actions/download-artifact@v4 | |
| if: steps.changes.outputs.src == 'true' | |
| with: | |
| pattern: build-${{matrix.projectName}} | |
| path: ${{env.ROOT}}/${{matrix.projectName}}/out | |
| - name: 📂 Setup .NET Core | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| source-url: https://nuget.pkg.github.com/${{github.repository_owner}}/index.json | |
| - name: 📂 Files | |
| working-directory: ${{env.ROOT}} | |
| run: ls -R | |
| - name: 🚚 [GitHub] Push ${{matrix.projectName}} to registry | |
| if: steps.changes.outputs.src == 'true' | |
| working-directory: ${{env.ROOT}}/${{matrix.projectName}} | |
| run: | | |
| dotnet nuget push ./out/**/*.nupkg \ | |
| --skip-duplicate -k ${{env.NUGET_AUTH_TOKEN}} \ | |
| --source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json | |
| - name: 🚚 [Microsoft] Push ${{matrix.projectName}} to registry | |
| if: steps.changes.outputs.src == 'true' | |
| working-directory: ${{env.ROOT}}/${{matrix.projectName}} | |
| run: | | |
| dotnet nuget push ./out/**/*.nupkg \ | |
| --skip-duplicate -k ${{env.MICROSOFT_NUGET_AUTH_TOKEN}} \ | |
| --source https://api.nuget.org/v3/index.json | |
| - uses: geekyeggo/delete-artifact@v5 | |
| if: steps.changes.outputs.src == 'true' | |
| with: | |
| name: build-${{matrix.projectName}} |