Skip to content

publishToNPM

publishToNPM #27

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: publishToNPM
# Controls when the action will run. Triggers the workflow on pull request
# event
on: workflow_dispatch
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.19.0'
registry-url: 'https://registry.npmjs.org'
- name: Get Branch Name
id: branch_name
run: echo "::set-output name=BRANCH_NAME::$(git branch --show-current)"
- name: Create Draft Release
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
PREVIOUS_VERSION=$(git tag -l | sort -V | tail -n 2 | head -n 1)
echo "Current Version: $CURRENT_VERSION"
echo "Previous Version: $PREVIOUS_VERSION"
echo "List of tags:"
git fetch --prune --unshallow --tags
# Get the latest tag
latest_tag=$(git for-each-ref --sort=-taggerdate --format '%(refname:short)' refs/tags | head -n 1)
echo "Latest Tag: $latest_tag"
# Extract commit messages between previous and current versions
COMMIT_MESSAGES=$(git log --pretty=format:"%s" $PREVIOUS_VERSION..HEAD)
echo "Commit Messages: $COMMIT_MESSAGES"
gh release create "$CURRENT_VERSION" -t "Release $CURRENT_VERSION" -n "Release Notes for $CURRENT_VERSION" -d <<< "$COMMIT_MESSAGES"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}