-
Notifications
You must be signed in to change notification settings - Fork 9
108 lines (87 loc) · 4.17 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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.2
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=..\..\..\..\src\AzurePipelines.TestLogger\AzurePipelines.TestLogger.nuspec
- name: Test
run: dotnet test --no-build --no-restore --verbosity normal --configuration ${{ matrix.Configuration }}
- name: Create zip
run: |
mkdir AzurePipelines.TestLogger.${{ env.SEM_VERSION }}
copy ".\src\AzurePipelines.TestLogger\bin\${{ matrix.Configuration }}\netstandard1.5\*.*" .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}
copy ".\LICENSE" .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}
copy ".\README.md" .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}
copy ".\ReleaseNotes.md" .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}
tar -cf AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.zip .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}
- 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
.\src\AzurePipelines.TestLogger\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: .\src\AzurePipelines.TestLogger\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 .\src\AzurePipelines.TestLogger\build\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json