Master GitHub Actions with hands-on labs and exercises. Learn how to automate workflows, run tests, deploy applications, and more using GitHub's powerful automation platform. This repository has everything you need to get started with continuous integration and continuous deployment.
name: CSharp Extension Methods Release Artifacts
on:
workflow_dispatch:
push:
paths:
- '.github/workflows/csharp-extension-methods-release-artifacts.yml'
- 'src/dotnet/CSharp.ExtensionMethods/**'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
GITHUB_TOKEN: $
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
- name: Build CSharp.ExtensionMethods
run: dotnet build --configuration Release
working-directory: ./src/dotnet/CSharp.ExtensionMethods/CSharp.ExtensionMethods
- name: Build CSharp.ExtensionMethods.Tests
run: dotnet build --configuration Release
working-directory: ./src/dotnet/CSharp.ExtensionMethods/CSharp.ExtensionMethods.Tests
- name: Run Unit Tests
run: dotnet test --no-restore --verbosity normal
working-directory: ./src/dotnet/CSharp.ExtensionMethods/CSharp.ExtensionMethods.Tests
- name: Create NuGet Package
run: dotnet pack --configuration Release
working-directory: ./src/dotnet/CSharp.ExtensionMethods/CSharp.ExtensionMethods
# Verify that the .nupkg file exists
- name: List contents of the bin/Release directory
run: ls ./src/dotnet/CSharp.ExtensionMethods/CSharp.ExtensionMethods/bin/Release/
- name: Publish NuGet Package to GitHub Packages
run: dotnet nuget push ./src/dotnet/CSharp.ExtensionMethods/CSharp.ExtensionMethods/bin/Release/*.nupkg --source "https://nuget.pkg.github.com/$/index.json" --api-key $ --skip-duplicate
- name: Publish NuGet Package to NuGet.org
run: dotnet nuget push ./src/dotnet/CSharp.ExtensionMethods/CSharp.ExtensionMethods/bin/Release/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key $ --skip-duplicate
# Create a GitHub Release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: v1.0.$
release_name: 'Release v1.0.$'
body: 'Release of CSharp.ExtensionMethods NuGet package'
env:
GITHUB_TOKEN: $