Skip to content

Commit 4753eba

Browse files
NEW: @W-15652656@: Add in manual workflow to publish to npm (#11)
1 parent af2dc05 commit 4753eba

File tree

6 files changed

+531
-1042
lines changed

6 files changed

+531
-1042
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: publish-package-to-npm
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
package:
6+
description: Package to be published
7+
type: string
8+
required: true
9+
version:
10+
description: Version to be published
11+
type: string
12+
required: true
13+
dryrun:
14+
description: Add --dry-run to npm publish step? (Uncheck to actually publish)
15+
type: boolean
16+
required: false
17+
default: true
18+
19+
jobs:
20+
verify-and-publish:
21+
runs-on: ubuntu-latest
22+
defaults:
23+
run:
24+
working-directory: ./packages/${{inputs.package}}
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
- name: Verify we are using the correct package.json file
31+
run: |
32+
[[ -f package.json ]] || (echo "::error:: ./packages/${{inputs.package}}/package.json does not exist." && exit 1)
33+
PACKAGE_VERSION=`cat package.json | jq '.version' | xargs`
34+
[[ ${{ inputs.version }} == ${PACKAGE_VERSION} ]] || (echo "::error:: Input version ${{ inputs.version }} does not match package.json version ${PACKAGE_VERSION}" && exit 1)
35+
PACKAGE_NAME=`cat package.json | jq '.name' | xargs`
36+
[[ "@salesforce/${{ inputs.package }}" == ${PACKAGE_NAME} ]] || (echo "::error:: Input package "@salesforce/${{ inputs.package }}" does not match package.json name ${PACKAGE_NAME}" && exit 1)
37+
- name: Build and test
38+
run: |
39+
npm install
40+
npm run build
41+
npm run test
42+
- name: publish-to-npm
43+
run: |
44+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
45+
if [ "${{inputs.dryrun}}" == "true" ]; then
46+
npm publish --tag latest-alpha --access public --verbose --dry-run
47+
else
48+
npm publish --tag latest-alpha --access public --verbose
49+
fi

0 commit comments

Comments
 (0)