Skip to content

ci(actions): bump the github-actions group across 1 directory with 2 updates #164

ci(actions): bump the github-actions group across 1 directory with 2 updates

ci(actions): bump the github-actions group across 1 directory with 2 updates #164

Workflow file for this run

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: publish
on:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
push:
branches:
- 'main' # Run the workflow when pushing to the main branch
pull_request:
branches:
- '*' # Run the workflow for all pull requests
release:
types:
- published # Run the workflow when a new GitHub release is published
env:
NuGetDirectory: ${{ github.workspace }}/src/*/bin/Release/
permissions: {}
defaults:
run:
shell: pwsh
jobs:
create_nuget:
runs-on: ubuntu-latest
permissions:
contents: read # Required for repository checkout.
strategy:
matrix:
dotnet-version: [ '10.0.x' ]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
name: Setup dotnet ${{ matrix.dotnet-version }}
- name: Update Git submodules
run: git submodule update --init --recursive
- uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: ${{ matrix.dotnet-version }}
# You can test your matrix by printing the current dotnet version
name: Display dotnet version
#run: dotnet --version
# Create the NuGet package in the folder from the environment variable NuGetDirectory
- run: dotnet build --configuration Release
# Publish the NuGet package as an artifact, so they can be used in the following jobs
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
validate_nuget:
runs-on: ubuntu-latest
needs: [ create_nuget ]
steps:
# Install the .NET SDK indicated in the global.json file
- name: Setup .NET
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: 10.0.x
# Download the NuGet package created in the previous job
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: nuget
path: ${{ env.NuGetDirectory }}
run_test:
runs-on: ubuntu-latest
permissions:
contents: read # Required for repository checkout.
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Setup .NET
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: 10.0.x
- name: Run tests
run: dotnet test --configuration Release
deploy:
# Publish only when creating a GitHub Release
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
# You can update this logic if you want to manage releases differently
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ validate_nuget, run_test ]
steps:
# Download the NuGet package created in the previous job
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: nuget
path: ${{ env.NuGetDirectory }}
# Install the .NET SDK indicated in the global.json file
- name: Setup .NET Core
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: 10.0.x
# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
- name: Publish NuGet package
run: |
Get-ChildItem -Path . -Recurse -Include *.nupkg | ForEach-Object {
$nupkgPath = $_.FullName
Write-Host "Pushing $nupkgPath"
dotnet nuget push $nupkgPath --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}