Skip to content

Merge pull request #273 from waf/net8.0-and-nuget-upgrade #61

Merge pull request #273 from waf/net8.0-and-nuget-upgrade

Merge pull request #273 from waf/net8.0-and-nuget-upgrade #61

Workflow file for this run

# publishes to nuget if the version number in PrettyPrompt.csproj changes
name: publish to nuget
on:
push:
branches:
- main
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Check for new version
id: CheckReleaseRequired
shell: pwsh
run: |
$publishedversions = (Find-Package -AllVersions -AllowPrereleaseVersions -Name "PrettyPrompt").Version
echo "Found published versions: $publishedversions"
if ($publishedversions.Count -gt 0) {
$csproj = [xml](Get-Content ./src/PrettyPrompt/PrettyPrompt.csproj)
$localversion = $csproj.Project.PropertyGroup.Version[0]
echo "Version in the repository is $localversion"
$isReleaseRequired = (-not $publishedversions.Contains($localversion)).ToString().ToLower()
echo "Release required: $isReleaseRequired"
echo "::set-output name=LOCAL_VERSION::v$localversion"
echo "::set-output name=IS_RELEASE_REQUIRED::$isReleaseRequired"
}
- name: Install Dotnet
uses: actions/setup-dotnet@v1
if: steps.CheckReleaseRequired.outputs.IS_RELEASE_REQUIRED == 'true'
with:
dotnet-version: |
8.0.x
- name: Create NuGet Package
if: steps.CheckReleaseRequired.outputs.IS_RELEASE_REQUIRED == 'true'
run: dotnet pack ./src/PrettyPrompt/PrettyPrompt.csproj -c Release -p:ContinuousIntegrationBuild=true
- name: Publish to NuGet
if: steps.CheckReleaseRequired.outputs.IS_RELEASE_REQUIRED == 'true'
run: dotnet nuget push --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} --source 'https://api.nuget.org/v3/index.json' .\src\PrettyPrompt\bin\Release\PrettyPrompt.*.nupkg
- name: Create Git Tag
if: steps.CheckReleaseRequired.outputs.IS_RELEASE_REQUIRED == 'true'
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.CheckReleaseRequired.outputs.LOCAL_VERSION }}',
sha: context.sha
})