Skip to content

Commit

Permalink
Only publish to NPM if it is a valid tag version
Browse files Browse the repository at this point in the history
NPm Rejects non semver tags
  • Loading branch information
spaceo committed Dec 8, 2023
1 parent cf92659 commit 02bd9af
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/create-release-on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
echo "NPM_VERSION=${RELEASE_NAME}-${RELEASE_SHA}" >> "$GITHUB_ENV"
echo "DIST_FILENAME=dist-$RELEASE_NAME-$RELEASE_SHA.zip" >> "$GITHUB_ENV"
# Validate/parse version tag.
# If it is not a version tag it is ok, we just need to know it.
- uses: nowsprinting/check-version-format-action@v3
id: version

- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -49,13 +54,15 @@ jobs:
echo "Release created 🚀😎 at: ${{ steps.create-release.outputs.url }}" >> $GITHUB_STEP_SUMMARY
- name: Modify package.json for local context
if: steps.version.outputs.is_valid == 'true'
# Values in package.json must match the current GitHub repository to
# publish to it.
run: |
npm exec -- json -I -f package.json -e "this.name='@$GITHUB_REPOSITORY'"
npm exec -- json -I -f package.json -e "this.repository='https://github.com/$GITHUB_REPOSITORY'"
- name: Release NPM package
if: steps.version.outputs.is_valid == 'true'
# The latest tag follows tagged versions to follow NPM conventions.
run: |
npm version ${{ env.NPM_VERSION }} --no-git-tag-version
Expand All @@ -64,7 +71,13 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Adding summary
- name: If created add NPM created summary
if: steps.version.outputs.is_valid == 'true'
run: |
echo "Npm package created 🚀. Version: ${{ env.NPM_VERSION }}" >> $GITHUB_STEP_SUMMARY
- name: If created add NPM NOT created summary
if: steps.version.outputs.is_valid != 'true'
run: |
echo "No npm package created... Just so you know it." >> $GITHUB_STEP_SUMMARY

0 comments on commit 02bd9af

Please sign in to comment.