Format corrected #3
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
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
name: Publish | ||
on: push | ||
jobs: | ||
if: | | ||
contains(github.event.head_commit.message, '[skip ci]') == false && | ||
startsWith(github.ref, 'refs/tags/v') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
- name: Extract the version and commit body from the tag | ||
shell: bash | ||
id: extract_release | ||
run: | | ||
VERSION="${{ github.ref }}" | ||
VERSION=${VERSION##*/v} | ||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | ||
EOF=$(od -An -N6 -x /dev/urandom | tr -d ' ') | ||
BODY=$(git show -s --format=%b) | ||
echo "BODY<<$EOF" >> $GITHUB_OUTPUT | ||
echo "$BODY" >> $GITHUB_OUTPUT | ||
echo "$EOF" >> $GITHUB_OUTPUT | ||
if [[ $VERSION == *"-"* ]] ; then | ||
echo "TAG=--tag next" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Publish package to npm | ||
shell: bash | ||
run: | | ||
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | ||
npm whoami | ||
npm publish ${{ steps.extract_release.outputs.TAG }} |