Skip to content

Deploy NuGet package #5

Deploy NuGet package

Deploy NuGet package #5

Workflow file for this run

name: "deploy"
run-name: Deploy NuGet package
concurrency:
group: azure-artifacts
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
environment:
description: Deployment environment
type: choice
options:
- azure-artifacts
- nuget
default: azure-artifacts
required: true
preview:
description: Append preview suffix
type: boolean
default: true
required: true
jobs:
build:
runs-on: ubuntu-latest
outputs:
nuget-version: "${{ steps.gitversion.outputs.majorMinorPatch }}-preview-${{ github.run_id }}"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: "5.x"
preferLatestVersion: true
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
updateAssemblyInfo: true
useConfigFile: true
configFilePath: gitversion.yml
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-quality: "ga"
- name: Build library
run: >
dotnet build src/Indicators.csproj
--configuration Release
--property:Version="${{ steps.gitversion.outputs.majorMinorPatch }}-preview-${{ github.run_id }}"
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Pack for NuGet
run: >
dotnet pack src/Indicators.csproj
--configuration Release
--no-build
--include-symbols
--output NuGet
-p:PackageVersion="${{ steps.gitversion.outputs.majorMinorPatch }}-preview-${{ github.run_id }}"
- name: Save NuGet package
uses: actions/upload-artifact@v3
with:
name: packages
path: NuGet
- name: Show version
run: |
{
echo "### Identified semantic version"
echo "| Variable | Value |"
echo "| --------------- | ----------------------------------------------- |"
echo "| Major | ${{ steps.gitversion.outputs.major }} |"
echo "| Minor | ${{ steps.gitversion.outputs.minor }} |"
echo "| Patch | ${{ steps.gitversion.outputs.patch }} |"
echo "| MajorMinorPatch | ${{ steps.gitversion.outputs.majorMinorPatch }} |"
echo ""
echo "Composed version: ${{ steps.gitversion.outputs.majorMinorPatch }}-preview-${{ github.run_id }}"
} >> $GITHUB_STEP_SUMMARY
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}
url: "${{ vars.NUGET_DOWNLOAD_PREFIX }}${{ needs.build.outputs.nuget-version }}"
steps:
- name: Install NuGet tool
uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NUGET_TOKEN }}
nuget-version: '6.0.x'
- name: Download NuGet package
uses: actions/download-artifact@v3
with:
name: packages
path: NuGet
- name: Show publish preview
run: |
echo ${{ vars.NUGET_PUBLISH_URL }}
echo ${{ vars.NUGET_DOWNLOAD_PREFIX }}
echo "skender.stock.indicators.${{ needs.build.outputs.nuget-version }}.nupkg"
echo "skender.stock.indicators.${{ needs.build.outputs.nuget-version }}.snupkg"
- name: Publish packages
run: |
nuget sources Add -Name "PubURL" -Source ${{ vars.NUGET_PUBLISH_URL }} -UserName DaveSkender -Password ${{ secrets.NUGET_TOKEN }}
nuget push NuGet/*.nupkg -src PubURL -ApiKey AZ