Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ inputs:
description: The NPM access token to use when publishing
required: true
npm-skip-version-up:
description: Version not up
description: Skip version up
default: "false"
required: false
npm-version-tag:
description: Version tag
default: ""
required: false
directory:
description: Directory
default: "./"
Expand All @@ -21,9 +17,9 @@ inputs:
description: PR label for publish (publish {label})
default: ""
required: false
pr-only-labeled:
description: Only publish if the PR is labeled
default: "false"
pr-version-tag:
description: Version tag for PR
default: "pr"
required: false

runs:
Expand All @@ -34,22 +30,25 @@ runs:
working-directory: ${{ inputs.directory }}
run: |
PREFIX=""
if [ "${{ inputs.npm-version-tag }}" != "" ]; then
PREFIX="${{ inputs.npm-version-tag }}-${{ github.event.number }}-"
if [ "${{ github.event_name }}" == "pull_request" ]; then
PR_SHA_SHORT=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7)
PREFIX="${{ inputs.pr-version-tag }}-${{ github.event.number }}-$PR_SHA_SHORT"
else
PREFIX="${GITHUB_SHA::7}"
fi
npm version prerelease --preid "${PREFIX}${GITHUB_SHA::7}" --no-git-tag-version
npm version prerelease --preid "${PREFIX}" --no-git-tag-version
shell: bash
env:
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
- name: Publish
if: >
inputs.pr-only-labeled == 'false'
github.event_name != 'pull_request'
|| (contains(github.event.pull_request.labels.*.name, 'publish')
|| (inputs.pr-label != ''
&& contains(github.event.pull_request.labels.*.name, format('publish {0}', inputs.pr-label))))
working-directory: ${{ inputs.directory }}
run: |
npm publish ${{ inputs.npm-version-tag != '' && format('--tag {0}', inputs.npm-version-tag) || '' }}
npm publish ${{ github.event_name == 'pull_request' && format('--tag {0}', inputs.pr-version-tag) || '' }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
Loading