-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (42 loc) · 1.54 KB
/
npm-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
on:
workflow_call:
inputs:
dist_tag:
description: NPM dist tag to publish to
default: latest
required: false
type: string
node_version:
description: Node version to build on
default: "18"
required: false
type: string
package_manager:
default: npm
description: Package manager to use. Can be 'npm' or 'bun'
type: string
secrets:
NPM_TOKEN:
description: NPM token with right access for publishing
required: true
jobs:
publish:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.dist_tag }}
url: ${{ steps.package-version-url.outputs.packageVersionUrl }}
steps:
- uses: ./.github/actions/node-environment-setup
with:
package_manager: ${{ inputs.package_manager }}
node_version: ${{ inputs.node_version }}
- name: Update version for non latest tagged versions
if: inputs.dist_tag != 'latest'
run: npm version "$(npm pkg get version | sed 's/\"//g')"-"$(date +%s)".${{ github.sha }} --allow-same-version --git-tag-version=false --tag-version-prefix=''
- name: Get version url
id: package-version-url
run: echo "packageVersionUrl=https://www.npmjs.com/package/$(npm pkg get name | tr -d '"')/v/$(npm pkg get version | tr -d '"')" >> "$GITHUB_OUTPUT"
- name: Publish to ${{ inputs.dist_tag }} tag with npm registry
run: npm publish --tag ${{ inputs.dist_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}