This is a quick and opinionated set of commands for building and releasing a new version of the packages in this monorepo.
FEDERATION_RELEASE_VERSION=X.Y.Z
(e.g.2.0.1
or2.0.0-beta.3
or2.0.0-preview.99
)git fetch origin main
to fetch the latestmain
branchgit checkout -b "release-$FEDERATION_RELEASE_VERSION" main
git log release-<the version of the last release>..
to see the changes since the last release- Update
CHANGELOG.md
in each repo (more info) - For actual releases (not alpha/beta/preview), consolidate any non-release CHANGELOG entries into a single version
git add ':/*CHANGELOG.md'
to add changelogs to the commit
npx lerna version --no-push --force-publish=\* "$FEDERATION_RELEASE_VERSION"
1git show --pretty="" --name-only HEAD
to see the files in the commitgit --no-pager tag --points-at HEAD
to see the tags that were created
git push --follow-tags -u origin "release-$FEDERATION_RELEASE_VERSION"
to push the version bumps & tags created by lerna in the previous stepecho "https://github.com/apollographql/federation/compare/main...release-$FEDERATION_RELEASE_VERSION?quick_pull=1&title=Release+$FEDERATION_RELEASE_VERSION&template=APOLLO_RELEASE_TEMPLATE.md"
and click the resulting link to open PR in Github- If
gh
is installed (the command-line tool for github), create a PR thusly:gh pr create --title "Release $FEDERATION_RELEASE_VERSION" --body-file ./.github/PULL_REQUEST_TEMPLATE/APOLLO_RELEASE_TEMPLATE.md
- If
- Tag the commit to begin the publishing process2
- For alpha/beta/preview
APOLLO_DIST_TAG=next npm run release:start-ci-publish
- For release
APOLLO_DIST_TAG=latest npm run release:start-ci-publish
- For alpha/beta/preview
echo https://app.circleci.com/pipelines/github/apollographql/federation?filter=mine
and click the resulting link to approve publishing to NPM- There will also be a message posted to #team-atlas in slack that has a link to the approval job
unset FEDERATION_RELEASE_VERSION
to ensure we don't accidentally use this variable later./scripts/check-npm-packages.sh
to spot-check the versions in NPM to ensure the packages were published correctly- For release (i.e. NOT an alpha/beta/preview), also add the
latest-2
dist tag- TODO: Make this easier/go away
- Merge the release PR to
main
Changelogs should be updated when creating a release. If there are no changes for a given package, no need to add a changelog entry.
- gateway-js/CHANGELOG.md
- composition-js/CHANGELOG.md
- subgraph-js/CHANGELOG.md
- query-planner-js/CHANGELOG.md
- internals-js/CHANGELOG.md
- query-graphs-js/CHANGELOG.md
npm version
is getting called due to lerna version lifecycle hooks, which calls npm i --package-lock-only
causing the package lock to get regenerated (this is a good thing).
Mistakes happen. Most of these release steps are recoverable if you mess up.
except don't make any mistakes yet, because we haven't documented troubleshooting steps.
Footnotes
-
Learn more about the
lerna version
command. For our purposes, the important parts are thatlerna
will update versions in the necessarypackage*.json
files and create a tag for each package (e.g.@apollo/federation-internals@2.0.0-preview.7
). ↩ -
npm run release:start-ci-publish
will create apublish/timestamp-goes-here
looking tag, which starts a job in CircleCI to start the publishing process. There's a confirmation prompt in CircleCI that must be accepted before the package is fully published to NPM. ↩