C# 8 Empty ReadOnlyCollection #89
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
push: | |
branches: | |
- 'build/**' | |
paths-ignore: | |
- '.devcontainer/**' | |
- '.vscode/settings.json' | |
- '.editorconfig' | |
- 'CONTRIBUTING.md' | |
- 'NuGet.md' | |
- 'README.md' | |
- 'build.ps1' | |
- 'build.sh' | |
- 'test/**' | |
tags: | |
- '*.*.*' | |
concurrency: | |
group: publish-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
# Disable sending usage data to Microsoft | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
# Disable telemetry message | |
DOTNET_NOLOGO: true | |
# Stop wasting time caching packages | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
# Do not extract XML documentation files from nuget packages | |
NUGET_XMLDOC_MODE: skip | |
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json' | |
PROJECT_CONFIGURATION: Release | |
PROJECT_PATH: ./src/PhoneNumbers/PhoneNumbers.csproj | |
RELEASE_VERSION: '0.0.0' | |
jobs: | |
build: | |
name: Publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Set release version | |
if: github.ref_type == 'tag' | |
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV | |
- name: Set release version (preview build) | |
if: github.ref_type == 'branch' | |
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF:17})" >> $GITHUB_ENV | |
- name: update project version value to release version | |
run: | | |
$xml = [xml](Get-Content '${{ env.PROJECT_PATH }}') | |
$xml.SelectNodes("//Project/PropertyGroup[1]/Version") | % { | |
$_."#text" = $_."#text".Replace("1.0.0", "${{ env.RELEASE_VERSION }}") | |
} | |
$xml.Save('${{ env.PROJECT_PATH }}') | |
shell: pwsh | |
- name: update release URL value to release version | |
if: github.ref_type == 'tag' | |
run: | | |
$xml = [xml](Get-Content '${{ env.PROJECT_PATH }}') | |
$xml.SelectNodes("//Project/PropertyGroup[1]/PackageReleaseNotes") | % { | |
$_."#text" = $_."#text".Replace("/releases", "/releases/tag/${{ env.RELEASE_VERSION }}") | |
} | |
$xml.Save('${{ env.PROJECT_PATH }}') | |
shell: pwsh | |
- name: dotnet restore | |
run: dotnet restore | |
- name: dotnet build | |
run: dotnet build --configuration ${{ env.PROJECT_CONFIGURATION }} --no-restore | |
- name: dotnet test | |
run: dotnet test --no-restore --verbosity minimal | |
- name: dotnet pack | |
if: github.ref_type == 'tag' | |
run: dotnet pack --no-build --configuration ${{ env.PROJECT_CONFIGURATION }} | |
- name: dotnet pack (preview build) | |
if: github.ref_type == 'branch' | |
run: | | |
$date = Get-Date -Format "yyyyMMdd" | |
$projVersion = ([xml](Get-Content ${{ env.PROJECT_PATH }})) | Select-Xml -XPath "//Project/PropertyGroup[1]/Version" | |
dotnet pack --no-build --configuration ${{ env.PROJECT_CONFIGURATION }} -p:PackageVersion="${{ env.RELEASE_VERSION }}-preview$date.${{ github.run_number }}" | |
shell: pwsh | |
- name: dotnet nuget push | |
if: github.ref_type == 'tag' || (github.ref_type == 'branch' && github.event_name == 'push') | |
run: dotnet nuget push '/home/runner/work/**/*.nupkg' --api-key ${{ secrets.NUGET_API_KEY }} --source ${{ env.NUGET_SOURCE }} |