Skip to content

Commit 66203b1

Browse files
committed
Publish API project to nuget
Signed-off-by: Victor Chang <[email protected]>
1 parent 242476e commit 66203b1

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

.github/workflows/ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ jobs:
308308
runs-on: ${{ matrix.os }}
309309
needs: [calc-version]
310310
env:
311+
NUGETVER: ${{ needs.calc-version.outputs.nuGetVersionV2 }}
311312
SEMVER: ${{ needs.calc-version.outputs.semVer }}
312313
PRERELEASELABEL: ${{ needs.calc-version.outputs.preReleaseLabel }}
313314
MAJORMINORPATCH: ${{ needs.calc-version.outputs.majorMinorPatch }}
@@ -381,12 +382,32 @@ jobs:
381382
popd
382383
dir -r ~/release
383384
385+
- name: Package API
386+
env:
387+
PACKAGEDIR: '${{ github.workspace }}/nupkg/'
388+
if: ${{ (matrix.os == 'ubuntu-latest') }}
389+
run: |
390+
mkdir $PACKAGEDIR
391+
dotnet pack --no-build -c ${{ env.BUILD_CONFIG }} -o $PACKAGEDIR -p:PackageVersion=${{ env.NUGETVER }}
392+
ls -lR $PACKAGEDIR
393+
working-directory: ./src/Api
394+
384395
- name: Upload CLI
385396
uses: actions/[email protected]
386397
with:
387398
name: artifacts
388399
path: ~/release
389400
retention-days: 7
401+
402+
- name: Upload Nuget
403+
if: ${{ matrix.os == 'ubuntu-latest' }}
404+
uses: actions/[email protected]
405+
env:
406+
PACKAGEDIR: '${{ github.workspace }}/nupkg/'
407+
with:
408+
name: nuget
409+
path: ${{ PACKAGEDIR }}*.nupkg
410+
retention-days: 30
390411

391412
- name: Log in to the Container registry
392413
uses: docker/[email protected]
@@ -501,6 +522,31 @@ jobs:
501522
name: artifacts
502523
path: ~/release
503524
retention-days: 7
525+
526+
publish:
527+
name: Publish to GitHub Packages
528+
runs-on: ubuntu-latest
529+
needs: [build, unit-test]
530+
if: ${{ ! ( github.event.inputs.nuget ) && ! ( contains(github.ref, 'refs/heads/main') ) }}
531+
steps:
532+
- uses: actions/download-artifact@v3
533+
id: download
534+
535+
- name: List artifacts
536+
run: ls -ldR ${{steps.download.outputs.download-path}}/**/*
537+
538+
- name: Install grp
539+
run: dotnet tool install gpr -g
540+
541+
- uses: actions/setup-dotnet@v3
542+
env:
543+
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
544+
with:
545+
dotnet-version: "6.0.x"
546+
source-url: https://nuget.pkg.github.com/Project-MONAI/index.json
547+
548+
- name: Publish to GitHub
549+
run: gpr push '${{ steps.download.outputs.download-path }}/nuget/*.nupkg' --repository ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}
504550

505551
release:
506552
if: ${{ contains(github.ref, 'refs/heads/main') || contains(github.ref, 'refs/heads/develop') ||contains(github.head_ref, 'release/') || contains(github.head_ref, 'feature/') || contains(github.head_ref, 'develop') }}
@@ -521,6 +567,22 @@ jobs:
521567

522568
- name: List artifacts
523569
run: ls -ldR ${{steps.download.outputs.download-path}}/**/*
570+
571+
- name: Install grp
572+
run: dotnet tool install gpr -g
573+
574+
- uses: actions/setup-dotnet@v3
575+
env:
576+
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
577+
with:
578+
dotnet-version: "6.0.x"
579+
source-url: https://nuget.pkg.github.com/Project-MONAI/index.json
580+
581+
- name: Publish to GitHub
582+
run: gpr push '${{ steps.download.outputs.download-path }}/nuget/*.nupkg' --repository ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}
583+
584+
- name: Publish to NuGet.org
585+
run: dotnet nuget push ${{ steps.download.outputs.download-path }}/nuget/*.nupkg -s https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET }} --skip-duplicate
524586

525587
- name: Extract owner and repo
526588
uses: jungwinter/split@v2

src/Api/Monai.Deploy.InformaticsGateway.Api.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,23 @@
2525
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
2626
<Nullable>enable</Nullable>
2727
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
28+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2829
</PropertyGroup>
2930

31+
<PropertyGroup>
32+
<PackageId>Monai.Deploy.InformaticsGateway.Api</PackageId>
33+
<Version>0.4.1</Version>
34+
<Authors>MONAI Consortium</Authors>
35+
<Company>MONAI Consortium</Company>
36+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
37+
<Description>MONAI Deploy Informatics Gateway API</Description>
38+
<Copyright>MONAI Consortium</Copyright>
39+
<PackageProjectUrl>https://github.com/Project-MONAI/monai-deploy-informatics-gateway</PackageProjectUrl>
40+
<RepositoryUrl>https://github.com/Project-MONAI/monai-deploy-informatics-gateway</RepositoryUrl>
41+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
42+
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
43+
</PropertyGroup>
44+
3045
<ItemGroup>
3146
<PackageReference Include="fo-dicom" Version="5.1.1" />
3247
<PackageReference Include="Macross.Json.Extensions" Version="3.0.0" />

0 commit comments

Comments
 (0)