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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions .circleci/config.yml

This file was deleted.

25 changes: 16 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
name: Test & Build

name: build
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.

push:
branches: '*'
pull_request:
branches: '*'

branches:
- '**'
jobs:
test-build:
name: Run tests and build project
build:
runs-on: ubuntu-latest
permissions:
contents: read
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
- 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 }}
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.