File Structure Improved #8
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
# .github/workflows/publish.yml | |
name: Publish to npm | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Set up Node.js | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
registry-url: "https://registry.npmjs.org" | |
cache: "npm" | |
# Install dependencies | |
- name: Install dependencies | |
run: npm install | |
# Run tests (optional) | |
- name: Run tests | |
run: npm test | |
# Build the package | |
- name: Build the package | |
run: npm run build | |
# Prepare dist folder for publish | |
- name: Copy necessary files to dist | |
run: cp README.md LICENSE package.json dist/ | |
# Publish dist folder to npm | |
- name: Publish dist folder to npm | |
run: cd dist && npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |