Skip to content

fix: build step before release in workflow #17

fix: build step before release in workflow

fix: build step before release in workflow #17

Workflow file for this run

name: Release npm package
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Check for release notes
run: |
RELEASE_NOTES="$(npm run release -- --dry-run | awk 'BEGIN { flag=0 } /^---$/ { if (flag == 0) { flag=1 } else { flag=2 }; next } flag == 1')"
echo "RELEASE_NOTES: $RELEASE_NOTES"
# Don't release if there are no changes
if [ "$(echo "$RELEASE_NOTES" | wc -l)" -eq 1 ] ; then
echo "::warning::This release would have no release notes. Does it include changes?"
echo " - You must have at least one fix / feat commit to generate release notes"
echo "*** STOPPING RELEASE PROCESS ***"
echo "RELEASE_NOTES_AVAILABLE=false" >> $GITHUB_ENV
else
echo "RELEASE_NOTES_AVAILABLE=true" >> $GITHUB_ENV
fi
- name: Generate release version
if: success() && env.RELEASE_NOTES_AVAILABLE == 'true'
run: npm run release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_KEY }}
- name: Build the project
if: success() && env.RELEASE_NOTES_AVAILABLE == 'true'
run: npm run build
- name: Push version changes
if: success() && env.RELEASE_NOTES_AVAILABLE == 'true'
run: |
git push --follow-tags origin main
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Publish package
if: success() && env.RELEASE_NOTES_AVAILABLE == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_KEY }}