-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (132 loc) · 5.75 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Build
on:
push:
tags: ["v*"]
branches: ["**"]
pull_request:
branches: [master]
env:
SOLUTION: xslt.sln
NETFX_SOLUTION: xslt-netfx.sln
BUILD_CONFIGURATION: Release
defaults:
run:
shell: cmd
jobs:
build:
runs-on: windows-latest
steps:
- name: Dump Environment
run: |
echo "Solution : ${{ env.SOLUTION }}"
echo "Solution (netfx): ${{ env.NETFX_SOLUTION }}"
echo "Configuration : ${{ env.BUILD_CONFIGURATION }}"
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # See https://github.com/GitTools/GitVersion/issues/2301
# Java 17 is needed by Sonar analyzer
- uses: actions/setup-java@v1
with:
java-version: 17
java-package: jdk
architecture: x64
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
- name: Install SonarScanner
if: ${{ github.actor != 'dependabot[bot]' }}
run: dotnet tool install --global dotnet-sonarscanner
- name: Restore
run: dotnet restore "${{ env.SOLUTION }}" --configfile ./nuget.config
- name: Begin Sonar Analysis
if: ${{ github.actor != 'dependabot[bot]' }}
run: dotnet sonarscanner begin /key:"addupsolutions_addup-xslt" /name:"addup-xslt" /version:"${{ steps.gitversion.outputs.majorMinorPatch }}" /organization:"addupsolutions-oss" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.verbose=true /d:sonar.host.url=https://sonarcloud.io
- name: Build Windows .NET 4.7.2
run: msbuild "${{ env.NETFX_SOLUTION }}" /p:Configuration=${{ env.BUILD_CONFIGURATION }} /p:RestorePackages=false /p:OutputPath=${{ github.workspace }}/build/win-netfx/
- name: End Sonar Analysis
if: ${{ github.actor != 'dependabot[bot]' }}
run: dotnet sonarscanner end /d:sonar.login="${{secrets.SONAR_TOKEN}}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Windows .NET Core
run: dotnet publish ./xslt/netcore/xslt-netcore.csproj -c "${{ env.BUILD_CONFIGURATION }}" -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -o ./build/win-x64/
- name: Build Linux .NET Core
run: dotnet publish ./xslt/netcore/xslt-netcore.csproj -c "${{ env.BUILD_CONFIGURATION }}" -r linux-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -o ./build/linux-x64/
- name: Collect Windows .NET 4.7.2 executable
uses: actions/upload-artifact@v2
with:
name: xslt-net472
path: ${{ github.workspace }}/build/win-netfx/xslt.exe
- name: Collect Windows .NET Core executable
uses: actions/upload-artifact@v2
with:
name: xslt-win
path: ${{ github.workspace }}/build/win-x64/xslt.exe
- name: Collect Linux .NET Core executable
uses: actions/upload-artifact@v2
with:
name: xslt-linux
path: ${{ github.workspace }}/build/linux-x64/xslt
###########################################
# Release creation / publication
- name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
- name: Zip Windows .NET 4.7.2 executable
if: startsWith(github.ref, 'refs/tags/v')
run: 7z a ${{ github.workspace }}/build/xslt-net472.zip ${{ github.workspace }}/build/win-netfx/xslt.exe
- name: Upload Windows .NET 4.7.2 executable to Release
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/build/xslt-net472.zip
asset_name: xslt-net472.zip
asset_content_type: application/zip
- name: Zip Windows .NET Core executable
if: startsWith(github.ref, 'refs/tags/v')
run: 7z a ${{ github.workspace }}/build/xslt-win.zip ${{ github.workspace }}/build/win-x64/xslt.exe
- name: Upload Windows .NET Core executable to Release
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/build/xslt-win.zip
asset_name: xslt-win.zip
asset_content_type: application/zip
- name: Zip Linux .NET Core executable
if: startsWith(github.ref, 'refs/tags/v')
run: 7z a ${{ github.workspace }}/build/xslt-linux.zip ${{ github.workspace }}/build/linux-x64/xslt
- name: Upload Linux .NET Core executable to Release
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/build/xslt-linux.zip
asset_name: xslt-linux.zip
asset_content_type: application/zip