Use yyyy-mm-dd in changelog.md #629
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Publish NuGet | |
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: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
NuGetDirectory: ${{ github.workspace }}/nuget | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
create_nuget: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./src/Jitter2 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Add MinVer and Reproducible Builds | |
run: | | |
dotnet add package MinVer | |
dotnet add package DotNet.ReproducibleBuilds | |
# Pack single-precision version | |
- name: Pack Single Precision | |
run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} | |
# Pack double-precision version | |
- name: Pack Double Precision | |
run: dotnet pack --configuration Release -p:DoublePrecision=true --output ${{ env.NuGetDirectory }} | |
# Upload artifacts | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nuget | |
if-no-files-found: error | |
retention-days: 7 | |
path: ${{ env.NuGetDirectory }}/* | |
validate_nuget: | |
runs-on: ubuntu-latest | |
needs: [create_nuget] | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Download NuGet Packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: nuget | |
path: ${{ env.NuGetDirectory }} | |
- name: Install NuGet Validator | |
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global | |
- name: Validate NuGet Packages | |
run: | | |
foreach ($file in Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg) { | |
meziantou.validate-nuget-package $file | |
} | |
run_test: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./src/Jitter2 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Run Tests - Single Precision | |
run: dotnet test --configuration Release | |
- name: Run Tests - Double Precision | |
run: dotnet test --configuration Release -p:DoublePrecision=true | |
deploy: | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
needs: [validate_nuget, run_test] | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Download NuGet Packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: nuget | |
path: ${{ env.NuGetDirectory }} | |
- name: Publish NuGet Packages | |
run: | | |
dotnet nuget add source --username notgiven688 --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/notgiven688/index.json" | |
foreach ($file in Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg) { | |
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate | |
dotnet nuget push $file --source "github" --skip-duplicate | |
} |