ci.yml #61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci.yml | |
env: | |
CI: true | |
NODE_VERSION: 18 | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: write # for dependabot updates | |
jobs: | |
unit-tests: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- name: Install dependencies | |
run: bun install | |
- name: Run unit tests | |
run: bun run test | |
publish-to-npm-public: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
needs: unit-tests | |
# Avoid running for non-main branches and non-merge events like new pull requests. | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- run: bun install | |
- name: Publish to Github Package Registry, if version was incremented | |
uses: JS-DevTools/npm-publish@v2 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
ignore-scripts: false # Allows the project's `prepublishOnly` script. | |
strategy: upgrade # Publish only if the version was incremented. |