diff --git a/ci/release.sh b/ci/release.sh index f1e1d767d1fb..cc2bdd7c864c 100755 --- a/ci/release.sh +++ b/ci/release.sh @@ -14,6 +14,14 @@ step() { cd "$(dirname "$0")"/.. +if [[ "$(uname)" == "Darwin" ]]; then + echo "Simulating release step..." + echo "##vso[task.setvariable variable=has_released;isOutput=true]true" + echo "##vso[task.setvariable variable=release_tag]$(cat VERSION)" + exit 0 +fi + + step "loading dev-env" eval "$(dev-env/bin/dade assist)" @@ -27,13 +35,6 @@ step "set up temporary location" release_dir="$(mktemp -d)" step "temporary release directory is ${release_dir}" -EXTRA_ARGS="" - -if [[ "$(uname)" == "Darwin" ]]; then - EXTRA_ARGS="--ignore-missing-deps" -fi - - if [[ "${BUILD_SOURCEBRANCHNAME:-}" == "master" ]]; then # set up bintray credentials mkdir -p ~/.jfrog @@ -41,9 +42,9 @@ if [[ "${BUILD_SOURCEBRANCHNAME:-}" == "master" ]]; then unset JFROG_CONFIG_CONTENT step "run release script (with --upload)" - ./bazel-bin/release/release --artifacts release/artifacts.yaml --upload --log-level debug --release-dir "${release_dir}" $EXTRA_ARGS + ./bazel-bin/release/release --artifacts release/artifacts.yaml --upload --log-level debug --release-dir "${release_dir}" else step "run release script (dry run)" - ./bazel-bin/release/release --artifacts release/artifacts.yaml --log-level debug --release-dir "${release_dir}" $EXTRA_ARGS + ./bazel-bin/release/release --artifacts release/artifacts.yaml --log-level debug --release-dir "${release_dir}" step "release artifacts got stored in ${release_dir}" fi diff --git a/dev-env/bin/daml-sdk-head b/dev-env/bin/daml-sdk-head index 152f44bafac2..c998d6697c7e 100755 --- a/dev-env/bin/daml-sdk-head +++ b/dev-env/bin/daml-sdk-head @@ -115,7 +115,7 @@ if [ "$SKIP_JARS" -eq "0" ]; then bazel build //release:release tmp=$(mktemp -d) - "$REPO_ROOT/bazel-bin/release/release" --artifacts "$REPO_ROOT/release/artifacts.yaml" --release-dir $tmp --all-artifacts --install-head-jars + "$REPO_ROOT/bazel-bin/release/release" --artifacts "$REPO_ROOT/release/artifacts.yaml" --release-dir $tmp --install-head-jars mv "$REPO_ROOT/VERSION.head-build-in-progress" "$REPO_ROOT/VERSION" trap - EXIT diff --git a/release/src/Main.hs b/release/src/Main.hs index dbe0346abcaf..1f76814e755d 100644 --- a/release/src/Main.hs +++ b/release/src/Main.hs @@ -64,14 +64,11 @@ main = do -- originating from genrules that use damlc. This is a bit hacky but -- given that it’s fairly unlikely to accidentally introduce a dependency on the scenario -- service it doesn’t seem worth fixing properly. - if getIgnoreMissingDeps optsIgnoreMissingDeps - then pure (a, []) - else do - let bazelQueryCommand = shell $ "bazel query 'kind(\"(scala|java)_library\", deps(" ++ (T.unpack . getBazelTarget . artTarget) a ++ ")) intersect //... except //compiler/scenario-service/protos:scenario_service_java_proto'" - internalDeps <- liftIO $ lines <$> readCreateProcess bazelQueryCommand "" - -- check if a dependency is not already a maven target from artifacts.yaml - let missingDeps = filter (`Set.notMember` allMavenTargets) internalDeps - return (a, missingDeps) + let bazelQueryCommand = shell $ "bazel query 'kind(\"(scala|java)_library\", deps(" ++ (T.unpack . getBazelTarget . artTarget) a ++ ")) intersect //... except //compiler/scenario-service/protos:scenario_service_java_proto'" + internalDeps <- liftIO $ lines <$> readCreateProcess bazelQueryCommand "" + -- check if a dependency is not already a maven target from artifacts.yaml + let missingDeps = filter (`Set.notMember` allMavenTargets) internalDeps + return (a, missingDeps) let onlyMissing = filter (not . null . snd) missingDepsForAllArtifacts -- now we can report all the missing dependencies per artifact @@ -83,11 +80,11 @@ main = do liftIO exitFailure files <- fmap concat $ forM artifacts $ \a -> do - fs <- artifactFiles optsAllArtifacts a + fs <- artifactFiles a pure $ map (a,) fs mapM_ (\(_, (inp, outp)) -> copyToReleaseDir bazelLocations releaseDir inp outp) files - uploadArtifacts <- concatMapM (mavenArtifactCoords optsAllArtifacts) mavenUploadArtifacts + uploadArtifacts <- concatMapM mavenArtifactCoords mavenUploadArtifacts validateMavenArtifacts releaseDir uploadArtifacts -- npm packages we want to publish. diff --git a/release/src/Options.hs b/release/src/Options.hs index 5d2d3b9eb59b..db835fa08421 100644 --- a/release/src/Options.hs +++ b/release/src/Options.hs @@ -24,9 +24,7 @@ data Options = Options , optsSlackReleaseMessageFile :: Maybe FilePath , optsFullLogging :: Bool , optsLogLevel :: LogLevel - , optsAllArtifacts :: AllArtifacts , optsLocallyInstallJars :: Bool - , optsIgnoreMissingDeps :: IgnoreMissingDeps } deriving (Eq, Show) optsParser :: Parser Options @@ -37,9 +35,7 @@ optsParser = Options <*> 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") <*> option readLogLevel (long "log-level" <> metavar "debug|info|warn|error (default: info)" <> help "Specify log level during release run" <> value LevelInfo ) - <*> (AllArtifacts <$> switch (long "all-artifacts" <> help "Produce all artifacts including platform-independent artifacts on MacOS")) <*> switch (long "install-head-jars" <> help "install jars to ~/.m2") - <*> (IgnoreMissingDeps <$> switch (long "ignore-missing-deps" <> help "Do not check for missing Maven dependencies")) where readLogLevel :: ReadM LogLevel diff --git a/release/src/Types.hs b/release/src/Types.hs index a905b062cde2..41a23cbf1dcd 100644 --- a/release/src/Types.hs +++ b/release/src/Types.hs @@ -3,7 +3,6 @@ {-# LANGUAGE ConstraintKinds #-} module Types ( - AllArtifacts(..), ArtifactId, ArtifactType, CIException(..), @@ -11,7 +10,6 @@ module Types ( BintrayPackage(..), GitRev, GroupId, - IgnoreMissingDeps(..), MavenAllowUnsecureTls(..), MavenCoords(..), MavenUpload(..), @@ -19,7 +17,6 @@ module Types ( MonadCI, OS(..), PerformUpload(..), - PlatformDependent(..), TextVersion, Version(..), VersionChange(..), @@ -79,23 +76,9 @@ data MavenCoords = MavenCoords , artifactType :: !ArtifactType } deriving Show -newtype PlatformDependent = PlatformDependent{getPlatformDependent :: Bool} - deriving (Eq, Show, FromJSON) - newtype MavenUpload = MavenUpload { getMavenUpload :: Bool } deriving (Eq, Show, FromJSON) --- | If this is True, we produce all artifacts even platform independent artifacts on MacOS. --- This is useful for testing purposes. -newtype AllArtifacts = AllArtifacts Bool - deriving (Eq, Show) - --- | If True, we do not check for missing deps. --- This is significantly faster and deps checking is platform independent --- so we only run it on Linux which is usually faster than the MacOS build. -newtype IgnoreMissingDeps = IgnoreMissingDeps { getIgnoreMissingDeps :: Bool } - deriving (Eq, Show) - -- execution type MonadCI m = (MonadIO m, MonadMask m, MonadLogger m, MonadUnliftIO m, MonadBaseControl IO m, Async.Forall (Async.Pure m)) diff --git a/release/src/Util.hs b/release/src/Util.hs index 1db82c66100e..ae3dfae3658d 100644 --- a/release/src/Util.hs +++ b/release/src/Util.hs @@ -97,7 +97,6 @@ instance FromJSON ReleaseType where data Artifact c = Artifact { artTarget :: !BazelTarget , artReleaseType :: !ReleaseType - , artPlatformDependent :: !PlatformDependent , artBintrayPackage :: !BintrayPackage -- ^ Defaults to sdk-components if not specified , artMavenUpload :: MavenUpload @@ -117,7 +116,6 @@ instance FromJSON (Artifact (Maybe ArtifactLocation)) where parseJSON = withObject "Artifact" $ \o -> Artifact <$> o .: "target" <*> o .: "type" - <*> (fromMaybe (PlatformDependent False) <$> o .:? "platformDependent") <*> (fromMaybe PkgSdkComponents <$> o .:? "bintrayPackage") <*> (fromMaybe (MavenUpload False) <$> o .:? "mavenUpload") <*> o .:? "javadoc-jar" @@ -283,17 +281,16 @@ customJavadocJarName :: Artifact a -> Maybe Text customJavadocJarName Artifact{..} = T.pack . toFilePath <$> artJavadocJar -- | Given an artifact, produce a list of pairs of an input file and the corresponding output file. -artifactFiles :: E.MonadThrow m => AllArtifacts -> Artifact PomData -> m [(Path Rel File, Path Rel File)] -artifactFiles allArtifacts art@Artifact{..} = do +artifactFiles :: E.MonadThrow m => Artifact PomData -> m [(Path Rel File, Path Rel File)] +artifactFiles art@Artifact{..} = do let PomData{..} = artMetadata outDir <- parseRelDir $ unpack $ T.intercalate "/" pomGroupId #"/"# pomArtifactId #"/"# pomVersion #"/" - let ostxt = if getPlatformDependent artPlatformDependent then "-" <> osName else "" let (directory, name) = splitBazelTarget artTarget directory <- parseRelDir $ unpack directory mainArtifactIn <- parseRelFile $ unpack $ mainFileName artReleaseType name - mainArtifactOut <- parseRelFile (unpack (pomArtifactId #"-"# pomVersion # ostxt # "." # mainExt artReleaseType)) + mainArtifactOut <- parseRelFile (unpack (pomArtifactId #"-"# pomVersion # "." # mainExt artReleaseType)) pomFileIn <- parseRelFile (unpack (name <> "_pom.xml")) pomFileOut <- releasePomPath artMetadata @@ -310,13 +307,11 @@ artifactFiles allArtifacts art@Artifact{..} = do (customJavadocJarName art <|> javadocJarName art <|> scaladocJarName art <|> javadocDeployJarName art <|> javadocProtoJarName art) javadocJarOut <- releaseDocJarPath artMetadata - let shouldReleasePlatInd = shouldRelease allArtifacts (PlatformDependent False) - pure $ - [(directory mainArtifactIn, outDir mainArtifactOut) | shouldRelease allArtifacts artPlatformDependent] <> - [(directory pomFileIn, outDir pomFileOut) | isJar artReleaseType, shouldReleasePlatInd] <> - [(directory sourceJarIn, outDir sourceJarOut) | shouldReleasePlatInd, Just sourceJarIn <- pure mbSourceJarIn] <> - [(directory javadocJarIn, outDir javadocJarOut) | shouldReleasePlatInd, Just javadocJarIn <- pure mbJavadocJarIn] + [(directory mainArtifactIn, outDir mainArtifactOut)] <> + [(directory pomFileIn, outDir pomFileOut) | isJar artReleaseType] <> + [(directory sourceJarIn, outDir sourceJarOut) | Just sourceJarIn <- pure mbSourceJarIn] <> + [(directory javadocJarIn, outDir javadocJarOut) | Just javadocJarIn <- pure mbJavadocJarIn] -- ^ Note that the Scaladoc is specified with the "javadoc" classifier. -- | The file path to the source jar for the given artifact in the release directory. @@ -336,31 +331,23 @@ releasePomPath PomData{..} = -- | Given an artifact, produce a list of pairs of an input file and the Maven coordinates. -- This corresponds to the files uploaded to Maven Central. -mavenArtifactCoords :: E.MonadThrow m => AllArtifacts -> Artifact PomData -> m [(MavenCoords, Path Rel File)] -mavenArtifactCoords allArtifacts Artifact{..} = do +mavenArtifactCoords :: E.MonadThrow m => Artifact PomData -> m [(MavenCoords, Path Rel File)] +mavenArtifactCoords Artifact{..} = do let PomData{..} = artMetadata - let jarClassifier = if getPlatformDependent artPlatformDependent then Just osName else Nothing outDir <- parseRelDir $ unpack $ T.intercalate "/" pomGroupId #"/"# pomArtifactId #"/"# pomVersion #"/" - let ostxt = if getPlatformDependent artPlatformDependent then "-" <> osName else "" - mainArtifactFile <- parseRelFile (unpack (pomArtifactId #"-"# pomVersion # ostxt # "." # mainExt artReleaseType)) + mainArtifactFile <- parseRelFile (unpack (pomArtifactId #"-"# pomVersion # "." # mainExt artReleaseType)) pomFile <- releasePomPath artMetadata sourcesFile <- releaseSourceJarPath artMetadata javadocFile <- releaseDocJarPath artMetadata let mavenCoords classifier artifactType = MavenCoords { groupId = pomGroupId, artifactId = pomArtifactId, version = pomVersion, classifier, artifactType } - let shouldReleasePlatInd = shouldRelease allArtifacts (PlatformDependent False) - - pure $ [ (mavenCoords jarClassifier $ mainExt artReleaseType, outDir mainArtifactFile) | shouldReleasePlatInd] <> - [ (mavenCoords Nothing "pom", outDir pomFile) | isJar artReleaseType, shouldReleasePlatInd] <> - [ (mavenCoords (Just "sources") "jar", outDir sourcesFile) | isJar artReleaseType, shouldReleasePlatInd] <> - [ (mavenCoords (Just "javadoc") "jar", outDir javadocFile) | isJar artReleaseType, shouldReleasePlatInd] - -shouldRelease :: AllArtifacts -> PlatformDependent -> Bool -shouldRelease (AllArtifacts allArtifacts) (PlatformDependent platformDependent) = - allArtifacts || platformDependent || osName == "linux" + pure $ [ (mavenCoords Nothing $ mainExt artReleaseType, outDir mainArtifactFile)] <> + [ (mavenCoords Nothing "pom", outDir pomFile) | isJar artReleaseType] <> + [ (mavenCoords (Just "sources") "jar", outDir sourcesFile) | isJar artReleaseType] <> + [ (mavenCoords (Just "javadoc") "jar", outDir javadocFile) | isJar artReleaseType] copyToReleaseDir :: (MonadLogger m, MonadIO m) => BazelLocations -> Path Abs Dir -> Path Rel File -> Path Rel File -> m () copyToReleaseDir BazelLocations{..} releaseDir inp out = do