IW4M-Admin/DeploymentFiles/deployment-pipeline.yml

244 lines
7.7 KiB
YAML
Raw Permalink Normal View History

2020-10-24 22:59:10 -04:00
name: '$(Date:yyyy.MM.dd)$(Rev:.r)'
2020-10-24 22:45:30 -04:00
trigger:
batch: true
branches:
include:
- release/pre
2020-10-24 22:59:10 -04:00
- master
2020-10-24 22:45:30 -04:00
pr: none
pool:
2022-01-26 16:53:07 -05:00
vmImage: 'windows-2022'
2020-10-24 22:45:30 -04:00
variables:
solution: 'IW4MAdmin.sln'
buildPlatform: 'Any CPU'
outputFolder: '$(Build.ArtifactStagingDirectory)\Publish\$(buildConfiguration)'
2020-10-24 22:59:10 -04:00
releaseType: verified
buildConfiguration: Stable
isPreRelease: false
2020-10-24 22:45:30 -04:00
steps:
2022-01-26 16:53:07 -05:00
- task: UseDotNet@2
displayName: 'Install .NET Core 6 SDK'
inputs:
packageType: 'sdk'
version: '6.0.x'
includePreviewVersions: true
- task: NuGetToolInstaller@1
2020-10-24 22:59:10 -04:00
- task: PowerShell@2
displayName: 'Setup Pre-Release configuration'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/release/pre')
inputs:
targetType: 'inline'
script: |
echo '##vso[task.setvariable variable=releaseType]prerelease'
echo '##vso[task.setvariable variable=buildConfiguration]Prerelease'
echo '##vso[task.setvariable variable=isPreRelease]true'
2020-10-24 22:59:10 -04:00
failOnStderr: true
2022-01-26 16:53:07 -05:00
2020-10-24 22:45:30 -04:00
- task: NuGetCommand@2
2020-10-24 22:59:10 -04:00
displayName: 'Restore nuget packages'
2020-10-24 22:45:30 -04:00
inputs:
restoreSolution: '$(solution)'
- task: PowerShell@2
2020-10-24 22:59:10 -04:00
displayName: 'Preload external resources'
2020-10-24 22:45:30 -04:00
inputs:
targetType: 'inline'
script: |
2020-10-24 22:59:10 -04:00
Write-Host 'Build Configuration is $(buildConfiguration), Release Type is $(releaseType)'
2020-10-24 22:45:30 -04:00
md -Force lib\open-iconic\font\css
wget https://raw.githubusercontent.com/iconic/open-iconic/master/font/css/open-iconic-bootstrap.scss -o lib\open-iconic\font\css\open-iconic-bootstrap.scss
failOnStderr: true
workingDirectory: '$(Build.Repository.LocalPath)\WebfrontCore\wwwroot'
- task: VSBuild@1
2020-10-24 22:59:10 -04:00
displayName: 'Build projects'
2020-10-24 22:45:30 -04:00
inputs:
solution: '$(solution)'
2020-10-24 22:59:10 -04:00
msbuildArgs: '/p:DeployOnBuild=false /p:PackageAsSingleFile=false /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)" /p:Version=$(Build.BuildNumber)'
2020-10-24 22:45:30 -04:00
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
2022-01-26 16:53:07 -05:00
- task: PowerShell@2
displayName: 'Bundle JS Files'
inputs:
targetType: 'inline'
script: |
Write-Host 'Getting dotnet bundle'
wget http://raidmax.org/IW4MAdmin/res/dotnet-bundle.zip -o $(Build.Repository.LocalPath)\dotnet-bundle.zip
2022-01-26 16:53:07 -05:00
Write-Host 'Unzipping download'
Expand-Archive -LiteralPath $(Build.Repository.LocalPath)\dotnet-bundle.zip -DestinationPath $(Build.Repository.LocalPath)
2022-01-26 16:53:07 -05:00
Write-Host 'Executing dotnet-bundle'
$(Build.Repository.LocalPath)\dotnet-bundle.exe $(Build.Repository.LocalPath)\WebfrontCore\bundleconfig.json
2022-01-26 16:53:07 -05:00
failOnStderr: true
workingDirectory: '$(Build.Repository.LocalPath)\WebfrontCore'
2020-10-24 22:45:30 -04:00
- task: DotNetCoreCLI@2
2020-10-24 22:59:10 -04:00
displayName: 'Publish projects'
2020-10-24 22:45:30 -04:00
inputs:
command: 'publish'
publishWebProjects: false
projects: |
**/WebfrontCore.csproj
**/Application.csproj
2020-10-24 22:59:10 -04:00
arguments: '-c $(buildConfiguration) -o $(outputFolder) /p:Version=$(Build.BuildNumber)'
2020-10-24 22:45:30 -04:00
zipAfterPublish: false
modifyOutputPath: false
- task: PowerShell@2
2020-10-24 22:59:10 -04:00
displayName: 'Run publish script 1'
2020-10-24 22:45:30 -04:00
inputs:
2020-10-24 22:59:10 -04:00
filePath: 'DeploymentFiles/PostPublish.ps1'
2020-10-24 22:45:30 -04:00
arguments: '$(outputFolder)'
failOnStderr: true
workingDirectory: '$(Build.Repository.LocalPath)'
- task: BatchScript@1
2020-10-24 22:59:10 -04:00
displayName: 'Run publish script 2'
2020-10-24 22:45:30 -04:00
inputs:
filename: 'Application\BuildScripts\PostPublish.bat'
workingFolder: '$(Build.Repository.LocalPath)'
arguments: '$(outputFolder) $(Build.Repository.LocalPath)'
2020-10-24 22:45:30 -04:00
failOnStandardError: true
2020-10-24 22:59:10 -04:00
- task: PowerShell@2
displayName: 'Download dos2unix for line endings'
inputs:
targetType: 'inline'
script: 'wget https://raidmax.org/downloads/dos2unix.exe'
failOnStderr: true
workingDirectory: '$(Build.Repository.LocalPath)\Application\BuildScripts'
2020-10-24 22:45:30 -04:00
- task: CmdLine@2
2020-10-24 22:59:10 -04:00
displayName: 'Convert Linux start script line endings'
2020-10-24 22:45:30 -04:00
inputs:
script: |
echo changing to encoding for linux start script
2022-01-31 18:56:43 -05:00
dos2unix $(outputFolder)\StartIW4MAdmin.sh
dos2unix $(outputFolder)\UpdateIW4MAdmin.sh
2020-10-24 22:45:30 -04:00
echo creating website version filename
2020-10-24 22:59:10 -04:00
@echo IW4MAdmin-$(Build.BuildNumber) > $(Build.ArtifactStagingDirectory)\version_$(releaseType).txt
2020-10-24 22:45:30 -04:00
workingDirectory: '$(Build.Repository.LocalPath)\Application\BuildScripts'
- task: CopyFiles@2
2020-10-24 22:59:10 -04:00
displayName: 'Move script plugins into publish directory'
2020-10-24 22:45:30 -04:00
inputs:
SourceFolder: '$(Build.Repository.LocalPath)\Plugins\ScriptPlugins'
Contents: '*.js'
TargetFolder: '$(outputFolder)\Plugins'
- task: CopyFiles@2
2020-10-24 22:59:10 -04:00
displayName: 'Move binary plugins into publish directory'
2020-10-24 22:45:30 -04:00
inputs:
SourceFolder: '$(Build.Repository.LocalPath)\BUILD\Plugins\'
Contents: '*.dll'
TargetFolder: '$(outputFolder)\Plugins'
- task: CmdLine@2
2020-10-24 22:59:10 -04:00
displayName: 'Move webfront resources into publish directory'
2020-10-24 22:45:30 -04:00
inputs:
script: 'xcopy /s /y /f wwwroot $(outputFolder)\wwwroot'
workingDirectory: '$(Build.Repository.LocalPath)\BUILD\Plugins'
failOnStderr: true
- task: CmdLine@2
2020-10-24 22:59:10 -04:00
displayName: 'Move gamescript files into publish directory'
2020-10-24 22:45:30 -04:00
inputs:
script: 'echo d | xcopy /s /y /f GameFiles $(outputFolder)\GameFiles'
workingDirectory: '$(Build.Repository.LocalPath)'
failOnStderr: true
- task: ArchiveFiles@2
2020-10-24 22:59:10 -04:00
displayName: 'Generate final zip file'
2020-10-24 22:45:30 -04:00
inputs:
rootFolderOrFile: '$(outputFolder)'
includeRootFolder: false
archiveType: 'zip'
2020-10-24 22:59:10 -04:00
archiveFile: '$(Build.ArtifactStagingDirectory)/IW4MAdmin-$(Build.BuildNumber).zip'
2020-10-24 22:45:30 -04:00
replaceExistingArchive: true
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/IW4MAdmin-$(Build.BuildNumber).zip'
artifact: 'IW4MAdmin-$(Build.BuildNumber).zip'
2021-11-20 21:37:11 -05:00
- task: FtpUpload@2
displayName: 'Upload zip file to website'
inputs:
credentialsOption: 'inputs'
serverUrl: '$(FTPUrl)'
username: '$(FTPUsername)'
password: '$(FTPPassword)'
rootDirectory: '$(Build.ArtifactStagingDirectory)'
filePatterns: '*.zip'
remoteDirectory: 'IW4MAdmin/Download'
clean: false
cleanContents: false
preservePaths: false
trustSSL: false
- task: FtpUpload@2
displayName: 'Upload version info to website'
inputs:
credentialsOption: 'inputs'
serverUrl: '$(FTPUrl)'
username: '$(FTPUsername)'
password: '$(FTPPassword)'
rootDirectory: '$(Build.ArtifactStagingDirectory)'
filePatterns: 'version_$(releaseType).txt'
remoteDirectory: 'IW4MAdmin'
clean: false
cleanContents: false
preservePaths: false
trustSSL: false
2020-10-24 22:45:30 -04:00
- task: GitHubRelease@1
2020-10-24 22:59:10 -04:00
displayName: 'Make GitHub release'
2020-10-24 22:45:30 -04:00
inputs:
gitHubConnection: 'github.com_RaidMax'
repositoryName: 'RaidMax/IW4M-Admin'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'userSpecifiedTag'
2020-10-24 22:59:10 -04:00
tag: '$(Build.BuildNumber)-$(releaseType)'
title: 'IW4MAdmin $(Build.BuildNumber) ($(releaseType))'
2020-10-24 22:45:30 -04:00
assets: '$(Build.ArtifactStagingDirectory)/*.zip'
isPreRelease: $(isPreRelease)
2020-10-24 22:45:30 -04:00
releaseNotesSource: 'inline'
releaseNotesInline: 'todo'
changeLogCompareToRelease: 'lastNonDraftRelease'
changeLogType: 'commitBased'
- task: PowerShell@2
2020-10-24 22:59:10 -04:00
displayName: 'Update master version'
2020-10-24 22:45:30 -04:00
inputs:
targetType: 'inline'
script: |
$payload = @{
2020-10-24 22:59:10 -04:00
'current-version-$(releaseType)' = '$(Build.BuildNumber)'
2020-10-24 22:45:30 -04:00
'jwt-secret' = '$(JWTSecret)'
} | ConvertTo-Json
$params = @{
Uri = 'http://api.raidmax.org:5000/version'
Method = 'POST'
Body = $payload
ContentType = 'application/json'
}
Invoke-RestMethod @params
- task: PublishPipelineArtifact@1
2020-10-24 22:59:10 -04:00
displayName: 'Publish artifact for analysis'
2020-10-24 22:45:30 -04:00
inputs:
targetPath: '$(outputFolder)'
artifact: 'IW4MAdmin.$(buildConfiguration)'
2020-10-24 22:59:10 -04:00
publishLocation: 'pipeline'