Build and publish #1
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: 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: Add license notice π | |
run: npm run license | |
- 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: Publish π | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create release β©οΈ | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.version.outputs.new-version }} |