Skip to content

Commit

Permalink
upload typescript packages to npm registry (digital-asset#4185)
Browse files Browse the repository at this point in the history
* make packages public

This uploads the typescript npm packages of the language support to the
npm registry in the release process.

CHANGELOG_BEGIN
CHANGELOG_END

* address moritz/gary's review

* generate the .npmrc file

* adding debug output

just in case the upload will fail in the next release.

* reverse package order
  • Loading branch information
Robin Krom authored Jan 23, 2020
1 parent e13f9a7 commit 811d740
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ci/build-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ steps:
MAVEN_USERNAME: $(MAVEN_USERNAME)
MAVEN_PASSWORD: $(MAVEN_PASSWORD)
MAVEN_URL: "https://oss.sonatype.org"
# For uploading npm packages to npm registry.
NPM_TOKEN: $(NPM_TOKEN)
name: release
- bash: |
set -euo pipefail
Expand Down
2 changes: 1 addition & 1 deletion language-support/ts/daml-ledger/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"private": true,
"private": false,
"name": "@daml/ledger",
"version": "0.0.0-SDKVERSION",
"description": "Wrappers around DAML's JSON API.",
Expand Down
2 changes: 1 addition & 1 deletion language-support/ts/daml-types/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"private": true,
"private": false,
"name": "@daml/types",
"version": "0.0.0-SDKVERSION",
"description": "Types used by the DAML JSON API.",
Expand Down
23 changes: 22 additions & 1 deletion release/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ module Main (main) where
import Control.Monad.Extra
import Control.Monad.IO.Class
import Control.Monad.Logger
import Control.Exception
import Data.Yaml
import qualified Data.Set as Set
import qualified Data.List as List
import Path
import Path.IO
import Path.IO hiding (removeFile)

import qualified Data.Text as T
import qualified Data.Maybe as Maybe
Expand Down Expand Up @@ -86,6 +87,15 @@ main = do
uploadArtifacts <- concatMapM (mavenArtifactCoords optsAllArtifacts) mavenUploadArtifacts
validateMavenArtifacts releaseDir uploadArtifacts

-- npm packages we want to publish.
let npmPackages =
[ "//language-support/ts/daml-types"
, "//language-support/ts/daml-ledger"
]
-- make sure the npm packages can be build.
$logDebug "Building language-support typescript packages"
forM_ npmPackages $ \rule -> liftIO $ callCommand $ "bazel build " <> rule

if | getPerformUpload upload -> do
$logInfo "Make release"
releaseToBintray upload releaseDir (map (\(a, (_, outp)) -> (a, outp)) files)
Expand All @@ -98,6 +108,17 @@ main = do
else
$logInfo "No artifacts to upload to Maven Central"

let npmrcPath = ".npmrc"
-- We can't put an .npmrc file in the root of the directory because other bazel npm
-- code picks it up and looks for the token which is not yet set before the release
-- phase.
$logDebug "Uploading npm packages"
liftIO $ bracket
(writeFile npmrcPath "//registry.npmjs.org/:_authToken=${NPM_TOKEN}")
(\() -> Dir.removeFile npmrcPath)
(\() -> forM_ npmPackages
$ \rule -> liftIO $ callCommand $ "bazel run " <> rule <> ":npm_package.publish")

-- set variables for next steps in Azure pipelines
liftIO . putStrLn $ "##vso[task.setvariable variable=has_released;isOutput=true]true"
liftIO . putStrLn . T.unpack $ "##vso[task.setvariable variable=release_tag]" # renderVersion sdkVersion
Expand Down
2 changes: 1 addition & 1 deletion release/src/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data Options = Options
optsParser :: Parser Options
optsParser = Options
<$> strOption (long "artifacts" <> help "Path to yaml file listing the artifacts to be released")
<*> (PerformUpload <$> switch (long "upload" <> help "upload artifacts to bintray and Maven Central. If false, we don't upload artifacts to Maven Central or bintray even when the last commit is a release commit."))
<*> (PerformUpload <$> switch (long "upload" <> help "upload java/scala artifacts to bintray and Maven Central and typescript artifacts to the npm registry. If false, we don't upload artifacts even when the last commit is a release commit."))
<*> option str (long "release-dir" <> help "specify full path to release directory")
<*> option (Just <$> str) (long "slack-release-message" <> help "if present will write out what to write in slack. if there are no releases the file will be empty" <> value Nothing)
<*> switch (long "full-logging" <> help "full logging detail")
Expand Down

0 comments on commit 811d740

Please sign in to comment.