|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + packages: write |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 17 | + |
| 18 | +env: |
| 19 | + DOTNET_NOLOGO: 'true' |
| 20 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 'true' |
| 21 | + DOTNET_CLI_TELEMETRY_OPTOUT: 'true' |
| 22 | + |
| 23 | +jobs: |
| 24 | + # Native binaries for the Linux and Windows RIDs, plus the runtime.liblouis metapackage. |
| 25 | + # Everything happens inside the container so a local ./build.sh produces identical packages. |
| 26 | + native-linux: |
| 27 | + name: native (linux + windows RIDs) |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Cross-compile and pack |
| 33 | + env: |
| 34 | + DOCKER_BUILDKIT: '1' |
| 35 | + run: ./build.sh |
| 36 | + |
| 37 | + - uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: packages-native-linux |
| 40 | + path: packages/*.nupkg |
| 41 | + if-no-files-found: error |
| 42 | + |
| 43 | + # Native binaries for the macOS RIDs. Needs a macOS host, so it cannot go in the container. |
| 44 | + native-macos: |
| 45 | + name: native (macOS RIDs) |
| 46 | + runs-on: macos-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - uses: actions/setup-dotnet@v4 |
| 51 | + with: |
| 52 | + dotnet-version: '8.0.x' |
| 53 | + |
| 54 | + - name: Build and pack |
| 55 | + run: sh ./build/build_runtime_macos_packages.sh |
| 56 | + |
| 57 | + - uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: packages-native-macos |
| 60 | + path: packages/*.nupkg |
| 61 | + if-no-files-found: error |
| 62 | + |
| 63 | + # The end-to-end check that runtime package selection actually works. |
| 64 | + # |
| 65 | + # The test project reaches runtime.liblouis through a project reference to LibLouis.NET, so |
| 66 | + # restore pulls in all eight per-RID packages from the local feed. Each runner then has to resolve |
| 67 | + # the one native binary matching the RID it is running on before any P/Invoke can succeed. A |
| 68 | + # mistake in the package layout or in the metapackage dependencies shows up here as a failing |
| 69 | + # test rather than in a consumer's application. |
| 70 | + test: |
| 71 | + name: test (${{ matrix.os }}) |
| 72 | + needs: [native-linux, native-macos] |
| 73 | + runs-on: ${{ matrix.os }} |
| 74 | + strategy: |
| 75 | + fail-fast: false |
| 76 | + matrix: |
| 77 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v4 |
| 80 | + |
| 81 | + - uses: actions/setup-dotnet@v4 |
| 82 | + with: |
| 83 | + dotnet-version: '8.0.x' |
| 84 | + |
| 85 | + - name: Collect runtime packages into a local feed |
| 86 | + uses: actions/download-artifact@v4 |
| 87 | + with: |
| 88 | + pattern: packages-native-* |
| 89 | + merge-multiple: true |
| 90 | + path: local-feed |
| 91 | + |
| 92 | + # The da-dk test tables `include` general tables such as braille-patterns.cti that ship in the |
| 93 | + # upstream release, so they have to be staged into LibLouis.NET.Tables before the tests run. |
| 94 | + # |
| 95 | + # shell: bash rather than the default, so this also works on the Windows runner, where the |
| 96 | + # default shell is PowerShell and `sh` is not on PATH. GitHub maps bash to Git Bash. |
| 97 | + - name: Stage upstream tables |
| 98 | + shell: bash |
| 99 | + run: ./build/stage_tables.sh |
| 100 | + |
| 101 | + - name: Test |
| 102 | + run: > |
| 103 | + dotnet test LibLouis.NET.Test/LibLouis.NET.Test.csproj |
| 104 | + --configuration Release |
| 105 | + -p:RestoreAdditionalProjectSources=${{ github.workspace }}/local-feed |
| 106 | +
|
| 107 | + # Managed packages. Split from native-linux because building LibLouis.NET resolves |
| 108 | + # runtime.liblouis, which depends on the macOS packages the container cannot produce. |
| 109 | + managed: |
| 110 | + name: managed packages |
| 111 | + needs: [native-linux, native-macos] |
| 112 | + runs-on: ubuntu-latest |
| 113 | + steps: |
| 114 | + - uses: actions/checkout@v4 |
| 115 | + |
| 116 | + - uses: actions/setup-dotnet@v4 |
| 117 | + with: |
| 118 | + dotnet-version: '8.0.x' |
| 119 | + |
| 120 | + - name: Collect runtime packages into a local feed |
| 121 | + uses: actions/download-artifact@v4 |
| 122 | + with: |
| 123 | + pattern: packages-native-* |
| 124 | + merge-multiple: true |
| 125 | + path: local-feed |
| 126 | + |
| 127 | + - name: Build and pack |
| 128 | + env: |
| 129 | + NUGET_LOCAL_FEED: ${{ github.workspace }}/local-feed |
| 130 | + # The test job already covers this, on three operating systems. |
| 131 | + SKIP_TESTS: '1' |
| 132 | + run: sh ./build/build_managed_packages.sh |
| 133 | + |
| 134 | + - uses: actions/upload-artifact@v4 |
| 135 | + with: |
| 136 | + name: packages-managed |
| 137 | + path: packages/*.nupkg |
| 138 | + if-no-files-found: error |
| 139 | + |
| 140 | + # Publishing is gated on a tag, so every push and pull request gets built and tested without |
| 141 | + # anything reaching the feed. |
| 142 | + # |
| 143 | + # Note that the repository carries two independent version streams: the runtime packages are |
| 144 | + # versioned after the upstream liblouis release (Directory.Build.props), while LibLouis.NET has |
| 145 | + # its own version. A tag therefore does not correspond to a single package version, and |
| 146 | + # --skip-duplicate makes re-pushing an unchanged runtime package a no-op. |
| 147 | + publish: |
| 148 | + name: publish to GitHub Packages |
| 149 | + if: startsWith(github.ref, 'refs/tags/v') |
| 150 | + needs: [native-linux, native-macos, test, managed] |
| 151 | + runs-on: ubuntu-latest |
| 152 | + steps: |
| 153 | + - uses: actions/setup-dotnet@v4 |
| 154 | + with: |
| 155 | + dotnet-version: '8.0.x' |
| 156 | + |
| 157 | + - uses: actions/download-artifact@v4 |
| 158 | + with: |
| 159 | + pattern: packages-* |
| 160 | + merge-multiple: true |
| 161 | + path: packages |
| 162 | + |
| 163 | + - name: Push |
| 164 | + run: > |
| 165 | + dotnet nuget push "packages/*.nupkg" |
| 166 | + --source https://nuget.pkg.github.com/Notalib/index.json |
| 167 | + --api-key ${{ secrets.GITHUB_TOKEN }} |
| 168 | + --skip-duplicate |
0 commit comments