-
Notifications
You must be signed in to change notification settings - Fork 5
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
name: Test & Build | ||
|
||
name: build | ||
on: | ||
release: | ||
types: [created] | ||
push: | ||
branches: '*' | ||
pull_request: | ||
branches: '*' | ||
|
||
branches: | ||
- '**' | ||
jobs: | ||
test-build: | ||
name: Run tests and build project | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
node-version: '20.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
cache: npm | ||
- run: npm ci | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
- run: npm run test:coverage | ||
- run: npm run build | ||
- run: npm publish | ||
if: github.event_name == 'release' && github.event.action == 'created' | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I take it we need to add the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
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.
Will this be triggered when we "draft a new release"? I have used the type
published
in the past.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.
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
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.
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/775259Not 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.
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.
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.