Skip to content

Check if apps are already installed on a higher version before deploying #1756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Actions/Deploy/Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ function CheckIfAppNeedsInstallOrUpgrade {
return $needsInstall, $needsUpgrade
}

# Check if the apps are already installed and emit a warning if the installed version is higher than the version in the app file
function CheckInstalledApps {
Param(
[hashtable] $bcAuthContext,
[string] $environment,
[string[]] $appFiles
)

$installedApps = Get-BcInstalledExtensions -bcAuthContext $bcAuthContext -environment $environment | Where-Object { $_.isInstalled }
foreach($appFile in $appFiles) {
# Get AppJson (works for full .app files, symbol files and also runtime packages)
$appJson = Get-AppJsonFromAppFile -appFile $appFile
$installedApp = $installedApps | Where-Object { $_.id -eq $appJson.id }

# Check if the version of the installed app is lower than the version in the app file
if ($installedApp) {
$currentVersion = [version]::new($appJson.Version)
$installedVersion = [version]::new($installedApp.versionMajor, $installedApp.versionMinor, $installedApp.versionBuild, $installedApp.versionRevision)

if ($currentVersion -lt $installedVersion) {
Write-Host "::WARNING::App $($appJson.name) is already installed in version $installedVersion, which is higher than $currentVersion, used in app.json. In order to install version $currentVersion, the higher version must be uninstalled first."
}
}
}
}

function InstallOrUpgradeApps {
Param(
[hashtable] $bcAuthContext,
Expand Down Expand Up @@ -403,6 +429,9 @@ else {
if ($syncMode -eq 'ForceSync') { $syncMode = 'Force' }
$parameters += @{ "SchemaSyncMode" = $syncMode }
}

CheckInstalledApps -bcAuthContext $bcAuthContext -environment $deploymentSettings.EnvironmentName -appFiles $apps

Write-Host "Publishing apps using automation API"
Publish-PerTenantExtensionApps @parameters
}
Expand Down
3 changes: 2 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ AL-Go now offers a dataexplorer dashboard to get started with AL-Go telemetry. A
### Issues

- Issue 1770 Wrong type of _projects_ setting in settings schema
- Issue 1787: Publish to Environment from PR fails in private repos
- Issue 1787 Publish to Environment from PR fails in private repos
- Issue 1722 Check if apps are already installed on a higher version before deploying

### Add custom jobs to AL-Go workflows

Expand Down
Loading