[GitActions][Pack] Validate against v(X.Y.Z) & set the env var VERSION #40
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
name: Build & Test | |
on: | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: 'The reason for running the workflow' | |
required: false | |
default: 'Manual run' | |
push: | |
branches: [ master ] | |
paths-ignore: | |
- 'README.md' | |
- '**/*.md' | |
- '**/*.gif' | |
- '**/*.png' | |
- '**/*.gitignore' | |
- '**/*.gitattributes' | |
- LICENSE | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
pull_request: | |
branches: [ master ] | |
paths-ignore: | |
- 'README.md' | |
- '**/*.md' | |
- '**/*.gif' | |
- '**/*.png' | |
- '**/*.gitignore' | |
- '**/*.gitattributes' | |
env: | |
# Disable the .NET logo in the console output. | |
DOTNET_NOLOGO: true | |
# Stop wasting time caching packages | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
# Disable sending usage data to Microsoft | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false | |
DOTNET_MULTILEVEL_LOOKUP: 0 | |
BUILD_CONFIG: 'Release' | |
# https://docs.github.com/en/actions/learn-github-actions/expressions | |
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: build-and-test-${{matrix.os}} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macOS-latest] | |
dotnet-version: ['3.x.x', '5.x.x', '6.x.x', '7.x.x'] | |
steps: | |
- name: 'Print manual run reason' | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: | | |
echo 'Reason: ${{ github.event.inputs.reason }}' | |
- uses: actions/checkout@v4 | |
with: | |
lfs: true | |
fetch-depth: 0 | |
- name: Setup .NET (global.json) | |
uses: actions/setup-dotnet@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
# Look to see if there is a cache hit for the corresponding requirements file | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --configuration $BUILD_CONFIG --no-restore | |
- name: Test | |
run: | | |
dotnet test \ | |
--configuration $BUILD_CONFIG \ | |
--no-restore \ | |
--no-build \ | |
--verbosity normal \ | |
--logger "trx;LogFileName=test-results.trx" || true | |
timeout-minutes: 60 | |
# - name: Test Report | |
# uses: dorny/test-reporter@v1 | |
# if: always() | |
# with: | |
# name: DotNET Tests | |
# path: "**/test-results.trx" | |
# reporter: dotnet-trx | |
# fail-on-error: true |