developer/api/v1/versions/Publish-VersionArchive.ps1

function Publish-VersionArchive
{
    param(
        [Parameter(Mandatory)]
        [string] $AppAlias,
        [Parameter(Mandatory)]
        [string] $VersionAlias,
        [string] $ArchiveUri,
        [string] $FilePath,
        [ValidateSet("constructive", "destructive")]
        [string] $PatchMode = "destructive",
        [ValidateSet("Definition", "Sandbox", "Published")]
        [string] $Stage = "Definition",
        [string] $NewVersionAlias,
        [string] $NewVersionName
    )

    if ($Stage -eq "Published" -and (!$NewVersionAlias -or !$NewVersionName))
    {
        throw [ArgumentException] "NewVersionAlias and NewVersionName must be specified if Stage is Published"
    }

    if (!$ArchiveUri -and !$FilePath)
    {
        throw [ArgumentException] "Either ArchiveUri or FilePath must be specified."
    }

    if ($ArchiveUri -and $FilePath)
    {
        throw [ArgumentException] "ArchiveUri and FilePath cannot be used together."
    }

    $query = "?action=patch&patchMode=$PatchMode&stage=$Stage"

    if ($Stage -eq "Published")
    {
        $query += "&newVersionAlias=$NewVersionAlias&newVersionName=$NewVersionName"
    }

    if ($ArchiveUri)
    {
        $query += "&archiveUri=$ArchiveUri"

        return Invoke-Api Post "/developer/api/v1/versions/$AppAlias/$VersionAlias/$query"
    }
    
    return Invoke-Api Post "/developer/api/v1/versions/$AppAlias/$VersionAlias/$query" -FileBody $FilePath
}