Skip to content

Commit

Permalink
Merge pull request #82 from dependency-check/develop
Browse files Browse the repository at this point in the history
6.0.0.4 Release
  • Loading branch information
ejohn20 authored May 18, 2021
2 parents f7ef113 + 778bb9e commit ec3d0e5
Show file tree
Hide file tree
Showing 7 changed files with 437 additions and 27 deletions.
271 changes: 271 additions & 0 deletions build/Build-Extension.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@

<#PSScriptInfo
.VERSION 1.0.0
.GUID 6312d879-4b8c-4d88-aa39-bf245069148e
.AUTHOR Markus Szumovski
.COMPANYNAME -
.COPYRIGHT 2021
.TAGS
.LICENSEURI
.PROJECTURI
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
V 1.0.0: Initial version
.PRIVATEDATA
#>

<#
.SYNOPSIS
Will build the extension.
.DESCRIPTION
Will build the extension.
.PARAMETER ExtensionRepositoryRoot
The path to the extension repository root from where to build the extension from.
Will default to parent directory of script if no path or $null was provided.
.PARAMETER BuildEnvironment
Set to "Release" for production environment or set to anything else (for example "Development") for development environment.
If nothing was provided the Release environment will be built.
.PARAMETER BuildVersion
If provided will set the version number.
If not provided the version number will not be changed.
.PARAMETER NoPackaging
If the switch was provided, the built extension will not be packaged up into a vsix file.
.OUTPUTS
Building and packaging progress
.EXAMPLE
Build-Extension -BuildVersion "6.1.0.1" -BuildEnvironment "Release"
#>
[CmdletBinding(SupportsShouldProcess=$True)]
Param
(
[Parameter(Position=0)]
[string] $ExtensionRepositoryRoot = $null,
[Parameter(Position=1)]
[string] $BuildEnvironment = "Release",
[Parameter(Position=2)]
[string] $BuildVersion = $null,
[Parameter(Position=3)]
[switch] $NoPackaging

)

### --- START --- functions
### --- END --- functions

### --- START --- main script ###
try {
Write-Host "--- Build extension script started ---`r`n`r`n" -ForegroundColor DarkGreen

if([string]::IsNullOrWhiteSpace($ExtensionRepositoryRoot)) {
Write-Host "No extension repository root provided, determining path now..."
$ExtensionRepositoryRoot = Split-Path -Path (Split-Path -Path $MyInvocation.MyCommand.Path -Parent -ErrorAction Stop) -Parent -ErrorAction Stop
Write-Host ""
}
else {
$ExtensionRepositoryRoot = Resolve-Path -Path $ExtensionRepositoryRoot -ErrorAction Ignore
}

if([string]::IsNullOrWhiteSpace($BuildEnvironment)) {
$BuildEnvironment = "Release"
}

# Set build env vars
if ($BuildEnvironment -eq "Release") {
$TaskId = "47EA1F4A-57BA-414A-B12E-C44F42765E72"
$TaskName = "dependency-check-build-task"
$VssExtensionName = "vss-extension.prod.json"
}
else {
$TaskId = "04450B31-9F11-415A-B37A-514D69EF69A1"
$TaskName = "dependency-check-build-task-dev"
$VssExtensionName = "vss-extension.dev.json"
}

$ExtensionRepositoryRootExists = Test-Path -Path $ExtensionRepositoryRoot -ErrorAction Ignore

if($ExtensionRepositoryRootExists) {
$TaskFolderPath = Join-Path -Path $ExtensionRepositoryRoot -ChildPath "src\Tasks\dependency-check-build-task" -ErrorAction Stop

$TaskDefPath = Join-Path -Path $TaskFolderPath -ChildPath "task.json" -ErrorAction Stop
$TaskDefExists = Test-Path -Path $TaskDefPath -ErrorAction Ignore

$VssExtensionPath = Join-Path -Path $ExtensionRepositoryRoot -ChildPath $VssExtensionName -ErrorAction Stop
$VssExtensionExists = Test-Path -Path $VssExtensionPath -ErrorAction Ignore
}
else {
$TaskFolderPath = $null
$TaskDefPath = $null
$TaskDefExists = $false
$VssExtensionPath = $null
$VssExtensionExists = $false
}

#Parse version vars
$VerPatchRevision = $null
if(![string]::IsNullOrWhiteSpace($BuildVersion)) {
$VerMajor,$VerMinor,$VerPatch,$VerRevision = $BuildVersion.Split('.')
if($null -eq $VerMajor) {
$VerMajor = 0
}
if($null -eq $VerMinor) {
$VerMinor = 0
}
if($null -eq $VerPatch) {
$VerPatch = 0
}
if($null -eq $VerRevision) {
$VerRevision = 0
}
$VerPatchRevision = [string]::Format("{0}{1}", $VerPatch, $VerRevision.PadLeft(3, '0'))
$BuildVersion = "$VerMajor.$VerMinor.$VerPatch.$VerRevision"
$BuildTaskVersion = "$VerMajor.$VerMinor.$VerPatchRevision"
}


Write-Host "------------------------------"

Write-Host "Extension repository root: ""$ExtensionRepositoryRoot"" (" -NoNewline
if($ExtensionRepositoryRootExists) {
Write-Host "exists" -ForegroundColor Green -NoNewline
}
else {
Write-Host "missing" -ForegroundColor Red -NoNewline
}
Write-Host ")"

Write-Host "Task definition JSON: ""$TaskDefPath"" (" -NoNewline
if($TaskDefExists) {
Write-Host "exists" -ForegroundColor Green -NoNewline
}
else {
Write-Host "missing" -ForegroundColor Red -NoNewline
}
Write-Host ")"

Write-Host "VSS extension JSON: ""$VssExtensionPath"" (" -NoNewline
if($VssExtensionExists) {
Write-Host "exists" -ForegroundColor Green -NoNewline
}
else {
Write-Host "missing" -ForegroundColor Red -NoNewline
}
Write-Host ")"

Write-Host "Build environment: $BuildEnvironment"
if([string]::IsNullOrWhiteSpace($BuildVersion)) {
Write-Host "Build version: <none defined>"
}
else {
Write-Host "Build version: $BuildVersion"
Write-Host "Build-Task version: $BuildTaskVersion"
}

Write-Host "Task-Id: $TaskId"
Write-Host "Task-Name: $TaskName"
Write-Host "VSS extension JSON: $VssExtensionName"

Write-Host "------------------------------`r`n"

if($ExtensionRepositoryRootExists) {
if($TaskDefExists) {

Write-Host "Reading task.json..."
$TaskJson = Get-Content -Path $TaskDefPath -Raw | ConvertFrom-Json

Write-Host "Setting task definition id and name..."
$TaskJson.id = $TaskId
$TaskJson.name = $TaskName

if([string]::IsNullOrWhiteSpace($BuildVersion)) {
Write-Host "(Skipping setting of task definition version since no version was provided)"
}
else {
Write-Host "Setting task definition version..."
$TaskJson.version.Major = $VerMajor
$TaskJson.version.Minor = $VerMinor
$TaskJson.version.Patch = $VerPatchRevision
}

Write-Host "Saving new task definition..."
$TaskJson | ConvertTo-Json -Depth 100 | Set-Content -Path $TaskDefPath

if([string]::IsNullOrWhiteSpace($BuildVersion)) {
Write-Host "(Skipping setting of extension version since no version was provided)"
}
else {
Write-Host "Reading ""$VssExtensionName""..."
$VssExtensionJson = Get-Content -Path $VssExtensionPath -Raw | ConvertFrom-Json

Write-Host "Setting version"
$VssExtensionJson.version = $BuildVersion

Write-Host "Saving new extension definition..."
$VssExtensionJson | ConvertTo-Json -Depth 100 | Set-Content $VssExtensionPath
}

Write-Host "`r`nBuilding task..."
Write-Host "------------------------------"
Push-Location
Set-Location -Path $TaskFolderPath
&"npm" install
&"npm" run build
Pop-Location
Write-Host "------------------------------"
Write-Host "`r`nBuilding extension..."
Write-Host "------------------------------"
&"npm" install
&"npm" run build
Write-Host "------------------------------"

if(!$NoPackaging.IsPresent) {
Write-Host "`r`nPackaging..."
if($BuildEnvironment -eq "Release") {
&"npm" run package-prod
}
else {
&"npm" run package-dev
}

Write-Host "`r`nBuilding and packaging extension..." -NoNewline
}
else {
Write-Host "`r`nBuilding extension..." -NoNewline
}

Write-Host "DONE" -ForegroundColor Green
}
else {
Write-Warning "Task.json not found, cannot continue"
}
}
else {
Write-Warning "Extension repository root not found, cannot continue"
}
}
finally {
Write-Host "`r`n`r`n--- Build extension script ended ---" -ForegroundColor DarkGreen
}

#and we're at the end

### --- END --- main script ###
16 changes: 13 additions & 3 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ Let's start with this: We can automate this with a pipeline later and eliminate

Start by making your changes to the extension. When you are ready to test and release, use the steps below.

## Build Task Version
## PowerShell Core building

The simplest way to create a new vsix package for development or production environment is to use the ./build/Build-Extension.ps1 PowerShell Core script (PowerShell Core needs to be installed for this script to work).

Just call it via `pwsh ./build/Build-Extension.ps1 -BuildVersion "6.1.0.0" -BuildEnvironment "Release"` and replace the -BuildVersion string with the new version number and use "Release" as BuildEnvironment for production and "Development" as BuildEnvironment for development.

After the call the new VSIX file should have been created in the repository root directory.

## Manual building

### Build Task Version

To release a new version, start by opening the *src/Tasks/dependency-check-build-task/task.json* file. Bump the version number. Keep the major and minor versions in sync with the core Dependency Check CLI. The patch release has to be updated every time you want to change the extension. Even in development. Think of it like a build number. Azure won't update the build task during an update if this value is the same as the currently installed build task in a pipeline. So, we put some 0's on th end to tell us what version of Dependency Check we are using, as well as the build id of the extension itself. Example 5.1.1 = 5.1.\[1000-1999\].

Expand All @@ -16,7 +26,7 @@ To release a new version, start by opening the *src/Tasks/dependency-check-build
},
```

## Building for DEV
### Building for DEV

Open the **package.json** file and modify the package line:

Expand Down Expand Up @@ -58,7 +68,7 @@ dependency-check.azuredevops-dev-5.2.0.000.vsix

Upload the the marketplace manually (for now until the release pipeline works)

## Build for PROD
### Build for PROD

Open the **package.json** file and update the package command to the prod value:

Expand Down
2 changes: 1 addition & 1 deletion overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The OWASP Dependency Check Azure DevOps Extension enables the following features

## GitHub Repository

The extension maintainers do not monitor the Marketplace Question & Answers. please use the [Azure DevOps Dependency Check](https://github.com/dependency-check/azuredevops) repository for questions, issues, or enhancements.
The extension maintainers do not monitor the Marketplace Question & Answers. Please use the [Azure DevOps Dependency Check](https://github.com/dependency-check/azuredevops) repository for questions, issues, or enhancements.

## Installation and Configuration

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ec3d0e5

Please sign in to comment.