Skip to content

Commit

Permalink
feat(publish-if-not-exists): add package manager as input
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshya0246 committed Nov 3, 2023
1 parent e3c2ae4 commit ee8fc2c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion publish-if-not-exists/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ inputs:
description: NPM access token
required: true

package_manager:
description: Package manager to use for publishing. Can be 'npm' or 'pnpm'
required: false
default: 'npm'

runs:
using: 'composite'
steps:
Expand All @@ -32,10 +37,18 @@ runs:
echo "version: $version"
package_ref="$name@$version"
if [[ "${{ inputs.package_manager }}" != "pnpm" && "${{ inputs.package_manager }}" != "npm" ]]; then
echo "Unsupported package manager: ${{ inputs.package_manager }}"
exit 1
fi
if npm view $package_ref > /dev/null 2>&1 ; then
echo "Package $package_ref already published"
exit 0
fi
echo "Publishing version $package_ref"
cd ${{ inputs.path }} && npm publish --access public
echo "Using ${{ inputs.package_manager }} as package manager"
cd ${{ inputs.path }} && ${{ inputs.package_manager }} publish --access public

0 comments on commit ee8fc2c

Please sign in to comment.