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

publish @derekstride/tree-sitter-sql npm package #223

Merged
merged 4 commits into from
Nov 17, 2023
Merged

Conversation

DerekStride
Copy link
Owner

@DerekStride DerekStride commented Nov 9, 2023

fixes #195

This sets up a workflow to publish to npm when PRs are merged into main.

I have a few open questions that anyone who has experience publishing to npm can help with:

  1. Will we need to continually bump the version number in order to publish?
  2. Should we instead use git tags to publish dedicated versions instead on every change?

cc// @rien

- run: npm ci
- run: npm publish --access public.
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link
Owner Author

Choose a reason for hiding this comment

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

I already setup this token ☑️

@dmfay
Copy link
Collaborator

dmfay commented Nov 10, 2023

  1. Will we need to continually bump the version number in order to publish?

yes, you can't republish the same version number

  1. Should we instead use git tags to publish dedicated versions instead on every change?

I think this is a good idea! Especially because we don't have a way to control semver (there are things like conventional commit with npm plugins but they do require some discipline to use)

node-version: 21
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish --access public.
Copy link

Choose a reason for hiding this comment

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

You could also use https://github.com/JS-DevTools/npm-publish, it only publishes a new version if the package version differs fro the last one on npm. We're using it for our npm package here: https://github.com/dodona-edu/dolos/blob/main/.github/workflows/ci-cd.yml#L529

But this command is much simpler, and might do the same check anyway.

@DerekStride
Copy link
Owner Author

I've updated the PR to publish to npm on publish instead of during push to main. This will mean we need to publish an new release on Github before it get's pushed to NPM.

@dmfay @matthias-Q I'm all for adopting conventional commits & semantic versioning and starting to track breaking changes to the schema if both of you are on board as well. We can unofficially start now but should start ourselves & asking other contributors to follow the guidelines after this PR lands and we publish our first release.

I've also added a CONTRIBUTING.md file & included a section on commit messages to encourage the use of conventional commits as suggested. The file also explains how to run tests, run the github pages server, and prepare a release. I'd appreciate feedback & suggestions on the document as I want it to reflect a consensus on our thoughts for the project.

@DerekStride DerekStride marked this pull request as ready for review November 13, 2023 20:56
CONTRIBUTING.md Outdated

## Pushing a new Version

Create a new PR to bump the version number in `package.json`. Bump the major version if the commit log since the last
Copy link
Collaborator

Choose a reason for hiding this comment

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

conventional commits let us automate this! add commit-and-tag-version as a dev dependency, with a release npm script to run it as described. Then any collaborator can npm run release locally to generate the version bump commit (including a changelog) and tag it, and pushing main + tags will let the action take over

Copy link
Owner Author

Choose a reason for hiding this comment

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

Awesome, I've added some commits to use the commit-and-tag-version package, updated the docs, and used it to generate an initial CHANGELOG.md.

@DerekStride
Copy link
Owner Author

Any final comment or should I ship 🚢 this PR and publish our first release! 🎉

@matthias-Q
Copy link
Collaborator

I say go for it.
(Tip: I have set up a pre-commit hook in my machine to check for conventional commits)

@DerekStride DerekStride merged commit e29d365 into main Nov 17, 2023
4 checks passed
@DerekStride DerekStride deleted the npm-package branch November 17, 2023 02:02
@DerekStride
Copy link
Owner Author

Published 🎉 https://www.npmjs.com/package/@derekstride/tree-sitter-sql

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.

Publish on NPM
4 participants