Skip to content

Commit

Permalink
Create publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
engineering87 authored Oct 24, 2024
1 parent 6841243 commit 1ab2301
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish NuGet Package

on:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
push:
tags:
- 'v*' # This triggers the action when a tag prefixed with 'v' is created

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies for PDNDClientAssertionGenerator
run: dotnet restore src/PDNDClientAssertionGenerator/PDNDClientAssertionGenerator.csproj

- name: Restore dependencies for PDNDClientAssertionGenerator.Tests
run: dotnet restore src/PDNDClientAssertionGenerator.Tests/PDNDClientAssertionGenerator.Tests.csproj

- name: Build PDNDClientAssertionGenerator
run: dotnet build src/PDNDClientAssertionGenerator/PDNDClientAssertionGenerator.csproj --no-restore --configuration Release

- name: Pack the NuGet package
run: dotnet pack src/PDNDClientAssertionGenerator/PDNDClientAssertionGenerator.csproj --configuration Release --no-build --output ./output

- name: Publish to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./output/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json

- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
Nuova versione pubblicata: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload NuGet package as release asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./output/*.nupkg
asset_name: package-${{ github.ref_name }}.nupkg
asset_content_type: application/octet-stream

0 comments on commit 1ab2301

Please sign in to comment.