daml/ci/build-unix.yml
Moritz Kiefer dba114a283
Merge Maven uploads for different Scala versions (#8943)
* Merge Maven uploads for different Scala versions

It turns out Maven will abort an existing staging operation if you
create a new one. This means our jobs race against each other. We
could try to fix that by either sequencing the jobs in a clever
way (annoying and can break things like rerunning if only parts
failed), or by creating more profiles (unclear if you can even have
two profiles for the same group id, even if you do, it’s annoying to
merge).

So in this PR I (grudgingly) merged both uploads into the Haskell
script. This isn’t all bad:

1. It moves some logic from bash embedded in yaml string literals into
Haskell code.
2. It duplicates some versions but it removes duplication in other
places so overall not too much worse.
3. It does however, make things slower. We don’t run this stuff in
parallel. That said, the release step is relatively small (< 5min) and
it only runs on Linux.

We could add CLI arguments to make the Scala versions configurable for
local development. Given that this is blocking releases, I wanted to
get something in that works first and then see what we need in that regard.

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-02-24 20:33:53 +00:00

184 lines
7.6 KiB
YAML

# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
parameters:
is_release: ''
name: ''
release_tag: ''
scala_version: ''
steps:
- bash: ci/dev-env-install.sh
displayName: 'Build/Install the Developer Environment'
- bash: |
source dev-env/lib/ensure-nix
ci/dev-env-push.py
displayName: 'Push Developer Environment build results'
condition: eq(variables['System.PullRequest.IsFork'], 'False')
env:
# to upload to the Nix cache
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
NIX_SECRET_KEY_CONTENT: $(NIX_SECRET_KEY_CONTENT)
- bash: ci/configure-bazel.sh
displayName: 'Configure Bazel'
env:
IS_FORK: $(System.PullRequest.IsFork)
# to upload to the bazel cache
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
- bash: ./fmt.sh --test
displayName: 'Platform-agnostic lints and checks'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
- bash: ./build.sh "_$(uname)"
displayName: 'Build'
env:
DAML_SDK_RELEASE_VERSION: ${{parameters.release_tag}}
DAML_SCALA_VERSION: ${{parameters.scala_version}}
- task: PublishBuildArtifacts@1
condition: failed()
displayName: 'Publish the bazel test logs'
inputs:
pathtoPublish: 'bazel-testlogs/'
artifactName: 'Test logs'
- bash: |
set -euo pipefail
eval "$(./dev-env/bin/dade-assist)"
./bazel-bin/release/release --release-dir "$(mktemp -d)" --upload
env:
DAML_SDK_RELEASE_VERSION: ${{parameters.release_tag}}
DAML_SCALA_VERSION: ${{parameters.scala_version}}
GPG_KEY: $(gpg-code-signing)
MAVEN_USERNAME: $(MAVEN_USERNAME)
MAVEN_PASSWORD: $(MAVEN_PASSWORD)
MAVEN_URL: "https://oss.sonatype.org"
NPM_TOKEN: $(NPM_TOKEN)
name: publish_npm_mvn
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq('${{parameters.scala_version}}', ''),
eq(variables['Build.SourceBranchName'], 'main'),
in('${{parameters.name}}', 'linux', 'linux-scala-2.13'))
- template: bash-lib.yml
parameters:
var_name: bash-lib
- bash: |
set -euo pipefail
source $(bash-lib)
eval "$(./dev-env/bin/dade-assist)"
TARBALL=daml-sdk-${{parameters.release_tag}}-${{parameters.name}}.tar.gz
cp bazel-bin/release/sdk-release-tarball.tar.gz $(Build.StagingDirectory)/$TARBALL
setvar tarball "$TARBALL"
PROTOS_ZIP=protobufs-${{parameters.release_tag}}.zip
cp bazel-bin/release/protobufs.zip $(Build.StagingDirectory)/$PROTOS_ZIP
setvar protos-zip "$PROTOS_ZIP"
DAML_ON_SQL=daml-on-sql-${{parameters.release_tag}}.jar
## Not built by default
bazel build //ledger/daml-on-sql:daml-on-sql-binary_deploy.jar
cp bazel-bin/ledger/daml-on-sql/daml-on-sql-binary_deploy.jar $(Build.StagingDirectory)/$DAML_ON_SQL
setvar daml-on-sql "$DAML_ON_SQL"
JSON_API=http-json-${{parameters.release_tag}}.jar
## Not built by default
bazel build //ledger-service/http-json:http-json-binary_deploy.jar
cp bazel-bin/ledger-service/http-json/http-json-binary_deploy.jar $(Build.StagingDirectory)/$JSON_API
setvar json-api "$JSON_API"
TRIGGER=daml-trigger-runner-${{parameters.release_tag}}.jar
bazel build //triggers/runner:trigger-runner_deploy.jar
cp bazel-bin/triggers/runner/trigger-runner_deploy.jar $(Build.StagingDirectory)/$TRIGGER
setvar trigger-runner "$TRIGGER"
TRIGGER_SERVICE=trigger-service-${{parameters.release_tag}}.jar
## Not built by default
bazel build //triggers/service:trigger-service-binary_deploy.jar
cp bazel-bin/triggers/service/trigger-service-binary_deploy.jar $(Build.StagingDirectory)/$TRIGGER_SERVICE
setvar trigger-service "$TRIGGER_SERVICE"
OAUTH2_MIDDLEWARE=oauth2-middleware-${{parameters.release_tag}}.jar
## Not built by default
bazel build //triggers/service/auth:oauth2-middleware-binary_deploy.jar
cp bazel-bin/triggers/service/auth/oauth2-middleware-binary_deploy.jar $(Build.StagingDirectory)/$OAUTH2_MIDDLEWARE
setvar oauth2-middleware "$OAUTH2_MIDDLEWARE"
SCRIPT=daml-script-${{parameters.release_tag}}.jar
bazel build //daml-script/runner:script-runner_deploy.jar
cp bazel-bin/daml-script/runner/script-runner_deploy.jar $(Build.StagingDirectory)/$SCRIPT
setvar script-runner "$SCRIPT"
env:
DAML_SDK_RELEASE_VERSION: ${{parameters.release_tag}}
name: publish
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'))
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.StagingDirectory)/$(publish.tarball)
artifactName: $(publish.tarball)
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'))
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.StagingDirectory)/$(publish.protos-zip)
artifactName: $(publish.protos-zip)
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'),
eq('${{parameters.name}}', 'linux'))
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.StagingDirectory)/$(publish.daml-on-sql)
artifactName: $(publish.daml-on-sql)
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'),
eq('${{parameters.name}}', 'linux'))
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.StagingDirectory)/$(publish.json-api)
artifactName: $(publish.json-api)
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'),
eq('${{parameters.name}}', 'linux'))
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.StagingDirectory)/$(publish.trigger-runner)
artifactName: $(publish.trigger-runner)
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'),
eq('${{parameters.name}}', 'linux'))
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.StagingDirectory)/$(publish.trigger-service)
artifactName: $(publish.trigger-service)
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'),
eq('${{parameters.name}}', 'linux'))
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.StagingDirectory)/$(publish.oauth2-middleware)
artifactName: $(publish.oauth2-middleware)
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'),
eq('${{parameters.name}}', 'linux'))
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.StagingDirectory)/$(publish.script-runner)
artifactName: $(publish.script-runner)
condition: and(succeeded(),
eq(${{parameters.is_release}}, 'true'),
eq(variables['Build.SourceBranchName'], 'main'),
eq('${{parameters.name}}', 'linux'))