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

Added action to publish to npm on release #175

Merged
merged 11 commits into from
Apr 11, 2024
29 changes: 29 additions & 0 deletions .github/workflows/publish-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish Cookie Policy release

# Only for testing. Should be on: release: types: [published]
on:
- push
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we want that yet, but could make sense to simply publish on every merge to main branch?

This would not create a release tag on GH (unless we can make it automated as well), but may be a nice next step in automating this, instead of relying on manual release.

This is the way we have it set up for our python packages that publish to pip, and in react components I think.
In Vanilla we want more manual control, so we tie it to GH release functionality. But here it probably will make it easier for everyone if it's fully automatic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree on the automation, and there should a way to create the release tag. In fact, we could

  • create the tag
  • create the release on GH
  • publish to npm

on merge to main.

I think this works for now though, and I can make another PR to set up the merge to main actions.


jobs:
build-and-publish:
name: Publish Cookie Policy to NPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- name: Build Cookie Policy
run: |
yarn install
yarn build
yarn test
- if: ${{ !github.event.release.prerelease }}
run: npm publish
samhotep marked this conversation as resolved.
Show resolved Hide resolved
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- if: ${{ github.event.release.prerelease }}
run: npm publish --tag next --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}