|
1 | | -- uses: actions/download-artifact@v4 |
2 | | - with: { name: win-bits, path: . } |
3 | | -- uses: actions/download-artifact@v4 |
4 | | - with: { name: linux-bits, path: . } |
5 | | - |
6 | | -- name: Merge → single package # unzip win, unzip linux, re-zip |
7 | | - shell: pwsh |
8 | | - run: | |
9 | | - $win = Get-ChildItem win-bits\*.nupkg | Select -First 1 |
10 | | - $linux = Get-ChildItem linux-bits\*.nupkg | Select -First 1 |
11 | | - $version = ([regex]'(\d+\.\d+\.\d+)').Match($win.Name).Value |
12 | | - Expand-Archive $win.FullName -DestinationPath stage -Force |
13 | | - Expand-Archive $linux.FullName -DestinationPath stage -Force |
14 | | - Compress-Archive stage\* "Graphviz.NetWrapper.$version.nupkg" -Force |
| 1 | +# .github/workflows/ci-pack.yml |
| 2 | +name: CI-Pack |
| 3 | + |
| 4 | +on: |
| 5 | + push: { branches: [ master ] } |
| 6 | + pull_request: { branches: [ master ] } |
| 7 | + release: { types: [published] } # runs on “Publish release” button |
| 8 | + workflow_dispatch: # lets you run it by hand |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-win: |
| 12 | + uses: ./.github/workflows/build-win.yml |
| 13 | + |
| 14 | + build-linux: |
| 15 | + uses: ./.github/workflows/build-linux.yml |
| 16 | + |
| 17 | + pack: |
| 18 | + needs: [build-win, build-linux] # ← the two workflow_call jobs |
| 19 | + runs-on: windows-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + # ------------------------------------------------------------------ |
| 25 | + # 1) Download the two packages that the reusable builds uploaded |
| 26 | + # ------------------------------------------------------------------ |
| 27 | + - name: Download Windows nupkg |
| 28 | + uses: actions/download-artifact@v4 |
| 29 | + with: |
| 30 | + name: win-bits # <── matches upload name in build-win.yml |
| 31 | + path: artifacts/win |
| 32 | + |
| 33 | + - name: Download Linux nupkg |
| 34 | + uses: actions/download-artifact@v4 |
| 35 | + with: |
| 36 | + name: linux-bits # <── matches upload name in build-linux.yml |
| 37 | + path: artifacts/linux |
| 38 | + |
| 39 | + # ------------------------------------------------------------------ |
| 40 | + # 2) Merge → one multi-RID package |
| 41 | + # ------------------------------------------------------------------ |
| 42 | + - name: Merge NuGet packages |
| 43 | + shell: pwsh |
| 44 | + run: | |
| 45 | + # Locate the packages we just downloaded |
| 46 | + $winPkg = Get-ChildItem artifacts/win -Filter *.nupkg | Select -First 1 |
| 47 | + $linuxPkg = Get-ChildItem artifacts/linux -Filter *.nupkg | Select -First 1 |
| 48 | +
|
| 49 | + if (-not $winPkg) { throw "Windows package not found" } |
| 50 | + if (-not $linuxPkg) { throw "Linux package not found" } |
| 51 | +
|
| 52 | + # Extract the semantic version from the Windows package name |
| 53 | + if ($winPkg.Name -notmatch '\.(\d+\.\d+\.\d+(-[A-Za-z0-9\.-]+)?)\.nupkg$') { |
| 54 | + throw "Could not parse version from $($winPkg.Name)" |
| 55 | + } |
| 56 | + $version = $Matches[1] |
| 57 | + $outFile = "Graphviz.NetWrapper.$version.nupkg" |
| 58 | +
|
| 59 | + Write-Host "Merging packages into $outFile" |
| 60 | +
|
| 61 | + # Clean staging folder |
| 62 | + $stage = "stage" |
| 63 | + Remove-Item $stage -Force -Recurse -ErrorAction SilentlyContinue |
| 64 | + New-Item -ItemType Directory -Path $stage | Out-Null |
| 65 | +
|
| 66 | + # Unzip both packages; identical files (nuspec, [Content_Types]) are OK |
| 67 | + Expand-Archive -Path $winPkg.FullName -DestinationPath $stage -Force |
| 68 | + Expand-Archive -Path $linuxPkg.FullName -DestinationPath $stage -Force |
| 69 | +
|
| 70 | + # Re-zip into the final x-plat package |
| 71 | + Compress-Archive -Path "$stage\*" -DestinationPath $outFile -Force |
| 72 | +
|
| 73 | + Write-Host "Created $outFile" |
| 74 | +
|
| 75 | + # ------------------------------------------------------------------ |
| 76 | + # 3) Push to NuGet (only when the workflow is triggered by a Release) |
| 77 | + # ------------------------------------------------------------------ |
| 78 | + # FIXNOW |
| 79 | + # - name: Push to NuGet.org |
| 80 | + # if: github.event_name == 'release' |
| 81 | + # env: |
| 82 | + # NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
| 83 | + # run: | |
| 84 | + # nuget push "Graphviz.NetWrapper.*.nupkg" ` |
| 85 | + # -Source https://api.nuget.org/v3/index.json ` |
| 86 | + # -ApiKey $env:NUGET_API_KEY |
0 commit comments