Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: streamline package publishing #453

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

wjhsf
Copy link
Contributor

@wjhsf wjhsf commented Sep 9, 2024

Following today's v5 release, we saw a few points of improvement on our release process:

  1. The API docs include the current version number; docs are now updated as part of the version script.
  2. Two tests use a hard-coded version of the project. There's not much value added by doing that, and it's annoying to maintain, so I changed them to use the version file.
    a. The version file is also something we've considered removing, but in the meantime I've added a test to make sure that the file just exports a valid semver string.
  3. Added a GitHub Actions workflow to publish to npm, triggered by creating a GitHub release.

The new release process is:

  1. Check out code to release
  2. npm version <type>, using major/minor/etc. as appropriate
  3. git push && git push tags/<version>
  4. Create GitHub release
  5. 🎉 it's on npm!

Important: Publishing will require creating/storing an NPM_TOKEN secret. So gotta do that before this will actually work.

This PR also contains a few prettier fixes because that happens sometimes.

Comment on lines +95 to +98
"docs": "npm run build && npm run docs:ci",
"docs:ci": "npm run docs:extract -- --local && npm run docs:generate",
"docs:generate": "api-documenter markdown --input-folder ./tmp --output-folder ./api/docs",
"docs:extract": "api-extractor run --verbose",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree with this specific renaming. There are actually two distinct processes happening here:

  1. Public API metadata is extracted from the code
  2. Documentation is generated from the code

If we're going to rename, we should probably use names that reflect these different processes so we don't conflate them as I originally did.

Also, we shouldn't use pass --local in the docs:ci script. That flag disables the validation which checks if the public API has changed. The API report that api-extractor produces should be thought of as similar to package-lock.json only it's a lockfile for public API changes, not dependencies. Following that comparison, consider the workflow for package-lock.json:

  • Changes are deliberately made to the lockfile by a developer (or dependabot) locally and then the change is committed
  • When running npm ci in an automated environment, if the lockfile doesn't match package.json then it will error

We should follow a similar process for the API report. That is how the previous scripts operated with api:dev being the deliberate, local change and api:extract being the automated one which should fail if there is a difference detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants