forked from ical-org/ical.net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
82 additions
and
62 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,82 @@ | ||
name: Publish | ||
# This job builds and and publishes the package to NuGet. | ||
# It depends on the included tests job to complete successfully. | ||
# The version number is determined by the latest tag for the 'main' branch selected with workflow dispatch. | ||
on: | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: | | ||
8.0.x | ||
6.0.x | ||
3.1.x | ||
- 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: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
- 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: | | ||
Version=$(git describe --tags --abbrev=0 | sed 's/^v//') | ||
echo "VERSION=$Version" >> $GITHUB_ENV | ||
echo "Version: $Version" | ||
- name: Build and pack for publishing | ||
run: | | ||
dotnet restore | ||
dotnet build --configuration Release Ical.Net/Ical.Net.csproj -p:Version=${{env.VERSION}} -p:FileVersion=${{env.VERSION}}.${{github.run_number}} -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 | ||
- name: Push package to NuGet | ||
# Does not fail, if the package already exists | ||
run: dotnet nuget push Ical.Net/bin/Release/Ical.Net.${{env.VERSION}}.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
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 the main branch. | ||
on: | ||
workflow_dispatch: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout main | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
ref: main | ||
- 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: 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: | | ||
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 and pack for publishing | ||
run: | | ||
dotnet build --configuration Release Ical.Net/Ical.Net.csproj -p:Version=${{env.VERSION}} -p:FileVersion=${{env.VERSION}}.${{github.run_number}} -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 | ||
- name: Push package to NuGet | ||
# Does not fail, if the package already exists | ||
run: dotnet nuget push Ical.Net/bin/Release/Ical.Net.${{env.VERSION}}.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate |