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