Skip to content

Publish release (master only) #29

Publish release (master only)

Publish release (master only) #29

name: Publish release (master only)
on:
workflow_dispatch:
inputs:
releaseType:
type: choice
required: true
description: 'Release type'
default: 'patch'
options:
- patch
- minor
- major
releaseBody:
type: string
required: true
description: 'Release description'
jobs:
publish:
name: Publish to package registry
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
permissions:
contents: write
packages: write
steps:
- name: Checkout branch
uses: actions/checkout@v3
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://npm.pkg.github.com'
cache: 'npm'
- name: Bump version
run: |
git config --global user.name '${{ github.actor }}'
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
echo "VERSION_TAG=$(npm version ${{ github.event.inputs.releaseType }})" >> $GITHUB_ENV
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
- name: Build package
run: npm run build
- name: Publish package
id: publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push new version tag
if: steps.publish.outcome == 'success'
run: git push
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION_TAG }}
body: ${{ github.event.inputs.releaseBody }}