From 681b0b43687c5c0163659864ff8433f3fe70cb43 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Thu, 29 Sep 2022 21:17:36 +0100 Subject: [PATCH] CI - Added nuget package creation --- .github/workflows/nuget.yml | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/nuget.yml diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml new file mode 100644 index 000000000..0522d3f3a --- /dev/null +++ b/.github/workflows/nuget.yml @@ -0,0 +1,45 @@ +name: Publish Nuget packages + +on: + workflow_dispatch: + push: + branches: + - master + +jobs: + version: + runs-on: ubuntu-latest + outputs: + version-suffix: ${{ steps.get-version.outputs.version-suffix }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get Version String + id: get-version + shell: pwsh + run: | + $MidnightUtc = [DateTime]::UtcNow.Date + $BranchName = "${{ github.ref_name }}".replace('/','-').replace('.','-') + $NumberOfCommitsToday = (git log --after=$($MidnightUtc.ToString("o")) --oneline | Measure-Object -Line).Lines + $VersionSuffix = "$BranchName.$($MidnightUtc.ToString("yyyyMMdd")).$NumberOfCommitsToday" + Write-Output "::set-output name=version-suffix::$VersionSuffix" + + nuget: + name: Publish Nuget Packages + needs: version + runs-on: ubuntu-latest + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: '6.0.x' + - name: Checkout + uses: actions/checkout@v3 + - name: Pack Artemis.Core + run: dotnet pack -c Release -p:VersionSuffix=${{ needs.version.outputs.version-suffix }} -p:BuildingNuget=True src/Artemis.Core/Artemis.Core.csproj + - name: Pack Artemis.UI.Shared + run: dotnet pack -c Release -p:VersionSuffix=${{ needs.version.outputs.version-suffix }} src/Artemis.UI.Shared/Artemis.UI.Shared.csproj + - name: Push Nugets + run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate \ No newline at end of file