diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000000..9fba9e1963 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,147 @@ +# CI process script for Snap.Hutao +# Usage: +# 1. Append the script in Pipelines +# 2. Upload the pfx and cer certificates to Pipelines Library secrets +# 3. Permit the pfx usage +# 4. Add a `pw` variable in the script variables, which is pfx password +# 5. Connect the GitHub in project settings +# 6. Run + +trigger: +- main + +pool: + vmImage: 'windows-2022' + +variables: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + solution: '$(Build.SourcesDirectory)/src/Snap.Hutao/Snap.Hutao.sln' + project: $(Build.SourcesDirectory)/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj' + buildPlatform: 'x64' + buildConfiguration: 'Release' + build_date: $[ format('{0:yyyy}.{0:MM}.{0:dd}', pipeline.startTime) ] + + +steps: +- task: GetRevision@1 + displayName: get Pipelines revision number + inputs: + VariableName: 'rev_number' + +- task: UseDotNet@2 + displayName: Install dotNet + inputs: + packageType: 'sdk' + version: '7.x' + includePreviewVersions: true + +- task: NuGetToolInstaller@1 + name: 'NuGetToolInstaller' + displayName: 'NuGet Installer' + +- task: NuGetCommand@2 + displayName: NuGet restore + inputs: + command: 'restore' + restoreSolution: '$(solution)' + feedsToUse: 'select' + +- task: MsixPackaging@1 + displayName: Build binary package + inputs: + outputPath: '$(Build.ArtifactStagingDirectory)/' + solution: '$(solution)' + clean: false + generateBundle: false + buildConfiguration: 'Release' + buildPlatform: 'x64' + updateAppVersion: false + appPackageDistributionMode: 'SideloadOnly' + msbuildLocationMethod: 'location' + msbuildLocation: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Msbuild\Current\Bin\MSBuild.exe' + +- task: MagicChunks@2 + inputs: + sourcePath: '$(Build.SourcesDirectory)\src\Snap.Hutao\Snap.Hutao\bin\x64\Release\net7.0-windows10.0.18362.0\win10-x64\AppxManifest.xml' + fileType: 'Xml' + targetPathType: 'source' + transformationType: 'json' + transformations: | + { + "Package/Identity/@Name": "7f0db578-026f-4e0b-a75b-d5d06bb0a74c", + "Package/Identity/@Publisher": "CN=DGP Studio CI", + "Package/Identity/@Version": "$(build_date).$(rev_number)", + "Package/Properties/DisplayName": "胡桃 Alpha", + "Package/Properties/PublisherDisplayName":"DGP Studio CI" + } + +- task: CmdLine@2 + displayName: Create resources folder + inputs: + script: | + mkdir Assets + + mkdir Resource + workingDirectory: '$(Build.SourcesDirectory)\src\Snap.Hutao\Snap.Hutao\bin\x64\Release\net7.0-windows10.0.18362.0\win10-x64' + + +- task: CopyFiles@2 + displayName: Copy Assets Folder + inputs: + SourceFolder: '$(Build.SourcesDirectory)\src\Snap.Hutao\Snap.Hutao\Assets' + Contents: '**' + TargetFolder: '$(Build.SourcesDirectory)\src\Snap.Hutao\Snap.Hutao\bin\x64\Release\net7.0-windows10.0.18362.0\win10-x64\Assets' + +- task: CopyFiles@2 + displayName: Copy Resource Folder + inputs: + SourceFolder: '$(Build.SourcesDirectory)\src\Snap.Hutao\Snap.Hutao\Resource' + Contents: '**' + TargetFolder: '$(Build.SourcesDirectory)\src\Snap.Hutao\Snap.Hutao\bin\x64\Release\net7.0-windows10.0.18362.0\win10-x64\Resource' + +- task: CmdLine@2 + displayName: Build MSIX + inputs: + script: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64\makeappx.exe" pack /d $(Build.SourcesDirectory)\src\Snap.Hutao\Snap.Hutao\bin\x64\Release\net7.0-windows10.0.18362.0\win10-x64 /p $(Build.ArtifactStagingDirectory)/Snap.Hutao.Alpha-$(build_date).$(rev_number).msix' + +- task: MsixSigning@1 + displayName: Sign MSIX package + inputs: + package: '$(Build.ArtifactStagingDirectory)/Snap.Hutao.Alpha-$(build_date).$(rev_number).msix' + certificate: 'DGP_Studio_CI.pfx' + passwordVariable: 'pw' + +- task: PublishPipelineArtifact@1 + displayName: 'Upload Output' + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)/' + artifact: 'Output' + publishLocation: 'pipeline' + +- task: DownloadSecureFile@1 + name: cerFile + displayName: Download Root CA + inputs: + secureFile: 'Snap.Hutao.CI.cer' + +- task: GitHubRelease@1 + inputs: + gitHubConnection: 'github.com_Masterain' + repositoryName: 'DGP-Studio/Snap.Hutao' + action: 'create' + target: '$(Build.SourceVersion)' + tagSource: 'userSpecifiedTag' + tag: '$(build_date).$(rev_number)' + title: '$(build_date).$(rev_number)' + releaseNotesSource: 'inline' + releaseNotesInline: | + ## 提示 (Hint) + 该发布版本由 CI 程序自动打包生成,属于 `Alpha` 测试版,仅用于开发调试和内部测试用途。使用该版本可能存在意料之外的风险,请仅在有明确用途的情况下使用该版本。 + + This release is a Alpha Testing version generated by CI program automatically in a purpose of debugging and interal testing. Using this release may have unexpected risk, please only use it when you know what you are doing. + assets: | + $(Build.ArtifactStagingDirectory)/* + $(cerFile.secureFilePath) + isPreRelease: true + changeLogCompareToRelease: 'lastFullRelease' + changeLogType: 'commitBased' \ No newline at end of file