Skip to content

Manual Release and Publish #7

Manual Release and Publish

Manual Release and Publish #7

Workflow file for this run

name: Publish to NPM and Create Release
on:
workflow_dispatch:
inputs:
version:
description: 'Update type (major, minor, patch)'
required: true
jobs:
publish:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/[email protected]
- name: Validate version input
run: |
if [[ "${{ github.event.inputs.version }}" =~ ^(major|minor|patch)$ ]]; then
echo "Valid version input"
else
echo "Invalid version input: ${{ github.event.inputs.version }}"
exit 1
fi
- name: Bump version
id: bump_version
run: |
git config user.name github-actions
git config user.email [email protected]
VERSION=$(npm version ${{ github.event.inputs.version }})
echo "$VERSION" > VERSION.txt
git add .
git commit -am "chore(release): $VERSION"
git push
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump_version.outputs.version }}
release_name: Release ${{ steps.bump_version.outputs.version }}
draft: false
prerelease: false