Skip to content

Release

Release #2

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
publish-to-nuget:
description: 'Publish to NuGet.org'
required: true
type: boolean
default: false
permissions:
id-token: write
contents: read
env:
TreatWarningsAsErrors: true
ContinuousIntegrationBuild: true
PublishRepositoryUrl: true
jobs:
build-and-pack:
name: Build and Pack
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
global-json-file: global.json
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration release -bl:artifacts/log/build.binlog
- name: Test
run: dotnet test --no-build --no-progress --configuration release -bl:artifacts/log/test.binlog
- name: Pack
run: dotnet pack --no-build --configuration release -bl:artifacts/log/pack.binlog
- name: Upload NuGet Packages
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: nuget-packages
path: ./artifacts/package/release/*.nupkg
if-no-files-found: error
- name: Upload Build Logs
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: build-logs
path: ./artifacts/log/**/*
if-no-files-found: error
publish-nuget:
name: Publish to NuGet.org
needs: build-and-pack
runs-on: ubuntu-latest
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_dispatch' && inputs.publish-to-nuget == true)
environment:
name: nuget.org
url: https://www.nuget.org/packages/DotNetProjectStarter
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
global-json-file: global.json
- name: Download NuGet Packages
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
name: nuget-packages
path: ./packages
- name: Authenticate to nuget
uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1.1.0
id: nugetlogin
with:
user: Youssef1313
- name: Push to NuGet.org
run: dotnet nuget push "./packages/**/*.nupkg" --api-key "${{ steps.nugetlogin.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
create-github-release:
name: Create GitHub Release
needs: build-and-pack
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Download NuGet Packages
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
name: nuget-packages
path: ./packages
- name: Create Release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.2.1
with:
files: ./packages/*.nupkg
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, '-') }}