diff --git a/azure-devops/app-cd.yml b/azure-devops/app-cd.yml new file mode 100644 index 000000000..c7602df74 --- /dev/null +++ b/azure-devops/app-cd.yml @@ -0,0 +1,89 @@ +trigger: + branches: + include: + - master + - vnext + +# This pipeline is meant to build specific branches for deployment. It's not meant to be a part of PR validation. Ensure that this pipeline is reserved for deployment purposes. +pr: none + +name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) + +pool: + vmImage: ubuntu-latest + +variables: + githubToken: # Add a GitHub token in Libraries + ReplacementText: '@infragistics/igniteui-angular-extras' + +steps: + - checkout: self + clean: true + fetchTags: true + + - task: NodeTool@0 + displayName: Use Node 20.x + inputs: + versionSpec: 20.x + + - task: PowerShell@2 + displayName: 'Replace with licensed angular-extras' + inputs: + targetType: 'inline' + script: | + # List of files to update + $files = @( + "projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.module.ts", + "projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.component.ts", + "projects/app-lob/src/app/grid-dynamic-chart-data/data-analysis-dock-manager/data-analysis-dock-manager.component.ts", + "projects/app-lob/src/app/app.module.ts", + "package.json") + foreach ($file in $files) { + (Get-Content -Path $file) -replace 'igniteui-angular-extras', '$(ReplacementText)' | Set-Content -Path $file + } + + - task: CmdLine@2 + displayName: 'Create empty .npmrc file in the project root dir' + inputs: + script: 'touch $(Build.SourcesDirectory)/.npmrc' + failOnStderr: true + + - task: Npm@1 + displayName: 'Register licensed npm registry in .npmrc' + inputs: + command: 'custom' + workingDir: '$(Build.SourcesDirectory)' + customCommand: 'config -L project set @infragistics:registry=https://packages.infragistics.com/npm/js-licensed/' + customEndpoint: 'public proget' + + - task: npmAuthenticate@0 + inputs: + workingFile: '$(Build.SourcesDirectory)/.npmrc' + customEndpoint: 'public proget' + + - task: Npm@1 + displayName: npm install + inputs: + command: install + workingDir: $(Build.SourcesDirectory) + verbose: false + customEndpoint: 'public proget' + env: + AZURE_PIPELINES: true + + - task: CmdLine@2 + displayName: Clone submodule + inputs: + script: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples + workingDirectory: $(Build.SourcesDirectory) + + - template: templates/cd-template.yml + parameters: + customCommand: run generate-live-editing + workingDir: $(Build.SourcesDirectory) + submoduleDir: angular-demos + baseHref: \/angular-demos\/ + targetFolder: dist/app + findRegex: angular-demos + npmBuildCommand: 'run build-ci' + repositoryfy: true diff --git a/azure-devops/app-crm-cd-yml b/azure-devops/app-crm-cd-yml new file mode 100644 index 000000000..e8ba442a0 --- /dev/null +++ b/azure-devops/app-crm-cd-yml @@ -0,0 +1,89 @@ +trigger: + branches: + include: + - master + - vnext + +# This pipeline is meant to build specific branches for deployment. It's not meant to be a part of PR validation. Ensure that this pipeline is reserved for deployment purposes. +pr: none + +name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) + +pool: + vmImage: ubuntu-latest + +variables: + githubToken: # Add a GitHub token in Libraries + ReplacementText: '@infragistics/igniteui-angular-extras' + +steps: + - checkout: self + clean: true + fetchTags: true + + - task: NodeTool@0 + displayName: Use Node 20.x + inputs: + versionSpec: 20.x + + - task: PowerShell@2 + displayName: 'Replace with licensed angular-extras' + inputs: + targetType: 'inline' + script: | + # List of files to update + $files = @( + "projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.module.ts", + "projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.component.ts", + "projects/app-lob/src/app/grid-dynamic-chart-data/data-analysis-dock-manager/data-analysis-dock-manager.component.ts", + "projects/app-lob/src/app/app.module.ts", + "package.json") + foreach ($file in $files) { + (Get-Content -Path $file) -replace 'igniteui-angular-extras', '$(ReplacementText)' | Set-Content -Path $file + } + + - task: CmdLine@2 + displayName: 'Create empty .npmrc file in the project root dir' + inputs: + script: 'touch $(Build.SourcesDirectory)/.npmrc' + failOnStderr: true + + - task: Npm@1 + displayName: 'Register licensed npm registry in .npmrc' + inputs: + command: 'custom' + workingDir: '$(Build.SourcesDirectory)' + customCommand: 'config -L project set @infragistics:registry=https://packages.infragistics.com/npm/js-licensed/' + customEndpoint: 'public proget' + + - task: npmAuthenticate@0 + inputs: + workingFile: '$(Build.SourcesDirectory)/.npmrc' + customEndpoint: 'public proget' + + - task: Npm@1 + displayName: npm install + inputs: + command: install + workingDir: $(Build.SourcesDirectory) + verbose: false + customEndpoint: 'public proget' + env: + AZURE_PIPELINES: true + + - task: CmdLine@2 + displayName: Clone submodule + inputs: + script: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples + workingDirectory: $(Build.SourcesDirectory) + + - template: templates/cd-template.yml + parameters: + customCommand: run generate-live-editing:app-crm + workingDir: $(Build.SourcesDirectory) + submoduleDir: angular-demos-crm + baseHref: \/angular-demos-grid-crm\/ + targetFolder: dist/app-crm + findRegex: angular-demos + npmBuildCommand: 'run build-ci:app-crm --loglevel verbose' + repositoryfy: false diff --git a/azure-devops/app-lob-cd.yml b/azure-devops/app-lob-cd.yml new file mode 100644 index 000000000..4c85da2a8 --- /dev/null +++ b/azure-devops/app-lob-cd.yml @@ -0,0 +1,89 @@ +trigger: + branches: + include: + - master + - vnext + +# This pipeline is meant to build specific branches for deployment. It's not meant to be a part of PR validation. Ensure that this pipeline is reserved for deployment purposes. +pr: none + +name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) + +pool: + vmImage: ubuntu-latest + +variables: + githubToken: # Add a GitHub token in Libraries + ReplacementText: '@infragistics/igniteui-angular-extras' + +steps: + - checkout: self + clean: true + fetchTags: true + + - task: NodeTool@0 + displayName: Use Node 20.x + inputs: + versionSpec: 20.x + + - task: PowerShell@2 + displayName: 'Replace with licensed angular-extras' + inputs: + targetType: 'inline' + script: | + # List of files to update + $files = @( + "projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.module.ts", + "projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.component.ts", + "projects/app-lob/src/app/grid-dynamic-chart-data/data-analysis-dock-manager/data-analysis-dock-manager.component.ts", + "projects/app-lob/src/app/app.module.ts", + "package.json") + foreach ($file in $files) { + (Get-Content -Path $file) -replace 'igniteui-angular-extras', '$(ReplacementText)' | Set-Content -Path $file + } + + - task: CmdLine@2 + displayName: 'Create empty .npmrc file in the project root dir' + inputs: + script: 'touch $(Build.SourcesDirectory)/.npmrc' + failOnStderr: true + + - task: Npm@1 + displayName: 'Register licensed npm registry in .npmrc' + inputs: + command: 'custom' + workingDir: '$(Build.SourcesDirectory)' + customCommand: 'config -L project set @infragistics:registry=https://packages.infragistics.com/npm/js-licensed/' + customEndpoint: 'public proget' + + - task: npmAuthenticate@0 + inputs: + workingFile: '$(Build.SourcesDirectory)/.npmrc' + customEndpoint: 'public proget' + + - task: Npm@1 + displayName: npm install + inputs: + command: install + workingDir: $(Build.SourcesDirectory) + verbose: false + customEndpoint: 'public proget' + env: + AZURE_PIPELINES: true + + - task: CmdLine@2 + displayName: Clone submodule + inputs: + script: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples + workingDirectory: $(Build.SourcesDirectory) + + - template: templates/cd-template.yml + parameters: + customCommand: run generate-live-editing:app-lob + workingDir: $(Build.SourcesDirectory) + submoduleDir: angular-demos-lob + baseHref: \/angular-demos-lob\/ + targetFolder: dist/app-lob + findRegex: angular-demos + npmBuildCommand: 'run build-ci:app-lob' + repositoryfy: true diff --git a/azure-devops/templates/cd-template.yml b/azure-devops/templates/cd-template.yml new file mode 100644 index 000000000..0c4967e60 --- /dev/null +++ b/azure-devops/templates/cd-template.yml @@ -0,0 +1,194 @@ +# template.yml +parameters: + - name: customCommand + type: string + - name: workingDir + type: string + - name: submoduleDir + type: string + - name: baseHref + type: string + - name: targetFolder + type: string + default: 'dist' + - name: findRegex + type: string + - name: npmBuildCommand + type: string + default: '' + - name: runCleanup + type: boolean + default: true + - name: repositoryfy + type: boolean + default: false + +steps: + # - task: CmdLine@2 + # displayName: Clone submodule + # inputs: + # script: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples + # workingDirectory: ${{ parameters.workingDir }} + + - task: CmdLine@2 + displayName: Staging - Git checkout branch + condition: eq(variables['Build.SourceBranchName'], 'vNext') + inputs: + script: git checkout vNext + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples + + - task: CmdLine@2 + displayName: Production - Git checkout branch + condition: and(eq(variables['Build.SourceBranchName'], 'master'), contains(variables['build.reason'], 'CI')) + inputs: + script: git checkout master + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples + + - script: | + sed -i 's/--configuration production/--base-href=${{ parameters.baseHref }} --configuration production/g' package.json + displayName: 'Update package.json file' + workingDirectory: ${{ parameters.workingDir }} + + - task: Npm@1 + displayName: generate live-editing + inputs: + command: custom + workingDir: ${{ parameters.workingDir }} + verbose: false + customCommand: ${{ parameters.customCommand }} + +# - task: PowerShell@2 +# displayName: 'Replace with licensed igniteui-angular' +# inputs: +# targetType: 'inline' +# script: | +# $mainDirectory = "." +# $subDirs = @("projects", "src") +# $oldStrings = @("'igniteui-angular'", "igniteui-angular/", """igniteui-angular""") # Strings to replace +# $newStrings = @("'@infragistics/igniteui-angular'", "@infragistics/igniteui-angular/" ,"""@infragistics/igniteui-angular""") +# $files = Get-ChildItem -Path $mainDirectory -File +# foreach ($subDir in $subDirs) { +# $subDirPath = Join-Path -Path $mainDirectory -ChildPath $subDir +# if (Test-Path $subDirPath) { +# $files += Get-ChildItem -Path $subDirPath -File -Recurse +# } +# } +# foreach ($file in $files) { +# Write-Host "Processing file: $($file.FullName)" -ForegroundColor Green +# $filePath = $file.FullName +# $content = Get-Content -Path $filePath -Raw +# for ($i = 0; $i -lt $oldStrings.Count; $i++) { +# $content = $content -replace [regex]::Escape($oldStrings[$i]), $newStrings[$i] +# Write-Host "Replacing: $($oldStrings[$i]) with $($newStrings[$i])" -ForegroundColor Green +# } +# Set-Content -Path $filePath -Value $content +# } + + - task: CmdLine@2 + displayName: 'Update packages trial->licensed using angular schematics' + inputs: + script: | + npx --userconfig=$(Build.SourcesDirectory)\.npmrc ng g @igniteui/angular-schematics:upgrade-packages --skip-install + failOnStderr: true + + - task: Npm@1 + displayName: npm install + inputs: + command: install + workingDir: $(Build.SourcesDirectory) + verbose: false + customEndpoint: 'public proget' + env: + AZURE_PIPELINES: true + + - task: Npm@1 + displayName: ${{ parameters.npmBuildCommand }} + inputs: + command: custom + workingDir: ${{ parameters.workingDir }} + verbose: false + customCommand: '${{ parameters.npmBuildCommand }} --userconfig=$(Build.SourcesDirectory)\.npmrc' + + - task: CopyFiles@2 + displayName: Copy web.config + inputs: + SourceFolder: $(Build.SourcesDirectory) + Contents: web.config + TargetFolder: $(Build.SourcesDirectory)/${{ parameters.targetFolder }} + + - script: | + sed -i 's/${{ parameters.findRegex }}/${{ parameters.submoduleDir }}/g' $(Build.SourcesDirectory)/${{ parameters.targetFolder }}/web.config + displayName: 'Update web.config file' + workingDirectory: ${{ parameters.workingDir }} + + - script: | + sourcePath="$(Build.SourcesDirectory)/${{ parameters.targetFolder }}" + destinationZip="$(Build.ArtifactStagingDirectory)/output.zip" + cd "$sourcePath" + zip -r "$destinationZip" ./ + displayName: 'Zip build output' + + - task: PublishPipelineArtifact@1 + displayName: Publish Artifact + inputs: + targetPath: $(Build.ArtifactStagingDirectory)/output.zip + artifact: '${{ parameters.submoduleDir }}-artifact' + publishLocation: pipeline + + - task: Npm@1 + displayName: Staging - Repositorify Angular Demos and LOB Demos + condition: and(eq(variables['Build.SourceBranchName'], 'vNext'), eq(variables['repositoryfy'], 'true')) + inputs: + command: custom + workingDir: ${{ parameters.workingDir }} + verbose: false + customCommand: run repositoryfyAngularDemosLob + + - task: Npm@1 + displayName: Production - Repositorify Angular Demos + condition: and(eq(variables['Build.SourceBranchName'], 'master'), contains(variables['build.reason'], 'CI'), eq(variables['repositoryfy'], 'true')) + inputs: + command: custom + workingDir: ${{ parameters.workingDir }} + verbose: false + customCommand: run repositoryfyAngularDemosLob:prod + + - task: CmdLine@2 + displayName: Stage changes + condition: eq(variables['repositoryfy'], 'true') + inputs: + script: git add . + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }} + + - task: CmdLine@2 + displayName: 'Check if there are any changes to be committed' + condition: eq(variables['repositoryfy'], 'true') + inputs: + script: | + # Check for changes + changeCount=$(git status --porcelain | wc -l) + if [ "$changeCount" -eq 0 ]; then + echo "##vso[task.logissue type=warning]No changes to commit." + exit 0 + else + echo "##vso[task.setvariable variable=changesDetected;isOutput=true]true" + fi + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }} + + - task: CmdLine@2 + displayName: Commit changes + condition: and(eq(variables['changesDetected'], 'true'), eq(variables['repositoryfy'], 'true')) + inputs: + script: | + git config user.name "tfsbuild" + git config user.email "tfsbuild@infragistics.com" + git add . + git commit -m "Automated repository update" + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }} + + - task: CmdLine@2 + displayName: Push changes + condition: and(eq(variables['changesDetected'], 'true'), eq(variables['repositoryfy'], 'true')) + inputs: + script: git push + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }}