Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
axunonb authored Jan 2, 2025
1 parent 3e35d53 commit e11c08c
Showing 1 changed file with 82 additions and 62 deletions.
144 changes: 82 additions & 62 deletions .github/workflows/publish.yml
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

0 comments on commit e11c08c

Please sign in to comment.