Skip to content

Consolidate workflows #5

Consolidate workflows

Consolidate workflows #5

Workflow file for this run

name: main
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- published
env:
TERM: xterm
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Install .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
- name: Validate format
run: dotnet format --verify-no-changes
test:
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
max-parallel: 3
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Install .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
- name: Run tests
run: >
dotnet test
--configuration Release
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
--
RunConfiguration.CollectSourceInformation=true
pack:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Install .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
- name: Set version
id: set-version
if: ${{ github.event_name != 'release' }}
run: |
ref="${{ github.head_ref || github.ref_name }}"
ref_clean="${ref/\//-}"
version_suffix="ci-${ref_clean}-${{ github.run_id }}"
echo "version-suffix=${version_suffix}" >> $GITHUB_OUT
- name: Create packages
run: >
dotnet pack
--configuration Release
${{ env.steps.set-version.outputs.version-suffix && format('--version-suffix {0}', env.steps.set-version.outputs.version-suffix) || '' }}
- name: Upload artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: packages
path: "**/*.nupkg"
deploy:
needs:
- format
- test
- pack
runs-on: ubuntu-latest
permissions:
actions: read
packages: write
steps:
- name: Download artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: packages
- name: Install .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
- name: Publish packages (GitHub Registry)
run: >
dotnet nuget push **/*.nupkg
--source https://nuget.pkg.github.com/passwordless/index.json
--api-key ${{ secrets.GITHUB_TOKEN }}
- name: Publish packages (NuGet Registry)
run: >
dotnet nuget push **/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{secrets.nuget_api_key}}