Fix publish code.
This commit is contained in:
@@ -4,6 +4,10 @@ inputs:
|
|||||||
tgz:
|
tgz:
|
||||||
description: "Path to the tarball file to publish."
|
description: "Path to the tarball file to publish."
|
||||||
required: true
|
required: true
|
||||||
|
workingDirectory:
|
||||||
|
description: "Working directory for the publish operation."
|
||||||
|
required: false
|
||||||
|
default: "."
|
||||||
registry:
|
registry:
|
||||||
description: "NPM registry URL."
|
description: "NPM registry URL."
|
||||||
required: false
|
required: false
|
||||||
@@ -33,24 +37,32 @@ runs:
|
|||||||
# Trim whitespace
|
# Trim whitespace
|
||||||
TGZ_PATH=$(echo "$TGZ_PATH" | xargs)
|
TGZ_PATH=$(echo "$TGZ_PATH" | xargs)
|
||||||
|
|
||||||
if [[ ! "$TGZ_PATH" =~ ^[./~] ]]; then
|
if [[ ! "$TGZ_PATH" =~ ^(\./|/|~) ]]; then
|
||||||
echo "Path does not start with . / or ~, adding ./ prefix"
|
echo "Path does not start with ./ / or ~, adding ./ prefix"
|
||||||
TGZ_PATH="./$TGZ_PATH"
|
TGZ_PATH="./$TGZ_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Verify the tarball exists
|
||||||
|
if [ ! -f "$TGZ_PATH" ]; then
|
||||||
|
echo "Error: Tarball not found at $TGZ_PATH (working directory: $(pwd))"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Configure npm authentication for the registry (scoped to project)
|
# Configure npm authentication for the registry (scoped to project)
|
||||||
REGISTRY_PATH=$(echo "${{ inputs.registry }}" | sed -E 's|https?://||')
|
REGISTRY_PATH=$(echo "${{ inputs.registry }}" | sed -E 's|https?://||')
|
||||||
npm config set --location=project registry "${{ inputs.registry }}"
|
npm config set --location=project registry "${{ inputs.registry }}"
|
||||||
npm config set --location=project "//${REGISTRY_PATH}:_authToken" "${{ inputs.apiKey }}"
|
npm config set --location=project "//${REGISTRY_PATH}:_authToken" "${{ inputs.apiKey }}"
|
||||||
|
|
||||||
echo "Publishing $TGZ_PATH to ${{ inputs.registry }}"
|
echo "Publishing $TGZ_PATH to ${{ inputs.registry }}"
|
||||||
npm publish --location=project "$TGZ_PATH" --access ${{ inputs.access }}
|
npm publish "$TGZ_PATH" --access ${{ inputs.access }}
|
||||||
|
|
||||||
echo "Package published successfully"
|
echo "Package published successfully"
|
||||||
|
working-directory: ${{ inputs.workingDirectory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
- name: "Clean up npm authentication"
|
- name: "Clean up npm authentication"
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
# Clean up project .npmrc in case of early exit
|
# Clean up project .npmrc in case of early exit
|
||||||
rm -f .npmrc
|
rm -f .npmrc
|
||||||
|
working-directory: ${{ inputs.workingDirectory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
Reference in New Issue
Block a user