Skip to content

Backport with Reloaded-Memory-Buffers 2.0 #20

Backport with Reloaded-Memory-Buffers 2.0

Backport with Reloaded-Memory-Buffers 2.0 #20

name: Build and Publish
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]
workflow_dispatch:
env:
COVERAGE_PATH: ./Publish/Coverage.xml
PUBLISH_CHANGELOG_PATH: ./Publish/Changelog.md
PUBLISH_PATH: ./Publish
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
RELEASE_TAG: ${{ github.ref_name }}
jobs:
build:
runs-on: windows-2022
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: '6.0.x'
- name: Print Environment Variables
run: |
echo "Changelog Path: $env:PUBLISH_CHANGELOG_PATH"
echo "Publish Path: $env:PUBLISH_PATH"
echo "Is Release?: $env:IS_RELEASE"
echo "Release Tag: $env:RELEASE_TAG"
# Required for C#10 features.
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Setup AutoChangelog
run: npm install -g auto-changelog
- name: Get Dotnet Info
run: dotnet --info
- name: Publish
run: |
[System.IO.Directory]::CreateDirectory("$env:PUBLISH_PATH")
dotnet build -c Release ./Source/Reloaded.Assembler.sln
- name: Test
run: dotnet test -c Release ./Source/Reloaded.Assembler.Tests/Reloaded.Assembler.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput="../../$env:COVERAGE_PATH" /p:Exclude="[xunit.*]*"
- name: Create NuGet Package Artifacts
run: |
$items = Get-ChildItem -Path "." -Recurse | Where-Object { $_.Name -match "\.nupkg" }
foreach ($item in $items)
{
Write-Host "Moving $item -> $env:PUBLISH_PATH"
Move-Item -Path "$item" -Destination "$env:PUBLISH_PATH"
}
- name: Create Changelog (on Tag)
run: |
if ($env:IS_RELEASE -eq 'true')
{
auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --starting-version "$env:RELEASE_TAG" --output "$env:PUBLISH_CHANGELOG_PATH"
}
else
{
auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --output "$env:PUBLISH_CHANGELOG_PATH"
}
- name: Upload NuGet Artifact
uses: actions/[email protected]
with:
# Artifact name
name: Library
# A file, directory or wildcard pattern that describes what to upload
path: ${{ env.PUBLISH_PATH }}/*.nupkg
retention-days: 0
- name: Upload Changelog Artifact
uses: actions/[email protected]
with:
# Artifact name
name: Changelog
# A file, directory or wildcard pattern that describes what to upload
path: ${{ env.PUBLISH_CHANGELOG_PATH }}
retention-days: 0
- name: Upload Coverage Artifact
uses: actions/[email protected]
with:
# Artifact name
name: Coverage
# A file, directory or wildcard pattern that describes what to upload
path: ${{ env.COVERAGE_PATH }}
retention-days: 0
- name: Upload to GitHub Releases
uses: softprops/[email protected]
if: env.IS_RELEASE == 'true'
with:
# Path to load note-worthy description of changes in release from
body_path: ${{ env.PUBLISH_CHANGELOG_PATH }}
# Newline-delimited list of path globs for asset files to upload
files: ${{ env.PUBLISH_PATH }}/*.nupkg
- name: Codecov
uses: codecov/[email protected]
with:
# Comma-separated list of files to upload
files: ${{ env.COVERAGE_PATH }}
- name: Upload to NuGet (on Tag)
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
if: env.IS_RELEASE == 'true'
run: |
$items = Get-ChildItem -Path "$env:PUBLISH_PATH/*.nupkg"
Foreach ($item in $items)
{
Write-Host "Pushing $item"
dotnet nuget push "$item" -k "$env:NUGET_KEY" -s "https://api.nuget.org/v3/index.json" --skip-duplicate
}