diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 573c0a50d..c03715101 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -187,80 +187,38 @@ To install both tools: `npm i -g npm-check npm-check-updates`. ## Publishing -First, follow the instructions in [docs/building.md](docs/building.md). +1. Prepare the release notes. -```sh -cargo install git-cliff -``` +- Execute the following command to extract git commit comments since the last release: -```sh -# git-cliff --tag ..HEAD | pbcopy -git-cliff --tag 1.0.1 v1.0.0..HEAD | pbcopy -``` + ```sh + # git-cliff --tag ..HEAD | pbcopy + # e.g.: git-cliff --tag 1.0.1 v1.0.0..HEAD | pbcopy -- Paste into [CHANGELOG.md](CHANGELOG.md) + # If git-cliff is not yet installed, first do: + # cargo install git-cliff + ``` + +- Paste that in a text editor - Clean up formatting - Add any important missing details -- Replace PR numbers with links: - -``` -#(\d{3}) -[#$1](https://github.com/temporalio/sdk-typescript/pull/$1) -``` - -- If PRs came from external contributors, thank them & link their github handles: `([#484](link), thanks to [`@user`](https://github.com/user) 🙏)` -- Open PR with CHANGELOG change -- If using a custom [features](https://github.com/temporalio/features) branch for PR integration tests, make - sure the branch is fully up-to-date with `features` `main` before merging the CHANGELOG PR -- Merge PR -- Checkout latest `main` - -We're [working on automating](https://github.com/temporalio/sdk-typescript/pull/395) the rest of the process: -- Log in to npm as `temporal-sdk-team` (`npm whoami` and `npm login`) -- Download the 5 `packages-*` artifacts from the PR's [GitHub Action](https://github.com/temporalio/sdk-typescript/actions) -- Publish: +- If PRs came from external contributors, thank them & link their github handles: `(#484, thanks to @user 🙏)` -```sh -#!/bin/bash -set -euo pipefail - -git clean -fdx -npm ci -npm run build +2. Publish bundles -mkdir -p packages/core-bridge/releases +- Make sure you are logged in to NPM as `temporal-sdk-team` (`npm whoami` and `npm login`) -# in the next command, replace ~/gh/release-sdk-typescript with your dir -for f in ~/Downloads/packages-*.zip; do mkdir "$HOME/Downloads/$(basename -s .zip $f)"; (cd "$HOME/Downloads/$(basename -s .zip $f)" && unzip $f && tar -xvzf @temporalio/core-bridge/core-bridge-*.tgz package/releases/ && cp -r package/releases/* ~/gh/release-sdk-typescript/packages/core-bridge/releases/); done +- Run the following command: -# we should now have all 5 build targets -ls packages/core-bridge/releases/ - -npx lerna version patch --force-publish='*' # or major|minor|etc, or leave out to be prompted. either way, you get a confirmation dialog. - -git checkout -B fix-deps -node scripts/prepublish.mjs -git commit -am 'Fix dependencies' -npx lerna publish from-package # add `--dist-tag next` for pre-release versions -git checkout - -``` - -Finally: - -``` -npm deprecate temporalio@^1.0.0 "Instead of installing temporalio, we recommend directly installing our packages: npm remove temporalio; npm install @temporalio/client @temporalio/worker @temporalio/workflow @temporalio/activity" -``` - -- Cleanup after publishing: - - ```sh - rm -rf $HOME/Downloads/packages-* - rm -rf packages/core-bridge/releases/* ``` + zsh ./scripts/publish.sh + ``` + +3. Other things -- If using a custom [features](https://github.com/temporalio/features/) branch for PR integration tests, merge - that branch into features `main` and update the SDK workflow definition to trigger `features` `main` +- If using a custom [features](https://github.com/temporalio/features) branch for PR integration tests, make + sure the branch is fully up-to-date with `features` - If any APIs have changed, open a PR to update [`samples-typescript`](https://github.com/temporalio/samples-typescript/). Once merged, update the `next` branch: diff --git a/docs/building.md b/docs/building.md deleted file mode 100644 index 81181ac2a..000000000 --- a/docs/building.md +++ /dev/null @@ -1,32 +0,0 @@ -## Building `temporal_sdk_typescript_bridge` - -`temporal_sdk_typescript_bridge` is a native Node.js module written in Rust using [neon](https://neon-bindings.com/). -One of the advantages of using Rust is that it's easy to cross compile to various platforms and architectures. - -By using Node.js' `n-api` we get a binary which _should_ work on all supported Node versions thanks to `n-api`'s [ABI stability](https://nodejs.org/en/docs/guides/abi-stability/). - -### Prerequisites for M1 Macs - -1. Install rosetta with `softwareupdate --install-rosetta` -1. Make sure you have brew under Rosetta alongside your M1 brew intallation
- See: https://github.com/Homebrew/brew/issues/9173
- `arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"` - -### Setting up a Rust cross-compilation MacOS build environment - -1. Download [rustup](https://rustup.rs/). -1. Run `rustup target add x86_64-apple-darwin` - if you're using a mac with an M1 chip -1. Run `rustup target add aarch64-apple-darwin` - if you're using a mac with an Intel chip
- **NOTE:** you can only compile for aarch64 if you have MacOS Big Sur or later -1. Run `rustup target add x86_64-pc-windows-gnu` -1. Run `rustup target add x86_64-unknown-linux-gnu` -1. Run `rustup target add aarch64-unknown-linux-gnu` -1. Run `brew tap messense/macos-cross-toolchains` -1. Run `brew install x86_64-unknown-linux-gnu` to enable Linux x86_64 compilation -1. Run `brew install aarch64-unknown-linux-gnu` to enable Linux aarch64 compilation -1. Run `brew install mingw-w64` to enable Windows compilation on Intel Macs
- Or `arch -x86_64 /usr/local/bin/brew install mingw-w64` on M1 Macs -1. Configure cargo for the Windows and Linux build targets - `cp etc/mac-cargo-config.toml ~/.cargo/config.toml` -1. Install the project's dependencies with `NPM_CONFIG_FOREGROUND_SCRIPTS=true npm ci` if you haven't already -1. Build the the bridge with `CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnu-gcc CC_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-gcc npx lerna run --stream build-rust -- --target all` diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100644 index 000000000..9198bd577 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,123 @@ +#!/bin/zsh +set -euo pipefail + +local workdir=$( mktemp -d -t sdk-typescript-release ) +trap 'cd / && rm -rf "$workdir"' EXIT +cd "$workdir" + +# FIXME Make this a parameter +# e.g. 'main' or 'releases/1.10.x' +source_branch=main + +# Manually download all native artifacts from the latest build + +mkdir -p artifacts package/releases +open artifacts + +echo -e 'Please do the following:' +echo -e ' 1. Open the \e]8;;https://github.com/temporalio/sdk-typescript/actions/workflows/ci.yml?query=branch%3A'"$source_branch"'\e\\GHA status page\e]8;;\e\\ for the "Continuous Integration" workflow, on branch main.' +echo -e ' 2. From there, select the latest execution' +echo -e ' 3. Download all corebridge-native-* artifacts to the "artifacts" directory that just opened' + +echo +echo -e 'Press ENTER once this is completed.' +read enterKey + +local count=$( find artifacts -type f -name "corebridge-native-*.zip" | wc -l ) +if [ $count -ne 5 ]; then + echo "The 'artifacts' directory does not contain exactly 5 files named 'corebridge-native-*.zip'" + echo "Aborting" + exit 1 +fi + +git clone --branch $source_branch --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/sdk-typescript.git +cd sdk-typescript + +# Extract native libs and organize them correctly +for name in ../artifacts/*.zip ; do + unzip -q ${name} -d packages/core-bridge/releases/ +done + +npm ci --ignore-scripts +npm run build -- --ignore @temporalio/core-bridge + +echo +echo 'Does this look correct?' +echo +ls -l packages/core-bridge/releases/*/* + +echo +echo 'Press ENTER to go on with publishing, or Ctrl+C to abort' + +read enterKey + +echo 'Publishing...' + +# User will be asked to indicate which type of release and to confirm, +# then the Publish commit will be created and pushed to the main branch. +npx lerna version --force-publish='*' + +local version=$( jq -r '.version' < lerna.json ) + +git checkout -B fix-deps +node scripts/prepublish.mjs +git commit -am 'Fix dependencies' + +# Check if the version matches the pattern +if [[ $version =~ '^[0-9]+\.[0-9]+\.[0-9]+$' ]]; then + npx lerna publish from-package +else + npx lerna publish from-package --dist-tag next +fi + +npm deprecate "temporalio@^${version}" "Instead of installing temporalio, we recommend directly installing our packages: npm remove temporalio; npm install @temporalio/client @temporalio/worker @temporalio/workflow @temporalio/activity" + +echo -e 'Please do the following:' +echo -e ' 1. Open the \e]8;https://github.com/temporalio/sdk-typescript/releases/new?tag=v'"$version"'\e\\GitHub New Release page\e]8;;\e\\ and select the 'v"$version"' tag.' +echo -e ' 2. In the Release Title field, enter '"$version"'' +echo -e ' 3. Paste the release notes inkto the description field' +if [[ $version =~ '^[0-9]+\.[0-9]+\.[0-9]+$' ]]; then + echo -e ' 4. Make sure that the "Set as a pre-release" checkbox is unchecked' + echo -e ' and that the "Set as the latest release" checkbox is checked' +else + echo -e ' 4. Make sure that the "Set as a pre-release" checkbox is checked' + echo -e ' and that the "Set as the latest release" checkbox is unchecked' +fi +echo -e ' 5. Press the "Save draft" button, then ask someone else to review' +echo -e ' 6. Press the "Publish Release" buton to complete the release process' + +echo +echo -e 'Press ENTER once this is completed.' +read enterKey + +cd "$workdir" + +if [[ $version =~ '^[0-9]+\.[0-9]+\.[0-9]+$' ]]; then + + ## + # Update the samples repo + ## + + ( + git clone --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/samples-typescript.git + cd samples-typescript + + npm i + + # Update all samples + zx .scripts/upgrade-versions.mjs "^${version}" + + # Update the package.json file + npm i + + git checkout -b "typescript-${version}" + git add --all + git commit -m "Update TS SDK to ${version}" + git push + + gh pr create \ + --title "Update TS SDK to ${version}" \ + --body "## What changed"$'\n\n'"- Update TS SDK to ${version}" \ + --head "typescript-${version}" + ) +fi \ No newline at end of file