Skip to content

Build and publish

Build and publish #5

Workflow file for this run

name: Build and publish
on:
workflow_dispatch:
inputs:
version:
type: choice
description: "Type of version bump for this release."
required: true
options:
- patch
- minor
- major
- none
jobs:
build_and_publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout πŸ’Ό
uses: actions/checkout@v4
- name: Install Node.js 🧩
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Check for critical vulnerabilities πŸ”Ž
run: npm audit --audit-level critical --omit=dev
- name: Install dependencies πŸ“¦
run: npm ci
- name: Run tests πŸ§ͺ
run: npm test
- name: Build πŸ—οΈ
run: npm run build
- name: Bump version πŸ“ˆ
id: version
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
NEW_VERSION=$(npm version ${{ inputs.version }} --message $'Update version to %s\n\nAutomated version bump by GitHub Action.')
git push --follow-tags --no-verify
echo "new-version=${NEW_VERSION}" >> $GITHUB_OUTPUT
if: inputs.version && inputs.version != 'none'
- name: Set up NPM πŸ”‘
run: npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}"
- name: Publish πŸš€
run: npm publish --access public
- name: Create release ⛩️
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.new-version }}