diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c9cf67d5..8641f09f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,16 +1,16 @@ # Contributing to Bedrock -Bedrock is a mini-monorepo managed by yarn workspaces and lerna. +Bedrock is a mini-monorepo managed by yarn workspaces and lerna. To build: - + yarn install yarn build To test: yarn test - + There are specific yarn scripts to test each module. # Modules @@ -29,14 +29,24 @@ Trunk-based development with semver. All modules share the same version (managed by `lerna`). -DO NOT manually edit the `package.json` files. DO NOT manually publish. +DO NOT manually edit the `package.json` files. Create feature branches named `feature/XXXX` where XXXX is a Jira issue key or Github issue number. Feature branches are merged to `master`. -After merging, run `yarn lerna version` to choose a new version, then push directly to `master`. This will be published by Jenkins. +After merging, run `yarn lerna version` to choose a new version, then push directly to `master`. To add a dependency to the root package: `yarn add -W package` To add a dependency to a module, use `yarn add @ephox/bedrock-XXX package`. Add a `-D` to the above for `devDependencies` +# Publishing + +Packages are published manually: + +1. Get temporary generated npm publish keys from the Bitwarden entry `npmjs.com - tinymce - engineering-inbox@tiny.cloud`. Publishing manually requires them. +2. Log in to npm with those keys (`npm login`). +3. On `master`, after running `yarn lerna version`, run: `yarn release` +4. When prompted for a one-time password, copy the verification code generated by the authenticator in the same Bitwarden entry. + +This builds all modules (`yarn build`) and then runs `lerna publish from-package`, which publishes every module whose version is not yet on npm. Lerna asks for confirmation before publishing; extra arguments are passed through to lerna (e.g. `yarn release --dist-tag next`). diff --git a/Jenkinsfile b/Jenkinsfile index f82e8688..dca0ab4e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,20 +46,5 @@ timestamps { platforms: platforms, prefix: testPrefix ) - - if (isReleaseBranch()) { - stage("publish") { - tinyPods.node() { - yarnInstall() - sh 'yarn build' - tinyNpm.withNpmPublishCredentials { - // We need to tell git to ignore the changes to .npmrc when publishing - exec('git update-index --assume-unchanged .npmrc') - // Re-evaluate whether we still need the `--no-verify-access` flag after upgrading Lerna (TINY-13539) - exec('yarn lerna publish from-package --yes --no-git-reset --ignore-changes @ephox/bedrock-sample --no-verify-access') - } - } - } - } } } diff --git a/package.json b/package.json index f6707492..b8a1581e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "build-runner": "yarn workspace @ephox/bedrock-runner build", "build-server": "yarn workspace @ephox/bedrock-server build", "build": "yarn lerna run build --ignore @ephox/bedrock-sample", + "release": "./publish.sh", "test-common": "yarn workspace @ephox/bedrock-common test", "test-client": "yarn workspace @ephox/bedrock-client test", "test-runner": "yarn workspace @ephox/bedrock-runner test", diff --git a/publish.sh b/publish.sh new file mode 100755 index 00000000..3397854c --- /dev/null +++ b/publish.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Manually publish packages to npm (mirrors the Jenkins publish stage). +# Publishes any package whose package.json version isn't on the registry yet. +set -euo pipefail + +cd "$(dirname "$0")" + +yarn build +yarn lerna publish from-package --ignore-changes @ephox/bedrock-sample "$@"