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

NPM publish from GHA #40

Merged
merged 2 commits into from
Apr 18, 2024
Merged

NPM publish from GHA #40

merged 2 commits into from
Apr 18, 2024

Conversation

microbit-matt-hillsdon
Copy link
Contributor

Align build.yml with similar projects

Align build.yml with similar projects
- run: npm publish
if: github.event_name == 'release' && github.event.action == 'created'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I take it we need to add the NPM_TOKEN secret to this repository.
Is that generate from a specific account?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, it's an org secret, so should work out-of-the-box 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an org secret enabled for specific repos and I added this one.

on:
release:
types: [created]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this be triggered when we "draft a new release"? I have used the type published in the past.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like it doesn't apply to drafts, although the docs are not very clear as to what's the difference: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release

Copy link
Collaborator

@microbit-carlos microbit-carlos Apr 17, 2024

Choose a reason for hiding this comment

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

If we trust this StackOverflow response, if we use release scripts (which we currently don't) could end-up only triggering a published event: https://stackoverflow.com/a/61066906/775259

Not really using that at the moment, so happy to merge it as is, if you want to keep all CI scripts the same, but worth knowing for the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty convinced it won't run for drafts but agree it may not run when a draft is published either, would need to test as the docs are unclear. I have a BAU ticket open to investigate this and will go back and update workflows based on that investigation.

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this isn't published to the GH package registry, no? Only npm.
In that case we probably don't need to add packages: write?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah which I suppose this will never do so fair to remove it. Will update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 22 to 23
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume this is only needed if using private packages from the GH package registry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah which I suppose this will never do so fair to remove it. Will update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@microbit-carlos microbit-carlos left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thanks Matt!

@microbit-carlos microbit-carlos merged commit f49e8e6 into main Apr 18, 2024
1 check passed
@microbit-matt-hillsdon microbit-matt-hillsdon deleted the gh-actions branch April 18, 2024 14:31
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