Set up CI with Azure Pipelines
[skip ci]
This commit is contained in:
@@ -1,92 +1,64 @@
|
|||||||
# ASP.NET Core
|
# ASP.NET
|
||||||
# Build and test ASP.NET Core projects targeting .NET Core.
|
# Build and test ASP.NET projects.
|
||||||
# Add steps that run tests, create a NuGet package, deploy, and more:
|
# Add steps that publish symbols, save build artifacts, deploy, and more:
|
||||||
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
|
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
pr:
|
|
||||||
- none
|
|
||||||
|
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'windows-latest'
|
vmImage: 'windows-latest'
|
||||||
|
|
||||||
name: 'This is changed in a task, below'
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
projectName: 'Gameboard.ShogiUI.Sockets'
|
solution: '**/*.sln'
|
||||||
version.MajorMinor: '1.0' # Manually change this when needed to follow semver.
|
buildPlatform: 'Any CPU'
|
||||||
version.Patch: $[counter(variables['version.MajorMinor'], 0)]
|
buildConfiguration: 'Release'
|
||||||
versionNumber: '$(version.MajorMinor).$(version.Patch)'
|
apiProjectName: 'Shogi.Api'
|
||||||
|
uiProjectName: 'Shogi.UI'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
# https://github.com/microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md#build-logging-commands
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: Set the name of the build (i.e. the Build.BuildNumber)
|
|
||||||
inputs:
|
|
||||||
targetType: 'inline'
|
|
||||||
script: |
|
|
||||||
[string] $buildName = "$(versionNumber)"
|
|
||||||
Write-Host "Setting the name of the build to '$buildName'."
|
|
||||||
Write-Host "##vso[build.updatebuildnumber]$buildName"
|
|
||||||
|
|
||||||
- task: NuGetToolInstaller@1
|
- task: NuGetToolInstaller@1
|
||||||
|
|
||||||
- task: NuGetCommand@2
|
- task: NuGetCommand@2
|
||||||
inputs:
|
inputs:
|
||||||
command: 'restore'
|
restoreSolution: '$(solution)'
|
||||||
restoreSolution: '**/*.sln'
|
|
||||||
feedsToUse: 'config'
|
|
||||||
|
|
||||||
- task: DotNetCoreCLI@2
|
|
||||||
displayName: Publish
|
|
||||||
env :
|
|
||||||
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
|
||||||
inputs:
|
|
||||||
command: 'publish'
|
|
||||||
publishWebProjects: false
|
|
||||||
projects: '**/*.csproj'
|
|
||||||
zipAfterPublish: false
|
|
||||||
arguments: '-c Release'
|
|
||||||
|
|
||||||
- task: FileTransform@1
|
- task: FileTransform@1
|
||||||
inputs:
|
inputs:
|
||||||
folderPath: '$(System.DefaultWorkingDirectory)'
|
folderPath: '$(System.DefaultWorkingDirectory)\$(uiProjectName)'
|
||||||
fileType: 'json'
|
fileType: 'json'
|
||||||
targetFiles: '**/appsettings.json'
|
targetFiles: 'wwwroot/appsettings.json'
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
inputs:
|
||||||
|
command: 'publish'
|
||||||
|
publishWebProjects: false
|
||||||
|
arguments: '-c Release'
|
||||||
|
zipAfterPublish: false
|
||||||
|
|
||||||
- task: CopyFilesOverSSH@0
|
- task: CopyFilesOverSSH@0
|
||||||
displayName: SSH Copy to 1UB
|
displayName: "Copy API files."
|
||||||
inputs:
|
inputs:
|
||||||
sshEndpoint: 'LucaServer'
|
sshEndpoint: 'LucaServer'
|
||||||
sourceFolder: '$(System.DefaultWorkingDirectory)\$(projectName)\bin\Release\net6.0\publish'
|
sourceFolder: '$(System.DefaultWorkingDirectory)/$(apiProjectName)/bin/Release/net6.0/publish'
|
||||||
targetFolder: '/var/www/apps/$(projectName)'
|
|
||||||
contents: '**'
|
contents: '**'
|
||||||
failOnEmptySource: true
|
targetFolder: '/var/www/apps/$(apiProjectName)'
|
||||||
cleanTargetFolder: true
|
readyTimeout: '20000'
|
||||||
|
|
||||||
|
- task: CopyFilesOverSSH@0
|
||||||
|
displayName: "Copy UI files."
|
||||||
|
inputs:
|
||||||
|
sshEndpoint: 'LucaServer'
|
||||||
|
sourceFolder: '$(System.DefaultWorkingDirectory)/$(uiProjectName)/bin/Release/net6.0/publish'
|
||||||
|
contents: '**'
|
||||||
|
targetFolder: '/var/www/apps/$(uiProjectName)'
|
||||||
|
readyTimeout: '20000'
|
||||||
|
|
||||||
- task: SSH@0
|
- task: SSH@0
|
||||||
displayName: Restart Kestrel
|
displayName: "Restart Kestrel"
|
||||||
inputs:
|
inputs:
|
||||||
sshEndpoint: 'LucaServer'
|
sshEndpoint: 'LucaServer'
|
||||||
runOptions: 'commands'
|
runOptions: 'commands'
|
||||||
commands: 'sudo systemctl restart kestrel-gameboard.shogiui.sockets.service'
|
commands: 'sudo systemctl restart kestrel-shogi.api.service'
|
||||||
readyTimeout: '20000'
|
readyTimeout: '20000'
|
||||||
|
|
||||||
- task: DotNetCoreCLI@2
|
|
||||||
displayName: 'Pack ServiceModels'
|
|
||||||
inputs:
|
|
||||||
command: 'pack'
|
|
||||||
packagesToPack: '**/*ServiceModels*.csproj'
|
|
||||||
versioningScheme: byBuildNumber
|
|
||||||
arguments: '-c Release'
|
|
||||||
|
|
||||||
- task: DotNetCoreCLI@2
|
|
||||||
displayName: 'Push NuGet packages to Feed'
|
|
||||||
inputs:
|
|
||||||
command: 'push'
|
|
||||||
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
|
|
||||||
nuGetFeedType: 'internal'
|
|
||||||
publishVstsFeed: '5622b603-b328-44aa-a6e8-8ca56ff54f88/22948853-baa7-4774-b19d-3aed351711c7'
|
|
||||||
Reference in New Issue
Block a user