Skip to content

Cross-platform support #386

Cross-platform support

Cross-platform support #386

Workflow file for this run

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}}
runs-on: ${{matrix.task.os}}
strategy:
fail-fast: false
matrix:
task:
- { title: FastText, projectName: LanguageIdentification.FastText.Native, os: windows-latest, arch: x86_64, script: ./Scripts/run-build.ps1, artifact: fasttext.dll }
- { title: FastText, projectName: LanguageIdentification.FastText.Native, os: macos-14, arch: arm64, script: ./Scripts/run-build.macos.sh, artifact: libfasttext.arm64.dylib }
- { title: FastText, projectName: LanguageIdentification.FastText.Native, os: macos-13, arch: x86_64, script: ./Scripts/run-build.macos.sh, artifact: libfasttext.x86_64.dylib }
permissions:
contents: read
packages: write
env:
ROOT: ./src
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- 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}}
if: steps.changes.outputs.src == 'true'
working-directory: ${{env.ROOT}}/${{matrix.task.projectName}}
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'
with:
name: build-${{matrix.task.projectName}}-${{matrix.task.os}}
path: ${{env.ROOT}}/${{matrix.task.projectName}}/${{matrix.task.artifact}}
retention-days: 1
overwrite: 'true'
compression-level: 0
if-no-files-found: 'error'
build-nugets:
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-latest }
- { title: CLD3, projectName: LanguageIdentification.CLD3, os: ubuntu-latest }
- { title: FastText, projectName: LanguageIdentification.FastText, os: ubuntu-latest }
# - { title: Whatlang, projectName: LanguageIdentification.Whatlang, os: ubuntu-latest }
# - { title: MediaPipe, projectName: LanguageIdentification.MediaPipe, os: ubuntu-latest }
# - { title: Lingua, projectName: LanguageIdentification.Lingua, os: ubuntu-latest }
# - { title: LanguageCode, projectName: LanguageCode, os: ubuntu-latest }
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: build-${{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: |
5.0.x
6.0.x
7.0.x
8.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-nugets-linux:
name: 🧪 Test on Linux
runs-on: ubuntu-latest
needs: build-nugets
permissions:
contents: read
packages: write
env:
ROOT: ./src
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- uses: actions/checkout@v4
- name: 📂 Files
working-directory: ${{env.ROOT}}
run: mkdir -p local-nugets
- uses: actions/download-artifact@v4
with:
pattern: build-*
merge-multiple: true
path: ${{env.ROOT}}/local-nugets
- name: 📂 Files
working-directory: ${{env.ROOT}}
run: ls -R
- name: 📂 Build Docker Image
working-directory: ${{env.ROOT}}
run: |
docker build -f ./test.Dockerfile -t langunage-identification-test-runner:latest .
docker build -f ./test-ci.Dockerfile -t langunage-identification-test-runner-ci:latest .
test-nugets-windows:
name: 🧪 Test on Windows
runs-on: windows-latest
needs: build-nugets
permissions:
contents: read
packages: write
env:
ROOT: ./src
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- uses: actions/checkout@v4
- name: 📂 Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
5.0.x
6.0.x
7.0.x
8.0.x
source-url: https://nuget.pkg.github.com/${{github.repository_owner}}/index.json
- name: 📂 Files
run: mkdir -p ${{env.ROOT}}/local-nugets
- uses: actions/download-artifact@v4
with:
pattern: build-*
merge-multiple: true
path: ${{env.ROOT}}/local-nugets
- name: 📂 Files
working-directory: ${{env.ROOT}}
run: ls -R
- name: 📂 Use local NuGet
run: |
$path = [System.IO.Path]::GetFullPath('${{env.ROOT}}/local-nugets')
dotnet nuget add source $path
- name: 📂 Download pretrained models
run: |
mkdir /models
Invoke-WebRequest -OutFile /models/fasttext176.bin https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin
Invoke-WebRequest -OutFile /models/mediapipe_language_detector.tflite https://storage.googleapis.com/mediapipe-models/language_detector/language_detector/float32/1/language_detector.tflite
- name: 🧪 Run Tests for LanguageIdentification
working-directory: ${{env.ROOT}}/LanguageIdentification.Tests
run: dotnet test -c CI
- name: 🧪 Run Tests for LanguageCode
working-directory: ${{env.ROOT}}/LanguageCode.Tests
run: dotnet test -c CI
test-nugets-macos:
name: 🧪 Test on macOS
runs-on: |
- macos-latest
- macos-12
needs: build-nugets
permissions:
contents: read
packages: write
env:
ROOT: ./src
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- uses: actions/checkout@v4
- name: 📂 Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
5.0.x
6.0.x
7.0.x
8.0.x
source-url: https://nuget.pkg.github.com/${{github.repository_owner}}/index.json
- name: 📂 Files
run: mkdir -p ${{env.ROOT}}/local-nugets
- uses: actions/download-artifact@v4
with:
pattern: build-*
merge-multiple: true
path: ${{env.ROOT}}/local-nugets
- name: 📂 Files
working-directory: ${{env.ROOT}}
run: ls -R
- name: 📂 Use local NuGet
run: |
path=$(realpath "${{env.ROOT}}/local-nugets")
dotnet nuget add source $path
- name: 📂 Download pretrained models
run: |
mkdir ~/models -p
curl --location -o ~/models/fasttext176.bin https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin
curl --location -o ~/models/mediapipe_language_detector.tflite https://storage.googleapis.com/mediapipe-models/language_detector/language_detector/float32/1/language_detector.tflite
- name: 🧪 Run Tests for LanguageIdentification
working-directory: ${{env.ROOT}}/LanguageIdentification.Tests
run: dotnet test -c CI
- name: 🧪 Run Tests for LanguageCode
working-directory: ${{env.ROOT}}/LanguageCode.Tests
run: dotnet test -c CI
deploy-nugets:
name: 🚚 Push ${{matrix.projectName}}
runs-on: ubuntu-latest
needs:
- test-nugets-linux
- test-nugets-windows
- test-nugets-macos
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: |
5.0.x
6.0.x
7.0.x
8.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}}