-
Notifications
You must be signed in to change notification settings - Fork 19
145 lines (125 loc) · 7.15 KB
/
buildrelease.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
137
138
139
140
141
142
143
144
145
# This is a basic workflow to help you get started with Actions
name: Build and Draft Release
# Controls when the action will run
on:
workflow_dispatch:
inputs:
branch:
description: 'Enter the branch name to build the Release from'
required: true
version:
description: 'Do not include the leading V. This will be the next version for the Release, MPB, and DLL'
required: true
prerelease:
description: 'Is this pre-release?'
required: true
default: 'true'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Job 1, Build - Build the Management Pack on Windows Server with Visual Studio
build:
runs-on: windows-2019
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out repository under $GITHUB_WORKSPACE, so job can access it
- uses: actions/checkout@v3.3.0
with:
ref: ${{ github.event.inputs.branch }}
# Add MSBuild to environment path
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1.3
# copy dependencies over
- name: Copy Dependencies folder from the repo to Build for MP signing and show them
run: |
Copy-Item -Path ManagementPack\2016\dependencies -Destination "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VSAC\" -Recurse
Get-ChildItem "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VSAC\"
# Build the Settings UI dll
- name: Compile SMLetsExchangeConnectorSettingsUI.dll
run: msbuild ManagementPack/2016/SMLetsExchangeConnectorSettingsUI/SMLetsExchangeConnectorSettingsUI.csproj
#change the MPB version
- name: Change the next MPB build version
run: |
[xml]$build = Get-Content ManagementPack\2016\SMLets.Exchange.Connector\SMLets.Exchange.Connector.mpproj
$build.Project.PropertyGroup[0].Version = "${{ github.event.inputs.version }}"
$build.Project.PropertyGroup[1].Copyright = "AdhocAdam, " + (Get-Date).Year + "."
$build.Save("ManagementPack\2016\SMLets.Exchange.Connector\SMLets.Exchange.Connector.mpproj")
# Convert Management Pack Fragments to single XML, seal it to create the MP, bind the DLL to it, and thus create the MPB
- name: Sign the XML to create the MP. Then combine the MP and DLL to create the MPB
run: msbuild ManagementPack/2016/SMLets.Exchange.Connector.sln
#change the Resources.DLL version
- name: Change the SMLets.Exchange.Connector.Resources.dll File Assembly version
run: |
$newVersion = "${{ github.event.inputs.version }}"
$originalAssembly = Get-Content -path ManagementPack\2016\SMLets.Exchange.Connector.Resources\Properties\AssemblyInfo.cs
$assemblyFileVersion = $originalAssembly[$originalAssembly.Length - 1]
$originalAssembly.Replace($assemblyFileVersion, '[assembly: AssemblyFileVersion("' + $newVersion + '")]') | Out-File ManagementPack\2016\SMLets.Exchange.Connector.Resources\Properties\AssemblyInfo.cs
# Create the SMLets.Exchange.Connector.Resources.dll for those using the connector with the SCSM workflow engine
- name: Compile the SMLets.Exchange.Connector.Resources.dll
run: msbuild ManagementPack\2016\SMLets.Exchange.Connector.Resources\SMLets.Exchange.Connector.Resources.csproj
# create a temp directory to build the SMLets Exchange Connector folder structure
- name: Create a local directory C:\smletsexchangeconnector
run: |
New-Item -Path "C:\smletsexchangeconnector" -ItemType Directory
New-Item -Path "C:\smletsexchangeconnector\ManagementPack" -ItemType Directory
New-Item -Path "C:\smletsexchangeconnector\ManagementPack\2016" -ItemType Directory
#copy files to the temp directory to prepare the artifact upload
- name: Copy relevant files to C:\smletsexchangeconnector
run: |
Copy-Item -Path "BouncyCastle.Crypto.dll" -Destination "C:\smletsexchangeconnector\"
Copy-Item -Path "CONTRIBUTING.md" -Destination "C:\smletsexchangeconnector\"
Copy-Item -Path "LICENSE" -Destination "C:\smletsexchangeconnector\"
Copy-Item -Path "MimeKit.dll" -Destination "C:\smletsexchangeconnector\"
Copy-Item -Path "pii_regex.txt" -Destination "C:\smletsexchangeconnector\"
Copy-Item -Path "smletsExchangeConnector.ps1" -Destination "C:\smletsexchangeconnector\"
Copy-Item -Path "smletsExchangeConnector_customEvents.ps1" -Destination "C:\smletsexchangeconnector\"
Copy-Item -Path "CiresonPortalTasks" -Destination "C:\smletsexchangeconnector" -Recurse
Copy-Item -Path "HTMLEmailTemplates" -Destination "C:\smletsexchangeconnector" -Recurse
Copy-Item -Path "ManagementPack\2016\SMLets.Exchange.Connector.Resources\bin\Debug\SMLets.Exchange.Connector.Resources.dll" -Destination "C:\smletsexchangeconnector\ManagementPack\2016\"
Copy-Item -Path "ManagementPack\2016\SMLets.Exchange.Connector\bin\Debug\SMLets.Exchange.Connector.mpb" -Destination "C:\smletsexchangeconnector\ManagementPack\2016\"
# publish the build artifact up to GitHub
- name: publish the artifact (folder) back to GitHub
uses: actions/upload-artifact@master
with:
name: SMletsExchangeConnector
path: C:\smletsexchangeconnector\
# Job 2, Draft GitHub Release - Create a GitHub Release via Ubuntu and attach the artifact from the previous step
release:
runs-on: ubuntu-latest
needs: [build]
steps:
# create a draft release
- name: Create a Release
id: create_release #this will be used as a variable
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.event.inputs.version }} #${{ github.ref }}
release_name: SMlets Exchange Connector v${{ github.event.inputs.version }}
body: "release notes go here"
draft: true
prerelease: ${{ github.event.inputs.prerelease }}
# download the Artifacts to Ubuntu that were uploaded in the Windows build step
- uses: actions/download-artifact@v3.0.2
id: download #this will be used as a variable
with:
name: SMletsExchangeConnector
# show the results of the download for logging
- name: Display structure of downloaded files
run: ls -R
working-directory: ${{ steps.download.outputs.download-path }}
# zip the directory
- name: Zip the directory
run: |
cd ${{ steps.download.outputs.download-path }}
zip -r smletsexchangeconnector.zip ./
# upload build artifacts to the Release
- name: Upload a Release Asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: smletsexchangeconnector.zip
asset_name: smletsexchangeconnector-${{ github.event.inputs.version }}.zip
asset_content_type: application/zip