|
| 1 | +name: Release Binaries (NativeAOT) |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +env: |
| 9 | + DOTNET_NOLOGO: true |
| 10 | + |
| 11 | +jobs: |
| 12 | + publish-aot: |
| 13 | + name: Publish NativeAOT (${{ matrix.rid }}) |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - os: windows-latest |
| 20 | + rid: win-x64 |
| 21 | + ext: .exe |
| 22 | + - os: windows-latest |
| 23 | + rid: win-arm64 |
| 24 | + ext: .exe |
| 25 | + - os: ubuntu-latest |
| 26 | + rid: linux-x64 |
| 27 | + ext: "" |
| 28 | + - os: ubuntu-latest |
| 29 | + rid: linux-arm64 |
| 30 | + ext: "" |
| 31 | + needsCross: true |
| 32 | + - os: macos-13 |
| 33 | + rid: osx-x64 |
| 34 | + ext: "" |
| 35 | + - os: macos-latest |
| 36 | + rid: osx-arm64 |
| 37 | + ext: "" |
| 38 | + |
| 39 | + permissions: |
| 40 | + contents: write |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout code |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + |
| 48 | + - name: Setup .NET |
| 49 | + uses: actions/setup-dotnet@v4 |
| 50 | + with: |
| 51 | + dotnet-version: 10.0.x |
| 52 | + |
| 53 | + - name: Install NativeAOT prerequisites (Linux) |
| 54 | + if: runner.os == 'Linux' |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + set -euo pipefail |
| 58 | + sudo apt-get update |
| 59 | + sudo apt-get install -y clang zlib1g-dev |
| 60 | +
|
| 61 | + - name: Install cross toolchain (linux-arm64) |
| 62 | + if: runner.os == 'Linux' && matrix.needsCross |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + set -euo pipefail |
| 66 | + sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu |
| 67 | +
|
| 68 | + - name: Restore |
| 69 | + run: dotnet restore src/CodeMedic.sln |
| 70 | + |
| 71 | + - name: Publish (NativeAOT) |
| 72 | + run: >- |
| 73 | + dotnet publish src/CodeMedic/CodeMedic.csproj |
| 74 | + -c Release |
| 75 | + -r ${{ matrix.rid }} |
| 76 | + /p:PublishAot=true |
| 77 | +
|
| 78 | + - name: Prepare artifact |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + set -euo pipefail |
| 82 | + VERSION="${{ github.event.release.tag_name }}" |
| 83 | + if [ -z "$VERSION" ]; then VERSION="manual"; fi |
| 84 | +
|
| 85 | + OUTDIR="src/CodeMedic/bin/Release/net10.0/${{ matrix.rid }}/publish" |
| 86 | + BIN="$OUTDIR/CodeMedic${{ matrix.ext }}" |
| 87 | +
|
| 88 | + if [ ! -f "$BIN" ]; then |
| 89 | + echo "Expected binary not found at $BIN" |
| 90 | + echo "Publish directory contents:" |
| 91 | + ls -la "$OUTDIR" || true |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | +
|
| 95 | + mkdir -p artifacts |
| 96 | + DEST="artifacts/CodeMedic-${VERSION}-${{ matrix.rid }}${{ matrix.ext }}" |
| 97 | + cp "$BIN" "$DEST" |
| 98 | +
|
| 99 | + - name: Generate checksums (SHA-256) |
| 100 | + shell: pwsh |
| 101 | + run: | |
| 102 | + $ErrorActionPreference = 'Stop' |
| 103 | +
|
| 104 | + $files = Get-ChildItem -LiteralPath 'artifacts' -File | Where-Object { $_.Name -notmatch '\.sha256$' } |
| 105 | + if (-not $files -or $files.Count -eq 0) { |
| 106 | + throw 'No artifacts found to checksum.' |
| 107 | + } |
| 108 | +
|
| 109 | + foreach ($file in $files) { |
| 110 | + $hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $file.FullName).Hash.ToLowerInvariant() |
| 111 | + $line = "$hash $($file.Name)" |
| 112 | + $checksumPath = "$($file.FullName).sha256" |
| 113 | + $line | Out-File -FilePath $checksumPath -Encoding ascii |
| 114 | + } |
| 115 | +
|
| 116 | + - name: Upload workflow artifact |
| 117 | + uses: actions/upload-artifact@v4 |
| 118 | + with: |
| 119 | + name: CodeMedic-${{ matrix.rid }} |
| 120 | + path: artifacts/* |
| 121 | + |
| 122 | + - name: Attach binaries to GitHub Release |
| 123 | + if: github.event_name == 'release' |
| 124 | + uses: softprops/action-gh-release@v2 |
| 125 | + with: |
| 126 | + files: artifacts/* |
0 commit comments