Skip to content

Release

Release #18

Workflow file for this run

name: Release
on: [ workflow_dispatch ]
permissions:
contents: read # for checkout
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace}}/nuget
jobs:
# Creates a new GitHub release using the semantic-release tool.
# This tool also creates a Git tag which holds the current library version.
release:
name: Create a new release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 18
branches: |
[ 'main' ]
tag_format: '${version}'
extra_plugins: |
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Builds the .NET project and creates a Nuget package.
build:
name: Build & Package
runs-on: ubuntu-latest
needs: [ release ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Pack
run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
# Validates the generated package.
validate:
name: Validate
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Install nuget validator
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
- name: Validate package
run: meziantou.validate-nuget-package ${{ env.NuGetDirectory }}/*.nupkg
# Deploys generated package to the Nuget server.
deploy:
name: Deploy Package
runs-on: ubuntu-latest
needs: [ build, validate ]
steps:
- uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Publish NuGet package
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json