diff --git a/Development.md b/Development.md index 15180925..ca0c6249 100644 --- a/Development.md +++ b/Development.md @@ -56,15 +56,25 @@ lsif-java snapshot-lsif # from github.com/sourcegraph/lsif-java ## Publishing a release -First, make sure you are on the main branch and have no dirty changes. - -Next, run the `dev/bump-version` script to bump the version in package.json and -push a git tag to trigger a CI job. +First, make sure you have no dirty changes. Then run the `dev/bump-version` +script. It creates a `release/vX.Y.Z` branch from the latest `main`, bumps the +version in package.json, pushes the branch and opens a release PR. ``` ./dev/bump-version VERSION_TO_RELEASE # example: ./dev/bump-version 2.3.1 ``` +Once the release PR is merged, tag the merge commit on `main` and push the tag +to trigger the release job (use the name of your remote for +sourcegraph/scip-typescript instead of `origin` if it differs): + +``` +git fetch origin main +git show origin/main:package.json | grep '"version"' # should show the new version +git tag -a v2.3.1 -m "Version 2.3.1" origin/main +git push origin v2.3.1 +``` + Once the release job has finished, create a GitHub release https://github.com/sourcegraph/scip-typescript/releases/new diff --git a/dev/bump-version b/dev/bump-version index f34b7b5f..e0c5a224 100755 --- a/dev/bump-version +++ b/dev/bump-version @@ -1,11 +1,9 @@ #!/usr/bin/env bash set -eux -# Assert that current branch is main -git rev-parse --abbrev-ref HEAD | grep -q main - -# Assert that there are no uncommitted changes -git diff-index --quiet HEAD -- +# Creates a release PR that bumps the version in package.json. +# After the PR is merged, tag the merge commit to trigger the release job +# (see Development.md). NEW_VERSION="$1" if ! [[ "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then @@ -13,14 +11,29 @@ if ! [[ "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then exit 1 fi +# Assert that there are no uncommitted changes +git diff-index --quiet HEAD -- + +# The remote pointing at sourcegraph/scip-typescript (override with REMOTE=...) +REMOTE="${REMOTE:-$(git remote -v | awk '$2 ~ /[:\/]sourcegraph\/scip-typescript(\.git)?$/ && $3 == "(push)" { print $1; exit }')}" +if [[ -z "$REMOTE" ]]; then + echo "No git remote for sourcegraph/scip-typescript found, set REMOTE=..." + exit 1 +fi + +BRANCH="release/v$NEW_VERSION" +git fetch "$REMOTE" main +git switch -c "$BRANCH" "$REMOTE/main" + echo "Updating package.json." yarn version --no-git-tag-version --new-version "$NEW_VERSION" -git commit -am "Release v$NEW_VERSION." --allow-empty - -# Commit and tag new version -VERSION_TAG="v$NEW_VERSION" -git add . -git commit -m "Bump version to $VERSION_TAG" --allow-empty -git push origin main -git tag -af "$VERSION_TAG" -m "Version $NEW_VERSION" -git push -f origin "$VERSION_TAG" +git commit -am "Release v$NEW_VERSION." + +git push -u "$REMOTE" "$BRANCH" +gh pr create --repo sourcegraph/scip-typescript --base main --head "$BRANCH" \ + --title "Release v$NEW_VERSION." \ + --body "Bumps the version to $NEW_VERSION. + +### Test plan + +Version bump only. Once merged, pushing the \`v$NEW_VERSION\` tag triggers the release workflow."