Node.js Webpack Package #14
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
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | |
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | |
name: Node.js Webpack Package | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: 22.x | |
restore-keys: | | |
22.x | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm test | |
- name: Build project | |
run: npm run build | |
- name: Copy package.json to dist directory | |
run: cp package.json dist/ | |
publish-gpr: | |
needs: build | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
registry-url: https://registry.npmjs.org/ | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: 22.x | |
restore-keys: | | |
22.x | |
- name: Install dependencies | |
run: npm ci | |
- name: Set up Git user | |
run: | | |
git config --global user.email "github@sl.neteng.cc" | |
git config --global user.name "SunDevil311" | |
- name: Increment version | |
run: npm version patch | |
- name: Copy package.json to dist directory | |
run: cp package.json dist/ | |
- name: Publish package | |
working-directory: ./dist | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |