Skip to content

Build and Draft Release #25

Build and Draft Release

Build and Draft Release #25

Workflow file for this run

# 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