Skip to content
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
28 changes: 20 additions & 8 deletions .github/workflows/copilot-build-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,35 @@ jobs:
- uses: actions/checkout@v3
with:
clean: true
fetch-depth: 0

- name: Package Copilot Chat WebAPI
run: |
scripts\deploy\package-webapi.ps1 -Configuration Release -DotnetFramework net6.0 -TargetRuntime win-x64 -OutputDirectory ${{ github.workspace }}\scripts\deploy
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'

- name: Check formatting of Copilot Chat WebAPI
run: |
cd webapi/
dotnet format --verify-no-changes --verbosity diagnostic
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0

- name: Set version tag
id: versiontag
run: |
$VERSION_TAG="$(Get-Date -Format "MMddHHmmss")"
$VERSION_TAG = "${{ steps.gitversion.outputs.Major }}."
$VERSION_TAG += "${{ steps.gitversion.outputs.Minor }}."
$VERSION_TAG += "${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
echo $VERSION_TAG
Write-Output "versiontag=$VERSION_TAG" >> $env:GITHUB_OUTPUT

- name: Package Copilot Chat WebAPI
run: |
scripts\deploy\package-webapi.ps1 -Configuration Release -DotnetFramework net6.0 -TargetRuntime win-x64 -OutputDirectory ${{ github.workspace }}\scripts\deploy -Version ${{ steps.versiontag.outputs.versiontag }} -InformationalVersion "Built from commit ${{ steps.gitversion.outputs.ShortSha }} on $(Get-Date -Format "yyyy-MM-dd")"

- name: Check formatting of Copilot Chat WebAPI
run: |
cd webapi/
dotnet format --verify-no-changes --verbosity diagnostic

- name: Upload package to artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/copilot-deploy-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- uses: actions/checkout@v3
with:
clean: true
fetch-depth: 0

- name: Install Azure CLI
run: |
Expand Down Expand Up @@ -69,6 +70,24 @@ jobs:
echo "::add-mask::$swaToken"
echo "SWA_CLI_DEPLOYMENT_TOKEN=$swaToken" >> $GITHUB_ENV

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'

- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0

- name: Set version tag
id: versiontag
run: |
$VERSION_TAG = "${{ steps.gitversion.outputs.Major }}."
$VERSION_TAG += "${{ steps.gitversion.outputs.Minor }}."
$VERSION_TAG += "${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
echo $VERSION_TAG
Write-Output "versiontag=$VERSION_TAG" >> $env:GITHUB_OUTPUT

- name: Deploy SWA
run: |
scripts/deploy/deploy-webapp.sh --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} --resource-group ${{vars.CC_DEPLOYMENT_GROUP_NAME}} --deployment-name ${{inputs.DEPLOYMENT_NAME}} --application-id ${{vars.APPLICATION_CLIENT_ID}} --authority ${{secrets.APPLICATION_AUTHORITY}} --no-redirect
scripts/deploy/deploy-webapp.sh --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} --resource-group ${{vars.CC_DEPLOYMENT_GROUP_NAME}} --deployment-name ${{inputs.DEPLOYMENT_NAME}} --application-id ${{vars.APPLICATION_CLIENT_ID}} --authority ${{secrets.APPLICATION_AUTHORITY}} --no-redirect -version ${{ steps.versiontag.outputs.versiontag }} -version-info "Built from commit ${{ steps.gitversion.outputs.ShortSha }} on $(Get-Date -Format "yyyy-MM-dd")"
107 changes: 0 additions & 107 deletions .github/workflows/update-version.sh

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -485,5 +485,8 @@ webapp/public/.well-known*
# Auto-generated solution file from Visual Studio
webapi/CopilotChatWebApi.sln

# Files created for deployments
/deploy/

# Tesseract OCR language data files
*.traineddata
*.traineddata
12 changes: 11 additions & 1 deletion scripts/deploy/deploy-webapp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ param(
[Parameter(Mandatory=$false)]
[string]
# Authority for client applications that are not configured as multi-tenant.
$Authority="https://login.microsoftonline.com/common"
$Authority="https://login.microsoftonline.com/common",

[string]
# Version to display in UI.
$Version = "",

[string]
# Additional information given in version info. (Ex: commit SHA)
$VersionInfo = ""
)

Write-Host "Setting up Azure credentials..."
Expand Down Expand Up @@ -64,6 +72,8 @@ Write-Host "Writing environment variables to '$envFilePath'..."
"REACT_APP_AAD_AUTHORITY=$Authority" | Out-File -FilePath $envFilePath -Append
"REACT_APP_AAD_CLIENT_ID=$ApplicationClientId" | Out-File -FilePath $envFilePath -Append
"REACT_APP_SK_API_KEY=$webapiApiKey" | Out-File -FilePath $envFilePath -Append
"REACT_APP_SK_VERSION=$Version" | Out-File -FilePath $envFilePath -Append
"REACT_APP_SK_BUILD_INFO=$VersionInfo" | Out-File -FilePath $envFilePath -Append

Write-Host "Generating SWA config..."
$swaConfig = $(Get-Content "$PSScriptRoot/../../webapp/template.swa-cli.config.json" -Raw)
Expand Down
14 changes: 14 additions & 0 deletions scripts/deploy/deploy-webapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ usage() {
echo " -d, --deployment-name DEPLOYMENT_NAME Name of the deployment from a 'deploy-azure.sh' deployment (mandatory)"
echo " -a, --application-id APPLICATION_ID Client application ID (mandatory)"
echo " -au, --authority Authority to use for client applications that are not configured as multi-tenant. Defaults to (https://login.microsoftonline.com/common) if not specified."
echo " -v --version VERSION Version to display in UI (default: 1.0.0)"
echo " -i --version-info INFO Additional info to put in version details"
echo " -nr, --no-redirect Do not attempt to register redirect URIs with the client application"
}

Expand Down Expand Up @@ -47,6 +49,16 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
-v|--version)
VERSION="$2"
shift
shift
;;
-i|--version-nfo)
VERSION_INFO="$2"
shift
shift
;;
-nr|--no-redirect)
NO_REDIRECT=true
shift
Expand Down Expand Up @@ -97,6 +109,8 @@ echo "REACT_APP_BACKEND_URI=https://$WEB_API_URL/" > $ENV_FILE_PATH
echo "REACT_APP_AAD_AUTHORITY=$AUTHORITY" >> $ENV_FILE_PATH
echo "REACT_APP_AAD_CLIENT_ID=$APPLICATION_ID" >> $ENV_FILE_PATH
echo "REACT_APP_SK_API_KEY=$WEB_API_KEY" >> $ENV_FILE_PATH
echo "REACT_APP_SK_VERSION=$VERSION" >> $ENV_FILE_PATH
echo "REACT_APP_SK_BUILD_INFO=$VERSION_INFO" >> $ENV_FILE_PATH

echo "Writing swa-cli.config.json..."
SWA_CONFIG_FILE_PATH="$SCRIPT_ROOT/../../webapp/swa-cli.config.json"
Expand Down
12 changes: 10 additions & 2 deletions scripts/deploy/package-webapi.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ param(

[string]
# Output directory for published assets.
$OutputDirectory = "$PSScriptRoot"
$OutputDirectory = "$PSScriptRoot",

[string]
# Version to give to assemblies and files.
$Version = "1.0.0",

[string]
# Additional information given in version info.
$InformationalVersion = ""
)

Write-Host "BuildConfiguration: $BuildConfiguration"
Expand All @@ -37,7 +45,7 @@ if (!(Test-Path $publishOutputDirectory)) {
}

Write-Host "Build configuration: $BuildConfiguration"
dotnet publish "$PSScriptRoot/../../webapi/CopilotChatWebApi.csproj" --configuration $BuildConfiguration --framework $DotNetFramework --runtime $TargetRuntime --self-contained --output "$publishOutputDirectory"
dotnet publish "$PSScriptRoot/../../webapi/CopilotChatWebApi.csproj" --configuration $BuildConfiguration --framework $DotNetFramework --runtime $TargetRuntime --self-contained --output "$publishOutputDirectory" /p:AssemblyVersion=$Version /p:FileVersion=$Version /p:InformationalVersion=$InformationalVersion
Comment thread
glahaye marked this conversation as resolved.
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Expand Down
18 changes: 16 additions & 2 deletions scripts/deploy/package-webapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ usage() {
echo " -c, --configuration CONFIGURATION Build configuration (default: Release)"
echo " -d, --dotnet DOTNET_FRAMEWORK_VERSION Target dotnet framework (default: net6.0)"
echo " -r, --runtime TARGET_RUNTIME Runtime identifier (default: linux-x64)"
echo " -p, --output OUTPUT_DIRECTORY Output directory (default: $SCRIPT_ROOT)"
echo " -o, --output OUTPUT_DIRECTORY Output directory (default: $SCRIPT_ROOT)"
echo " -v --version VERSION Version to set files to (default: 1.0.0)"
echo " -i --info INFO Additional info to put in version details"
echo " -nz, --no-zip Do not zip package (default: false)"
}

Expand Down Expand Up @@ -42,6 +44,16 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
-v|--version)
VERSION="$2"
shift
shift
;;
-i|--info)
INFO="$2"
shift
shift
;;
-nz|--no-zip)
NO_ZIP=true
shift
Expand All @@ -58,6 +70,8 @@ done
: "${CONFIGURATION:="Release"}"
: "${DOTNET:="net6.0"}"
: "${RUNTIME:="linux-x64"}"
: "${VERSION:="1.0.0"}"
: "${INFO:=""}"
: "${OUTPUT_DIRECTORY:="$SCRIPT_ROOT"}"

PUBLISH_OUTPUT_DIRECTORY="$OUTPUT_DIRECTORY/publish"
Expand All @@ -72,7 +86,7 @@ if [[ ! -d "$PUBLISH_ZIP_DIRECTORY" ]]; then
fi

echo "Build configuration: $CONFIGURATION"
dotnet publish "$SCRIPT_ROOT/../../webapi/CopilotChatWebApi.csproj" --configuration $CONFIGURATION --framework $DOTNET --runtime $RUNTIME --self-contained --output "$PUBLISH_OUTPUT_DIRECTORY"
dotnet publish "$SCRIPT_ROOT/../../webapi/CopilotChatWebApi.csproj" --configuration $CONFIGURATION --framework $DOTNET --runtime $RUNTIME --self-contained --output "$PUBLISH_OUTPUT_DIRECTORY" /p:AssemblyVersion=$VERSION /p:FileVersion=$VERSION /p:InformationalVersion=$INFO
if [ $? -ne 0 ]; then
exit 1
fi
Expand Down
29 changes: 20 additions & 9 deletions webapi/Controllers/ServiceOptionsController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Diagnostics;
using System.Reflection;
using CopilotChat.WebApi.Models.Response;
using CopilotChat.WebApi.Options;
using Microsoft.AspNetCore.Authorization;
Expand Down Expand Up @@ -39,15 +41,24 @@ public ServiceOptionsController(
[ProducesResponseType(StatusCodes.Status200OK)]
public IActionResult GetServiceOptions()
{
return this.Ok(
new ServiceOptionsResponse()
var response = new ServiceOptionsResponse()
{
MemoryStore = new MemoryStoreOptionResponse()
{
MemoryStore = new MemoryStoreOptionResponse()
{
Types = Enum.GetNames(typeof(MemoryStoreOptions.MemoryStoreType)),
SelectedType = this._memoryStoreOptions.Type.ToString()
}
}
);
Types = Enum.GetNames(typeof(MemoryStoreOptions.MemoryStoreType)),
SelectedType = this._memoryStoreOptions.Type.ToString()
},
Version = GetAssemblyFileVersion()
};

return this.Ok(response);
}

private static string GetAssemblyFileVersion()
{
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(assembly.Location);
Comment thread
glahaye marked this conversation as resolved.

return fileVersion.FileVersion ?? string.Empty;
}
}
6 changes: 6 additions & 0 deletions webapi/Models/Response/ServiceOptionsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public class ServiceOptionsResponse
/// </summary>
[JsonPropertyName("memoryStore")]
public MemoryStoreOptionResponse MemoryStore { get; set; } = new MemoryStoreOptionResponse();

/// <summary>
/// Version of this application.
/// </summary>
[JsonPropertyName("version")]
public string Version { get; set; } = string.Empty;
}
Comment thread
glahaye marked this conversation as resolved.

/// <summary>
Expand Down
Loading