|
| 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 | + win-build: |
| 12 | + uses: ./.github/workflows/win-build.yml |
| 13 | + |
| 14 | + linux-build: |
| 15 | + uses: ./.github/workflows/linux-build.yml |
| 16 | + |
| 17 | + pack: |
| 18 | + needs: [win-build, linux-build] # ← the two workflow_call jobs |
| 19 | + runs-on: windows-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + # 1) bring the two per-OS packages into this job -------------------- |
| 23 | + - uses: actions/download-artifact@v4 |
| 24 | + with: { name: win-bits, path: artifacts/win } |
| 25 | + - uses: actions/download-artifact@v4 |
| 26 | + with: { name: linux-bits, path: artifacts/linux } |
| 27 | + |
| 28 | + # 2) unzip → merge → zip ------------------------------------------ |
| 29 | + - name: Merge NuGet packages |
| 30 | + id: merge |
| 31 | + shell: pwsh |
| 32 | + run: | |
| 33 | + # locate both nupkgs (Rubjerg.Graphviz.<ver>.nupkg) |
| 34 | + $winPkg = Get-ChildItem artifacts/win -Filter *.nupkg | Select -First 1 |
| 35 | + $linuxPkg = Get-ChildItem artifacts/linux -Filter *.nupkg | Select -First 1 |
| 36 | + if (-not $winPkg -or -not $linuxPkg) { throw "Packages missing" } |
| 37 | +
|
| 38 | + # extract <id> and <version> from the file name |
| 39 | + if ($winPkg.Name -notmatch '^(.+?)\.(\d+\.\d+\.\d+(?:-[A-Za-z0-9\.-]+)?)\.nupkg$') { |
| 40 | + throw "Unexpected package file name $($winPkg.Name)" |
| 41 | + } |
| 42 | + $id = $Matches[1] # Rubjerg.Graphviz |
| 43 | + $version = $Matches[2] # 2.0.2 (or 2.0.2-beta etc.) |
| 44 | +
|
| 45 | + $stage = "stage" |
| 46 | + Remove-Item $stage -Recurse -Force -ErrorAction SilentlyContinue |
| 47 | + New-Item -ItemType Directory -Path $stage | Out-Null |
| 48 | +
|
| 49 | + Expand-Archive $winPkg.FullName -DestinationPath $stage -Force |
| 50 | + Expand-Archive $linuxPkg.FullName -DestinationPath $stage -Force |
| 51 | +
|
| 52 | + $outFile = "$id.$version.nupkg" |
| 53 | + Compress-Archive "$stage\*" $outFile -Force |
| 54 | +
|
| 55 | + # expose the path for later steps |
| 56 | + "outfile=$outFile" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 57 | +
|
| 58 | + # 3) upload the merged package as a build artefact ------------------ |
| 59 | + - name: Upload final package as artefact |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: merged-nupkg |
| 63 | + path: ${{ steps.merge.outputs.outfile }} |
| 64 | + retention-days: 30 |
| 65 | + |
| 66 | + # 4) push to NuGet only on a GitHub Release ------------------------- |
| 67 | + # - name: Push to NuGet.org |
| 68 | + # if: github.event_name == 'release' |
| 69 | + # env: |
| 70 | + # NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
| 71 | + # run: | |
| 72 | + # nuget push "${{ steps.merge.outputs.outfile }}" ` |
| 73 | + # -Source https://api.nuget.org/v3/index.json ` |
| 74 | + # -ApiKey $env:NUGET_API_KEY |
| 75 | + |
0 commit comments