From cd10d5840d6dd57b1685cb5471d4f2ba721b4bb4 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:54:23 +0100 Subject: [PATCH] V14: Publish Bellissima package to npm via Pipelines (#14926) * ignore node_modules specifically to limit size of build_output * build and publish backoffice artifacts * instruct GitVersioning to output all variables such as npm to use in Pipelines * use NBGV variables * prepare npm package for nightlies * instruct to deploy to MyGet for nightlies * Deploy to npm only after Myget * add public access to publish * write scopes to .npmrc file * add scope to registry.npmjs.org * nightly param --- .artifactignore | 1 + build/azure-pipelines.yml | 111 ++++++++++++++++++++++++++++++-- build/nightly-build-trigger.yml | 5 +- src/Umbraco.Web.UI.New.Client | 2 +- version.json | 6 +- 5 files changed, 111 insertions(+), 14 deletions(-) diff --git a/.artifactignore b/.artifactignore index a287e295ae..2179dc1f0e 100644 --- a/.artifactignore +++ b/.artifactignore @@ -1,3 +1,4 @@ **/* !**/bin/** !**/obj/** +**/node_modules diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index aed4d68cf2..74fae6c65d 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -13,6 +13,14 @@ parameters: displayName: Deploy to NuGet type: boolean default: false + - name: npmDeploy + displayName: Deploy to Npm + type: boolean + default: false + - name: npmPublishTag + displayName: Npm publish tag + type: string + default: 'latest' - name: buildApiDocs displayName: Build API docs type: boolean @@ -41,6 +49,10 @@ parameters: displayName: TestFilter used for release type builds on non windows agents type: string default: ' ' + - name: isNightly + displayName: 'Is nightly build (used for MyGet feed)' + type: boolean + default: false variables: nodeVersion: 20 @@ -93,13 +105,13 @@ stages: targets: coreBuild workingDirectory: src/Umbraco.Web.UI.Client - script: npm ci --no-fund --no-audit --prefer-offline - workingDirectory: src/Umbraco.Web.UI.New.Client - displayName: Run npm ci + displayName: Run npm ci (Bellissima) + workingDirectory: src/Umbraco.Web.UI.New.Client - script: npm run build:for:cms - displayName: Run New Backoffice Build + displayName: Run build (Bellissima) workingDirectory: src/Umbraco.Web.UI.New.Client - script: npm run build - displayName: Run Login Build + displayName: Run Login Build (Bellissima) workingDirectory: src/Umbraco.Web.UI.New.Client/apps/auth - task: UseDotNet@2 displayName: Use .NET $(dotnetVersion) @@ -128,6 +140,24 @@ stages: inputs: targetPath: $(Build.SourcesDirectory) artifactName: build_output + - bash: | + echo "##[command]Running npm version" + echo "##[debug]Version: $PACKAGE_VERSION" + echo "##[command]Running npm pack" + echo "##[debug]Output directory: $(Build.ArtifactStagingDirectory)" + npm version $PACKAGE_VERSION --allow-same-version --no-git-tag-version + mkdir $(Build.ArtifactStagingDirectory)/npm + npm pack --pack-destination $(Build.ArtifactStagingDirectory)/npm + mv .npmrc $(Build.ArtifactStagingDirectory)/npm/ + displayName: Prepare Bellissima npm package + env: + PACKAGE_VERSION: $(build.NBGV_NpmPackageVersion) + workingDirectory: src/Umbraco.Web.UI.New.Client + - task: PublishPipelineArtifact@1 + displayName: Publish Bellissima npm artifact + inputs: + targetPath: $(Build.ArtifactStagingDirectory)/npm + artifactName: npm - stage: Build_Docs condition: and(succeeded(), or(eq(dependencies.Build.outputs['A.build.NBGV_PublicRelease'], 'True'), ${{parameters.buildApiDocs}})) @@ -570,7 +600,45 @@ stages: command: 'push' packagesToPush: $(Build.ArtifactStagingDirectory)/**/*.nupkg nuGetFeedType: 'external' - publishFeedCredentials: 'MyGet - Pre-releases' + ${{ if eq(parameters.isNightly, true) }}: + publishFeedCredentials: 'MyGet - Umbraco Nightly' + ${{ else }}: + publishFeedCredentials: 'MyGet - Pre-releases' + - job: + displayName: Push to pre-release feed (npm) + steps: + - checkout: none + - download: current + artifact: npm + - bash: | + # Check if we are on a nightly build + if [ $isNightly = "False" ]; then + echo "##[debug]Prerelease build detected" + registry="https://www.myget.org/F/umbracoprereleases/npm/" + else + echo "##[debug]Nightly build detected" + registry="https://www.myget.org/F/umbraconightly/npm/" + fi + echo "@umbraco-cms:registry=$registry" >> .npmrc + env: + isNightly: ${{parameters.isNightly}} + workingDirectory: $(Pipeline.Workspace)/npm + displayName: Add scoped registry to .npmrc + - task: npmAuthenticate@0 + displayName: Authenticate with npm (MyGet) + inputs: + workingFile: '$(Pipeline.Workspace)/npm/.npmrc' + customEndpoint: 'MyGet (npm) - Umbracoprereleases, MyGet (npm) - Umbraconightly' + - bash: | + # Setup temp npm project to load in defaults from the local .npmrc + npm init -y + + # Find the first .tgz file in the current directory and publish it + files=( ./*.tgz ) + npm publish --access public "${files[0]}" + displayName: Push to npm (MyGet) + workingDirectory: $(Pipeline.Workspace)/npm + - stage: Deploy_NuGet displayName: NuGet release dependsOn: @@ -595,14 +663,43 @@ stages: nuGetFeedType: 'external' publishFeedCredentials: 'NuGet - Umbraco.*' + - stage: Deploy_Npm + displayName: Npm release + condition: and(succeeded(), or(eq(dependencies.Build.outputs['A.build.NBGV_PublicRelease'], 'True'), ${{parameters.npmDeploy}})) + dependsOn: + - Deploy_NuGet + jobs: + - job: Publish + displayName: Push to NPM + steps: + - checkout: none + - download: current + artifact: npm + - bash: echo "@umbraco-cms:registry=https://registry.npmjs.org" >> .npmrc + workingDirectory: $(Pipeline.Workspace)/npm + displayName: Add scoped registry to .npmrc + - task: npmAuthenticate@0 + displayName: Authenticate with npm + inputs: + workingFile: $(Pipeline.Workspace)/npm/.npmrc + customEndpoint: 'NPM - Umbraco Backoffice' + - script: | + # Setup temp npm project to load in defaults from the local .npmrc + npm init -y + + # Find the first .tgz file in the current directory and publish it + files=( ./*.tgz ) + npm publish --tag $npmTag --access public "${files[0]}" + displayName: Push to npm + workingDirectory: $(Pipeline.Workspace)/npm + - stage: Upload_API_Docs pool: vmImage: 'windows-latest' # Apparently AzureFileCopy is windows only :( variables: - umbracoMajorVersion: $[ stageDependencies.Build.A.outputs['build.NBGV_VersionMajor'] ] + umbracoMajorVersion: $[ dependencies.Build.outputs['A.build.NBGV_VersionMajor'] ] displayName: Upload API Documentation dependsOn: - - Build - Deploy_MyGet # Change to "Deploy_Nuget" after release of v14 condition: and(succeeded(), or(eq(dependencies.Build.outputs['A.build.NBGV_PublicRelease'], 'True'), ${{parameters.uploadApiDocs}})) jobs: diff --git a/build/nightly-build-trigger.yml b/build/nightly-build-trigger.yml index 1b70e6c9e5..1d11232c0f 100644 --- a/build/nightly-build-trigger.yml +++ b/build/nightly-build-trigger.yml @@ -15,6 +15,7 @@ schedules: - v14/dev steps: +- checkout: none - task: TriggerBuild@4 inputs: definitionIsInCurrentTeamProject: true @@ -26,10 +27,10 @@ steps: useSameBranch: true waitForQueuedBuildsToFinish: false storeInEnvironmentVariable: false - templateParameters: 'sqlServerIntegrationTests: true, forceReleaseTestFilter: true' + templateParameters: 'sqlServerIntegrationTests: true, forceReleaseTestFilter: true, myGetDeploy: true, isNightly: true' authenticationMethod: 'OAuth Token' enableBuildInQueueCondition: false dependentOnSuccessfulBuildCondition: false dependentOnFailedBuildCondition: false checkbuildsoncurrentbranch: false - failTaskIfConditionsAreNotFulfilled: false \ No newline at end of file + failTaskIfConditionsAreNotFulfilled: false diff --git a/src/Umbraco.Web.UI.New.Client b/src/Umbraco.Web.UI.New.Client index 653b707e81..bf6be57e7c 160000 --- a/src/Umbraco.Web.UI.New.Client +++ b/src/Umbraco.Web.UI.New.Client @@ -1 +1 @@ -Subproject commit 653b707e81b1e0b08a2c93192d03bfdd31d562e6 +Subproject commit bf6be57e7c8bd9c8c95b2985e04fb1177cf0fbdc diff --git a/version.json b/version.json index 2386445d86..0af236f262 100644 --- a/version.json +++ b/version.json @@ -17,9 +17,7 @@ "tagName": "release-{version}" }, "cloudBuild": { - "setAllVariables": true, - "buildNumber": { - "enabled": true - } + "setVersionVariables": true, + "setAllVariables": true } }