-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from d365collaborative/development
Next release
- Loading branch information
Showing
16 changed files
with
1,727 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
skippublish: | ||
description: "Determines if the publishing to the PowerShell Gallery is skipped" | ||
default: $True | ||
required: false | ||
type: choice | ||
options: | ||
- $False | ||
- $True | ||
skipghrelease: | ||
description: "Determines if creation of a GitHub release is skipped" | ||
default: $False | ||
required: false | ||
type: choice | ||
options: | ||
- $False | ||
- $True | ||
|
||
jobs: | ||
call-tmpl-build-release: | ||
uses: ./.github/workflows/tmpl-build-release.yml | ||
with: | ||
skippublish: ${{ inputs.skippublish }} | ||
skipghrelease: ${{ inputs.skipghrelease }} | ||
secrets: | ||
apikey: ${{ secrets.ApiKey }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Template for a reusable workflow to build and release a PowerShell module. | ||
# The template expects the following PowerShell scripts in the build folder of the repository root | ||
# that do the actual validated build and release: | ||
# - vsts-prerequisities.ps1 | ||
# - vsts-validate.ps1 | ||
# - vsts-build.ps1 | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
autoversion: | ||
description: "Determines if the module's build version number is automatically incremented" | ||
default: $True | ||
required: false | ||
type: string | ||
skippublish: | ||
description: "Determines if the publishing to the PowerShell Gallery is skipped" | ||
default: $False | ||
required: false | ||
type: string | ||
skipghrelease: | ||
description: "Determines if a GitHub release is created" | ||
default: $False | ||
required: false | ||
type: string | ||
secrets: | ||
apikey: | ||
description: "Key for the PowerShell Gallery API" | ||
required: true | ||
|
||
jobs: | ||
build-and-release: | ||
|
||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Install Prerequisites | ||
run: .\build\vsts-prerequisites.ps1 | ||
shell: powershell | ||
- name: Validate | ||
run: .\build\vsts-validate.ps1 | ||
shell: powershell | ||
- name: Build | ||
run: .\build\vsts-build.ps1 -ApiKey ${{ secrets.apikey }} -AutoVersion:${{ inputs.autoversion }} -SkipPublish:${{ inputs.skippublish }} | ||
shell: powershell | ||
|
||
- name: Get version | ||
run: | | ||
$publishDir = Get-Item -Path publish | ||
[version]$version = (Import-PowerShellDataFile -Path "$($publishDir.FullName)\d365bap.tools\d365bap.tools.psd1").ModuleVersion | ||
$githubReleaseVersion = "$($version.Major).$($version.Minor).$($version.Build)" | ||
"VERSION=$githubReleaseVersion" >> $env:GITHUB_ENV | ||
shell: powershell | ||
|
||
- name: Create GitHub release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
name: ${{ env.VERSION }} | ||
tag_name: ${{ env.VERSION }} | ||
draft: false | ||
prerelease: true | ||
generate_release_notes: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
d365bap.tools/functions/Export-BapEnvironmentSolution.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
|
||
<# | ||
.SYNOPSIS | ||
Export PowerPlatform / Dataverse Solution from the environment | ||
.DESCRIPTION | ||
Enables the user to export solutions, on a given environment | ||
The cmdlet downloads the solution, extracts it and removes unnecessary files | ||
.PARAMETER EnvironmentId | ||
The id of the environment that you want to work against | ||
This can be obtained from the Get-BapEnvironment cmdlet | ||
.PARAMETER SolutionId | ||
The id of the solution that you want to work against | ||
This can be obtained from the Get-BapEnvironmentSolution cmdlet | ||
.PARAMETER Path | ||
Path to the location that you want the files to be exported to | ||
.EXAMPLE | ||
PS C:\> Export-BapEnvironmentSolution -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -SolutionId 3ac10775-0808-42e0-bd23-83b6c714972f -Path "C:\Temp\" | ||
This will export the solution from the environment. | ||
It will extract the files into the "C:\Temp\" location. | ||
.NOTES | ||
Author: Mötz Jensen (@Splaxi) | ||
#> | ||
function Export-BapEnvironmentSolution { | ||
[CmdletBinding()] | ||
param ( | ||
[parameter (mandatory = $true)] | ||
[string] $EnvironmentId, | ||
|
||
[parameter (mandatory = $true)] | ||
[string] $SolutionId, | ||
|
||
[parameter (mandatory = $true)] | ||
[string] $Path | ||
) | ||
|
||
begin { | ||
# Make sure all *BapEnvironment* cmdlets will validate that the environment exists prior running anything. | ||
$envObj = Get-BapEnvironment -EnvironmentId $EnvironmentId | Select-Object -First 1 | ||
|
||
if ($null -eq $envObj) { | ||
$messageString = "The supplied EnvironmentId: <c='em'>$EnvironmentId</c> didn't return any matching environment details. Please verify that the EnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet." | ||
Write-PSFMessage -Level Host -Message $messageString | ||
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', ''))) | ||
} | ||
|
||
if (Test-PSFFunctionInterrupt) { return } | ||
|
||
$solObj = Get-BapEnvironmentSolution -EnvironmentId $EnvironmentId -SolutionId $SolutionId | Select-Object -First 1 | ||
|
||
if ($null -eq $solObj) { | ||
$messageString = "The supplied SolutionId: <c='em'>$SolutionId</c> didn't return any matching solution from the environment. Please verify that the SolutionId is correct - try running the <c='em'>Get-BapEnvironmentSolution</c> cmdlet." | ||
Write-PSFMessage -Level Host -Message $messageString | ||
Stop-PSFFunction -Message "Stopping because solution was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', ''))) | ||
} | ||
} | ||
|
||
process { | ||
if (Test-PSFFunctionInterrupt) { return } | ||
|
||
$tmp = pac org list --filter $EnvironmentId | ||
|
||
Write-PSFMessage -Level Host -Message "<c='em'>$($tmp[0])</c>" | ||
|
||
$found = $false | ||
foreach ($line in $tmp) { | ||
$found = $line -like "*$EnvironmentId*" | ||
|
||
if ($found) { | ||
break | ||
} | ||
} | ||
|
||
if (-not $found) { | ||
$messageString = "It seems that the current pac cli session isn't connected to the correct tenant. Please run the <c='em'>pac auth create --name 'ChangeThis'</c> and make sure to use credentials that have enough privileges." | ||
Write-PSFMessage -Level Host -Message $messageString | ||
Stop-PSFFunction -Message "Stopping because pac cli session is NOT connected to the correct tenant." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', ''))) | ||
} | ||
|
||
if (Test-PSFFunctionInterrupt) { return } | ||
|
||
# pac cli is connected to the correct tenant | ||
$pathDownload = [System.IO.Path]::ChangeExtension([System.IO.Path]::GetTempFileName(), 'zip') | ||
|
||
$tmp = pac solution export --name $solObj.SystemName --environment $EnvironmentId --path $pathDownload --overwrite | ||
|
||
if (-not (($tmp | Select-Object -Last 1) -eq "Solution export succeeded.")) { | ||
$messageString = "It seems that export of the solution encountered some kind of error. Please run the cmdlet <c='em'>again in a few minutes</c>." | ||
Write-PSFMessage -Level Host -Message $messageString | ||
Stop-PSFFunction -Message "Stopping because export failed." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', ''))) | ||
} | ||
|
||
Expand-Archive -Path $pathDownload -DestinationPath $Path -Force | ||
|
||
# Give the file system time to persis the extracted files. | ||
Start-Sleep -Seconds 2 | ||
|
||
Remove-Item -LiteralPath $(Join-Path -Path $Path -ChildPath "[Content_Types].xml") -ErrorAction SilentlyContinue -Force | ||
} | ||
|
||
end { | ||
|
||
} | ||
} |
Oops, something went wrong.