Skip to content

Build

Build #76

Workflow file for this run

name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
branches: [ main ]
inputs:
prerelease:
description: 'Is this build a pre-release?'
required: true
default: 'true'
jobs:
build:
runs-on: windows-latest
env:
VERSION: 1.2.3
strategy:
matrix:
Configuration: [Debug, Release]
steps:
- name: Set version number for pre-release
if: ${{ github.event.inputs.prerelease == '' || github.event.inputs.prerelease == 'true' }}
run: |
echo "SEM_VERSION=${{ env.VERSION }}-build-${{ github.RUN_NUMBER }}" >> $env:GITHUB_ENV
- name: Set version number for release
if: ${{ github.event.inputs.prerelease == 'false' }}
run: |
echo "SEM_VERSION=${{ env.VERSION }}" >> $env:GITHUB_ENV
- name: Read environmental variables
run: |
echo VERSION=${{ env.VERSION }}
echo GITHUB_RUN_NUMBER=${{ github.RUN_NUMBER }}
echo SEM_VERSION=${{ env.SEM_VERSION }}
- name: Checkout
uses: actions/[email protected]
- name: Setup .NET Core 2.1
uses: actions/[email protected]
with:
dotnet-version: 2.1
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration ${{ matrix.Configuration }} -p:Version=${{ env.SEM_VERSION }} -p:AssemblyVersion=${{ env.VERSION }} -p:FileVersion=${{ env.VERSION }}
- name: Prepare for pack
run: |
mkdir .\src\AzurePipelines.TestLogger\contentFiles\any\any
copy ".\src\AzurePipelines.TestLogger\bin\${{ matrix.Configuration }}\netstandard1.5\*.dll" .\src\AzurePipelines.TestLogger\contentFiles\any\any
- name: Pack
run: dotnet pack .\src\AzurePipelines.TestLogger\AzurePipelines.TestLogger.csproj --configuration ${{ matrix.Configuration }} -p:NuspecProperties="Version=${{ env.SEM_VERSION }}" --no-restore --no-build --output:.\build -p:NuspecFile=..\AzurePipelines.TestLogger\AzurePipelines.TestLogger.nuspec
- name: Test
run: dotnet test --no-build --no-restore --verbosity normal --configuration ${{ matrix.Configuration }}
- name: Create Zip
uses: vimtor/[email protected]
with:
files: LICENSE README.md ReleaseNotes.md .\src\AzurePipelines.TestLogger\bin\${{ matrix.Configuration }}\netstandard1.5
dest: AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.zip
- name: Upload Build Artifact
uses: actions/[email protected]
with:
name: AzurePipelines.TestLogger ${{ env.SEM_VERSION }} ${{ matrix.Configuration }}
path: AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.zip
if-no-files-found: error
- name: Publish GitHub Release
if: ${{ matrix.Configuration == 'Release' && github.event.inputs.prerelease == 'false' }}
uses: softprops/action-gh-release@v1
with:
name: v${{ env.SEM_VERSION }}
draft: true
prerelease: false
fail_on_unmatched_files: true
files: |
AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.zip
.\build\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.nupkg
- name: Upload NuGet Package
uses: actions/[email protected]
with:
name: AzurePipelines.TestLogger ${{ env.SEM_VERSION }} ${{ matrix.Configuration }}.nupkg
path: .\build\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.nupkg
if-no-files-found: error
- name: Publish NuGet Package
if: ${{ matrix.Configuration == 'Release' && github.event_name != 'pull_request' }}
run: dotnet nuget push .\build\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json