diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 1c9a72a2..f3b74277 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -200,7 +200,13 @@ stages: # Build and publish API docs on every merge build - job: jsdoc + dependsOn: displayenv condition: and(succeeded(),eq(variables['Build.Reason'], 'IndividualCI')) + variables: + ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}: + jsdoc_release: master + ${{ if ne(variables['Build.SourceBranch'], 'refs/heads/master') }}: + jsdoc_release: release-$(BuildData.MINOR_PACKAGE_VERSION) steps: - script: | set -ev @@ -239,9 +245,9 @@ stages: git checkout -b gh-pages origin/gh-pages git clean -xdf - mkdir -p $(Build.SourceBranchName)/api - rm -rf $(Build.SourceBranchName)/api/* - cp -r $(Build.ArtifactStagingDirectory)/jsdoc/gen/* $(Build.SourceBranchName)/api + mkdir -p $(jsdoc_release)/api + rm -rf $(jsdoc_release)/api/* + cp -r $(Build.ArtifactStagingDirectory)/jsdoc/gen/* $(jsdoc_release)/api if [ -d $(Build.ArtifactStagingDirectory)/gh-pages ]; then find . -maxdepth 1 ! \( -name [.]* -o -name 'gh-pages' -o -name 'master' -o -name 'release-*' \) -exec rm -rf {} \; cp -r $(Build.ArtifactStagingDirectory)/gh-pages/* . diff --git a/ci/templates/build-data.yaml b/ci/templates/build-data.yaml index 3cd79236..bcd11e3d 100644 --- a/ci/templates/build-data.yaml +++ b/ci/templates/build-data.yaml @@ -1,8 +1,13 @@ steps: - script: | env | sort + # handle full version number VERSION=$(jq '.version' $(Build.SourcesDirectory)/package.json | sed -r "s/\"([0-9]?[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9]).*/\1/") echo Current version in code is :${VERSION}: echo "##vso[task.setvariable variable=PACKAGE_VERSION;isOutput=true]${VERSION}" + # handle minor version + MINOR_VERSION=$(jq '.version' $(Build.SourcesDirectory)/package.json | sed -r "s/\"([0-9]?[0-9]\.[0-9]?[0-9])\.[0-9]?[0-9].*/\1/") + echo Current minor version in code is :${MINOR_VERSION}: + echo "##vso[task.setvariable variable=MINOR_PACKAGE_VERSION;isOutput=true]${MINOR_VERSION}" name: BuildData displayName: 'Build data' \ No newline at end of file