Skip to content

Commit

Permalink
Publish API project to nuget
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <[email protected]>
  • Loading branch information
mocsharp committed Sep 12, 2023
1 parent 242476e commit 66203b1
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ jobs:
runs-on: ${{ matrix.os }}
needs: [calc-version]
env:
NUGETVER: ${{ needs.calc-version.outputs.nuGetVersionV2 }}
SEMVER: ${{ needs.calc-version.outputs.semVer }}
PRERELEASELABEL: ${{ needs.calc-version.outputs.preReleaseLabel }}
MAJORMINORPATCH: ${{ needs.calc-version.outputs.majorMinorPatch }}
Expand Down Expand Up @@ -381,12 +382,32 @@ jobs:
popd
dir -r ~/release
- name: Package API
env:
PACKAGEDIR: '${{ github.workspace }}/nupkg/'
if: ${{ (matrix.os == 'ubuntu-latest') }}
run: |
mkdir $PACKAGEDIR
dotnet pack --no-build -c ${{ env.BUILD_CONFIG }} -o $PACKAGEDIR -p:PackageVersion=${{ env.NUGETVER }}
ls -lR $PACKAGEDIR
working-directory: ./src/Api

- name: Upload CLI
uses: actions/[email protected]
with:
name: artifacts
path: ~/release
retention-days: 7

- name: Upload Nuget
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/[email protected]
env:
PACKAGEDIR: '${{ github.workspace }}/nupkg/'
with:
name: nuget
path: ${{ PACKAGEDIR }}*.nupkg
retention-days: 30

- name: Log in to the Container registry
uses: docker/[email protected]
Expand Down Expand Up @@ -501,6 +522,31 @@ jobs:
name: artifacts
path: ~/release
retention-days: 7

publish:
name: Publish to GitHub Packages
runs-on: ubuntu-latest
needs: [build, unit-test]
if: ${{ ! ( github.event.inputs.nuget ) && ! ( contains(github.ref, 'refs/heads/main') ) }}
steps:
- uses: actions/download-artifact@v3
id: download

- name: List artifacts
run: ls -ldR ${{steps.download.outputs.download-path}}/**/*

- name: Install grp
run: dotnet tool install gpr -g

- uses: actions/setup-dotnet@v3
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
dotnet-version: "6.0.x"
source-url: https://nuget.pkg.github.com/Project-MONAI/index.json

- name: Publish to GitHub
run: gpr push '${{ steps.download.outputs.download-path }}/nuget/*.nupkg' --repository ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}

release:
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') }}
Expand All @@ -521,6 +567,22 @@ jobs:

- name: List artifacts
run: ls -ldR ${{steps.download.outputs.download-path}}/**/*

- name: Install grp
run: dotnet tool install gpr -g

- uses: actions/setup-dotnet@v3
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
dotnet-version: "6.0.x"
source-url: https://nuget.pkg.github.com/Project-MONAI/index.json

- name: Publish to GitHub
run: gpr push '${{ steps.download.outputs.download-path }}/nuget/*.nupkg' --repository ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}

- name: Publish to NuGet.org
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

- name: Extract owner and repo
uses: jungwinter/split@v2
Expand Down
15 changes: 15 additions & 0 deletions src/Api/Monai.Deploy.InformaticsGateway.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,23 @@
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<PropertyGroup>
<PackageId>Monai.Deploy.InformaticsGateway.Api</PackageId>
<Version>0.4.1</Version>
<Authors>MONAI Consortium</Authors>
<Company>MONAI Consortium</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>MONAI Deploy Informatics Gateway API</Description>
<Copyright>MONAI Consortium</Copyright>
<PackageProjectUrl>https://github.com/Project-MONAI/monai-deploy-informatics-gateway</PackageProjectUrl>
<RepositoryUrl>https://github.com/Project-MONAI/monai-deploy-informatics-gateway</RepositoryUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="fo-dicom" Version="5.1.1" />
<PackageReference Include="Macross.Json.Extensions" Version="3.0.0" />
Expand Down

0 comments on commit 66203b1

Please sign in to comment.