NPM build, test and publish #9
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: npm-publish | |
run-name: NPM build, test and publish | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
paths: | |
- 'package.json' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Bun.js | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Update bun dependencies | |
run: | | |
bun i | |
bun run build | |
bun run test --if-present | |
- name: Commit and push changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: 'package*.json' | |
message: 'Bot: bun deps update' | |
- name: Store build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: | | |
dist | |
package*.json | |
publish-npmjs-com: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Bun.js | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
- name: Prepare npm build | |
run: | | |
echo "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}" > .npmrc | |
sed -i 's!./src!./dist!g' ./package.json | |
bun i | |
- name: Publish to npmjs.com | |
run: bun publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |