PubTest #1
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 | ||
# This job builds and publishes the package to NuGet. | ||
# It depends on the included tests job to complete successfully. | ||
# The version number is determined by the latest 'v*' tag for the main branch. | ||
on: | ||
workflow_dispatch: {} | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-22.04 | ||
# ubuntu-latest = ubuntu-24.04 does not include mono (2025-08-01) | ||
steps: | ||
- name: Checkout main | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
ref: main | ||
- name: Set Git config for line endings | ||
run: git config --global core.autocrlf true | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: | | ||
8.0.x | ||
6.0.x | ||
3.1.x | ||
- name: Get version tag | ||
# The latest tag for the selected branch. | ||
# Get it and strip off any leading 'v' from the version tag | ||
run: | | ||
Version=$(git tag --list 'v*' --sort=-v:refname | head -n 1 | sed 's/^v//') | ||
echo "VERSION=$Version" >> $GITHUB_ENV | ||
echo "Version: $Version" | ||
- name: Reset branch to specified tag | ||
run: git reset --hard v${{ env.VERSION }} | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --no-restore --configuration Release -p:Nullable=disable -p:nowarn=1591 | ||
- name: Test | ||
run: dotnet test --no-build --configuration Release --verbosity quiet | ||
publish: | ||
runs-on: ubuntu-latest | ||
needs: tests | ||
steps: | ||
- name: Checkout main | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
ref: main | ||
- name: Set Git config for line endings | ||
run: git config --global core.autocrlf true | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: | | ||
8.0.x | ||
- name: Get version tag | ||
# The latest tag for the selected branch. | ||
# Get it and strip off any leading 'v' from the version tag | ||
run: | | ||
Check failure on line 64 in .github/workflows/pubtest.yml
|
||
# The version variable will be e.g. like "5.1.0-pre.1" (pre-release) or "5.1.0" (release) | ||
Version=$(git tag --list 'v*' --sort=-v:refname | head -n 1 | sed 's/^v//') | ||
FileVersion=${{ env.VERSION%%-* }} | ||
AssemblyVersion=${{ env.VERSION%%.* }}.0 | ||
echo "VERSION=$Version" >> $GITHUB_ENV | ||
echo "FILE_VERSION=$FileVersion" >> $GITHUB_ENV | ||
echo "ASSEMBLY_VERSION=$AssemblyVersion" >> $GITHUB_ENV | ||
echo "Version: $Version" | ||
echo "File Version: $FileVersion" | ||
echo "Assembly Version: $AssemblyVersion" | ||
- name: Reset branch to specified tag | ||
run: git reset --hard v${{ env.VERSION }} | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Build and pack for publishing | ||
run: | | ||
# For version e.g. "5.1.0-pre.1", the FileVersion will be "5.1.0" and the AssemblyVersion will be "5.0.0" | ||
# AssemblyVersion must only change for major releases | ||
dotnet build --configuration Release Ical.Net/Ical.Net.csproj -p:Version=${{env.VERSION}} -p:FileVersion=${{env.FILE_VERSION}} -p:AssemblyVersion=${{env.ASSEMBLY_VERSION}} -p:Nullable=disable -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:ContinuousIntegrationBuild=true | ||
dotnet pack --configuration Release Ical.Net/Ical.Net.csproj -p:Version=${{env.VERSION}} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --no-build -p:PackageVersion=${{env.VERSION}} | ||
- name: Store artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ICal.Net_pkg_${{env.VERSION}}.${{github.run_number}} | ||
path: | | ||
Ical.Net/bin/Release/**/*.nupkg | ||
Ical.Net/bin/Release/**/*.snupkg |