From c6ca8bbcb2f3382b8d807e9de17c79dcbd4b817e Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Fri, 12 Jan 2024 18:41:19 -0500 Subject: [PATCH 1/5] [WIP] Update publish instructions --- CONTRIBUTING.md | 82 +++++++++-------------------------- docs/building.md | 32 -------------- scripts/publish.sh | 106 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 94 deletions(-) delete mode 100644 docs/building.md create mode 100644 scripts/publish.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 254ba729d..47a3ddd34 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -182,80 +182,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..d834a80bc --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,106 @@ +#!/bin/zsh +set -euo pipefail + +local workdir=$( mktemp -d -t sdk-typescript-release ) +trap 'cd / && rm -rf "$workdir"' EXIT +cd "$workdir" + +# Manually download all native artifacts from the latest main 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%3Amain\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 packages-* 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 "packages-*.zip" | wc -l ) +if [ $count -ne 5 ]; then + echo "The 'artifacts' directory does not contain exactly 5 files named 'packages-*.zip'" + echo "Aborting" + exit 1 +fi + +# Extract native libs and organize them correctly +for name in artifacts/*.zip ; do + unzip -cq ${name} '@temporalio/core-bridge/core-bridge-*.tgz' | + tar -xvz package/releases/ +done + +git clone --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/sdk-typescript.git +cd sdk-typescript + +npm ci --ignore-scripts +npm run build -- --ignore @temporalio/core-bridge + +cp -r ../package/releases packages/core-bridge/releases + +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 patch --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 '"$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 + git clone --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/features.git + cd features + + # Update typescript_latest in ci.yaml + sed -i '' 's%^\([ ]*typescript_latest: \).*$%\1\''"$version"'\'%' .github/workflows/ci.yaml + + # Update @temporalio/* dependencies in package.json + sed -i '' 's#\("@temporalio/.*": "^\)[^"]*\(",\)#\1'"$version"'\2#' package.json + + # Update package-lock.json + npm i +fi \ No newline at end of file From 4d641efda82112f6efa80dbe2927332917d30eae Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Wed, 22 May 2024 10:35:16 -0400 Subject: [PATCH 2/5] Updated script --- scripts/publish.sh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index d834a80bc..f3d947156 100644 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -13,33 +13,30 @@ 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%3Amain\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 packages-* artifacts to the "artifacts" directory that just opened' +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 "packages-*.zip" | wc -l ) +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 'packages-*.zip'" + echo "The 'artifacts' directory does not contain exactly 5 files named 'corebridge-native-*.zip'" echo "Aborting" exit 1 fi -# Extract native libs and organize them correctly -for name in artifacts/*.zip ; do - unzip -cq ${name} '@temporalio/core-bridge/core-bridge-*.tgz' | - tar -xvz package/releases/ -done - git clone --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 -cp -r ../package/releases packages/core-bridge/releases - echo echo 'Does this look correct?' echo @@ -54,7 +51,7 @@ 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 patch --force-publish='*' +npx lerna version --force-publish='*' local version=$( jq -r '.version' < lerna.json ) From 8e38424d06aa8e496478eb053a333d507ef1d004 Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Tue, 16 Jul 2024 15:07:48 -0400 Subject: [PATCH 3/5] Also update features and samples repo --- scripts/publish.sh | 65 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index f3d947156..718bad361 100644 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -5,6 +5,10 @@ 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 main build mkdir -p artifacts package/releases @@ -26,7 +30,7 @@ if [ $count -ne 5 ]; then exit 1 fi -git clone --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/sdk-typescript.git +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 @@ -89,15 +93,58 @@ read enterKey cd "$workdir" if [[ $version =~ '^[0-9]+\.[0-9]+\.[0-9]+$' ]]; then - git clone --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/features.git - cd features - # Update typescript_latest in ci.yaml - sed -i '' 's%^\([ ]*typescript_latest: \).*$%\1\''"$version"'\'%' .github/workflows/ci.yaml + ## + # Update the features repo + ## + + ( + git clone --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/features.git + cd features + + # Update typescript_latest in ci.yaml + sed -i '' 's%^\([ ]*typescript_latest: \).*$%\1'"'$version'"'%' .github/workflows/ci.yaml + + # Update @temporalio/* dependencies in package.json + sed -i '' 's#\("@temporalio/.*": "^\)[^"]*\(",\)#\1'"$version"'\2#' package.json + + # Update package-lock.json + npm i + + git checkout -b "typescript-${version}" + git add --all + git commit -m "Update TS SDK to ${version}" + + gh pr create \ + --title "Update TS SDK to ${version}" \ + --body "## What changed"$'\n\n'"- Update TS SDK to ${version}" \ + --head "typescript-${version}" + ) + + ## + # 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 "^1.10.2" + + # Update the package.json file + npm i - # Update @temporalio/* dependencies in package.json - sed -i '' 's#\("@temporalio/.*": "^\)[^"]*\(",\)#\1'"$version"'\2#' package.json + git checkout -b "typescript-${version}" + git add --all + git commit -m "Update TS SDK to ${version}" + git push - # Update package-lock.json - npm i + 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 From 46bd793dd674dd6820e0e062f8d40d93efb937aa Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Wed, 24 Jul 2024 17:13:34 -0400 Subject: [PATCH 4/5] Add missing git pull + other minor fixes --- scripts/publish.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index 718bad361..de731783e 100644 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -9,13 +9,13 @@ cd "$workdir" # e.g. 'main' or 'releases/1.10.x' source_branch=main -# Manually download all native artifacts from the latest main build +# 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%3Amain\e\\GHA status page\e]8;;\e\\ for the "Continuous Integration" workflow, on branch main.' +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' @@ -73,7 +73,7 @@ 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 '"$version"' tag.' +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 @@ -97,7 +97,7 @@ if [[ $version =~ '^[0-9]+\.[0-9]+\.[0-9]+$' ]]; then ## # Update the features repo ## - +# pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between main and typescript-1.10.3, Head ref must be a branch (createPullRequest) ( git clone --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/features.git cd features @@ -114,6 +114,7 @@ if [[ $version =~ '^[0-9]+\.[0-9]+\.[0-9]+$' ]]; then 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}" \ @@ -132,7 +133,7 @@ if [[ $version =~ '^[0-9]+\.[0-9]+\.[0-9]+$' ]]; then npm i # Update all samples - zx .scripts/upgrade-versions.mjs "^1.10.2" + zx .scripts/upgrade-versions.mjs "^${version}" # Update the package.json file npm i From de7c4d39ac8d863bf56d5a6e247f52de3ae9b330 Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Wed, 25 Sep 2024 13:48:24 -0400 Subject: [PATCH 5/5] No longer need to update the feature repo on release --- scripts/publish.sh | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index de731783e..9198bd577 100644 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -94,34 +94,6 @@ cd "$workdir" if [[ $version =~ '^[0-9]+\.[0-9]+\.[0-9]+$' ]]; then - ## - # Update the features repo - ## -# pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between main and typescript-1.10.3, Head ref must be a branch (createPullRequest) - ( - git clone --depth 1 --shallow-submodules --recurse-submodules https://github.com/temporalio/features.git - cd features - - # Update typescript_latest in ci.yaml - sed -i '' 's%^\([ ]*typescript_latest: \).*$%\1'"'$version'"'%' .github/workflows/ci.yaml - - # Update @temporalio/* dependencies in package.json - sed -i '' 's#\("@temporalio/.*": "^\)[^"]*\(",\)#\1'"$version"'\2#' package.json - - # Update package-lock.json - 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}" - ) - ## # Update the samples repo ##