-
Notifications
You must be signed in to change notification settings - Fork 0
Add publish step #33
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
base: main
Are you sure you want to change the base?
Add publish step #33
Conversation
| check-version: true | ||
|
|
||
| - name: Version update | ||
| if: steps.publish.outputs.type != 'none' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this just to make sure there wasn't an error? (Is it possible that the Publish step could fail but still output something?)
(I'm not very familiar with GH actions, so if there's a reference talking about best practices for this stuff, I'd love to see it!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly copied it from an example action.
This one was to see the version update output in the Github actions console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read the docs and now I get it!
| - name: Publish ✨ | ||
| id: publish | ||
| if: github.ref == 'refs/heads/main' | ||
| uses: JS-DevTools/npm-publish@v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a github-developed action or third party? If not github, could you link to it? (Want to verify that it's well-maintained, popular, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| uses: JS-DevTools/npm-publish@v1 | ||
| with: | ||
| token: ${{ secrets.NPM_TOKEN }} | ||
| check-version: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does 'check-version' do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only publish to NPM if the version number in package.json differs from the latest on NPM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also use greater-version-only, to be safe?
| - name: Checkout 🛎️ | ||
| uses: actions/checkout@master | ||
| uses: actions/checkout@v3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know if there was a reason we were pointing at the development branch before / was there a reason you needed to make this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know honestly. It just felt right to point at a specific version, so that things don't break suddenly
| - name: Version update | ||
| if: steps.publish.outputs.type != 'none' | ||
| run: | | ||
| echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does JS-DevTools/npm-publish choose the new version number? Is it using something like semver? (If so, how do you choose whether to bump the patch/minor/major version?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses the version we specify in package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect.
| branch: gh-pages # The branch the action should deploy to. It should be any branch other than `main` | ||
| folder: dist # The folder the action should deploy. | ||
|
|
||
| - name: Publish ✨ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know very little about github actions, but this is a 'step' within the 'build' job. Is it better practice to have a 'build' job and a 'publish' job? (That would be closer to our CircleCI setup for other repos)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question! I don't know the best practices here, so you tell me.
I chose to make it a 'step' for a couple of reasons:
- if I were to make it a job I would have to do 3/4 exact same steps from build
- it was just faster to try it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From some quick Googling, folks advocate for "keeping jobs simple," but there doesn't seem to be a ton of best-practices out there.
I'm curious if it would get rid of the need to repeat steps if you made Publish a separate job, but used the needs directive to specify that the Publish job depends on the Build job?
If so, that feels cleaner to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it

Publishes a new version to NPM if
mainTODO:
NPM_TOKENto github secrets