Skip to content

Commit

Permalink
Merge pull request #79 from randomnote1/UpdateBuildProcess
Browse files Browse the repository at this point in the history
Update build process
  • Loading branch information
randomnote1 authored Jun 9, 2021
2 parents e15f28c + 9275981 commit d9737ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 49 deletions.
55 changes: 13 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
name: Build Management Pack

# Run when a pull request is closed
# When a push occurs to the dev or main branches
on:
pull_request:
push:
branches:
types: [closed]
- dev
- main

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# Only run when a pull request is merged to dev or main
if: |
( github.event.pull_request.merged == true ) &&
(
( github.base_ref == 'main' ) ||
( github.base_ref == 'dev' )
)
# Only run when a push occurs to dev or main
if: ( github.ref == 'refs/heads/main' ) || ( github.ref == 'refs/heads/dev' )

# Specify the version of Windows
runs-on: windows-latest

steps:
# Check out the repository the pull request in merging into (dev/main)
#- name: Checkout Base Repo
# uses: actions/checkout@v2
# with:
# github-token: ${{ secrets.AM_REPO_BUILD }}
# ref: ${{ github.event.pull_request.base.sha }}
# path: base

- name: Checkout Head Repo
- name: Checkout Base Repo
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: head
path: base
token: ${{ secrets.GITHUB_TOKEN }}

# Execute the build PowerShell script
- name: Execute build script
if: |
( github.base_ref == 'main' ) ||
( ( github.base_ref == 'dev' ) && ( github.head_ref != 'main' ) )
if: ( github.ref == 'refs/heads/main' ) || ( github.ref == 'refs/heads/dev' )
shell: powershell
run: .\head\Build\build.ps1
run: .\base\Build\build.ps1

# Upload the management pack files as artifacts
- name: Upload Artifacts
Expand All @@ -53,7 +39,7 @@ jobs:

# Create a release of the management pack
- name: Generate Release
if: github.base_ref == 'main'
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
with:
name: v${{ env.Version }}
Expand All @@ -65,7 +51,7 @@ jobs:

# Create a beta release of the management pack
- name: Generate Beta Release
if: github.base_ref == 'dev'
if: github.ref == 'refs/heads/dev'
uses: softprops/action-gh-release@v1
with:
name: v${{ env.Version }}
Expand All @@ -74,18 +60,3 @@ jobs:
files: ${{ env.ArtifactFileName }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Open a pull request for dev <- main
- name: Open pull to commit into dev from main
if: ( github.base_ref == 'main' ) && ( github.head_ref == 'dev' )
uses: peter-evans/create-pull-request@v3
with:
path: head
commit-message: Update dev version to v${{ env.Version }}
committer: GitHub Actions Bot <[email protected]>
author: GitHub Actions Bot <[email protected]>
branch: main
delete-branch: false
base: dev
title: Rebase dev
body: Update dev to v${{ env.Version }} from main.
13 changes: 6 additions & 7 deletions Build/build.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Set the verbose preference
$VerbosePreference = 'Continue'

Write-Verbose -Message "GITHUB_BASE_REF: $($env:GITHUB_BASE_REF)"
Write-Verbose -Message "GITHUB_HEAD_REF: $($env:GITHUB_HEAD_REF)"
Write-Verbose -Message "GITHUB_REF: $($env:GITHUB_REF)"

# Download the System Center Visual Studio Authoring Extensions (VSAE)
$invokeWebRequestParams = @{
Expand All @@ -21,7 +20,7 @@ msiexec /quiet /i $vsaeMsiFile.FullName
$vsWherePath = Join-Path -Path ( Join-Path -Path ( Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'Microsoft Visual Studio' ) -ChildPath Installer ) -ChildPath vswhere.exe
Write-Verbose -Message "vswhere.exe path: $vsWherePath"

$solutions = Get-ChildItem -Path Head -Filter *.sln -Recurse
$solutions = Get-ChildItem -Path base -Filter *.sln -Recurse
Write-Verbose -Message ( "Solution Files: `n {0}" -f ( $solutions.FullName -join "`n " ) )

foreach ( $solution in $solutions )
Expand Down Expand Up @@ -114,7 +113,7 @@ foreach ( $solution in $solutions )
}

# Verify the management pack files were created
$buildFiles = Get-ChildItem -Path .\head\*\bin\Release\*
$buildFiles = Get-ChildItem -Path .\base\*\bin\Release\*
Write-Verbose -Message ( "Management Pack Files:`n {0}" -f ( $buildFiles.FullName -join "`n " ) )

# Find the relevant file to release
Expand All @@ -133,7 +132,7 @@ foreach ( $solution in $solutions )

if ( -not $releaseFile )
{
throw 'No management pack files found in ".\head\*\bin\Release\*"'
throw 'No management pack files found in ".\base\*\bin\Release\*"'
}
else
{
Expand All @@ -146,12 +145,12 @@ foreach ( $solution in $solutions )

# Commit the version update to the reference repo
Push-Location
Set-Location -Path head
Set-Location -Path base
git config user.name "GitHub Actions Bot"
git config user.email "<[email protected]>"
git add $projectFile.FullName
git add $projectUserFile.FullName
git commit -m $commitComment
git push
git push origin HEAD:$($env:GITHUB_REF)
Pop-Location
}

0 comments on commit d9737ee

Please sign in to comment.