Skip to content

Commit

Permalink
NEW: @W-15652656@: Add in manual workflow to publish to npm (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-carter-at-sf committed May 8, 2024
1 parent af2dc05 commit 03498ee
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/publish-package-to-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: publish-package-to-npm
on:
workflow_dispatch:
inputs:
package:
description: Package to be published
type: string
required: true
version:
description: Version to be published
type: string
required: true
dryrun:
description: Add --dry-run to npm publish step? (Uncheck to actually publish)
type: boolean
required: false
default: true

jobs:
verify-and-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/${{inputs.package}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Verify we are using the correct package.json file
run: |
[[ -f package.json ]] || (echo "::error:: ./packages/${{inputs.package}}/package.json does not exist." && exit 1)
PACKAGE_VERSION=`cat package.json | jq '.version' | xargs`
[[ ${{ inputs.version }} == ${PACKAGE_VERSION} ]] || (echo "::error:: Input version ${{ inputs.version }} does not match package.json version ${PACKAGE_VERSION}" && exit 1)
PACKAGE_NAME=`cat package.json | jq '.name' | xargs`
[[ "@salesforce/${{ inputs.package }}" == ${PACKAGE_NAME} ]] || (echo "::error:: Input package "@salesforce/${{ inputs.package }}" does not match package.json name ${PACKAGE_NAME}" && exit 1)
- name: Build and test
run: |
npm install
npm run build
npm run test
- name: publish-to-npm
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
if [ "${{inputs.dryrun}}" == "true" ]; then
npm publish --tag latest-alpha --dry-run --verbose
else
npm publish --tag latest-alpha --verbose
fi
2 changes: 1 addition & 1 deletion packages/code-analyzer-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview",
"repository": {
"type": "git",
"url": "https://github.com/forcedotcom/code-analyzer-core.git",
"url": "git+https://github.com/forcedotcom/code-analyzer-core.git",
"directory": "packages/code-analyzer-core"
},
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/code-analyzer-core/src/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export interface CodeLocation {
getFile(): string
getStartLine(): number
getStartColumn(): number
getEndLine(): number
getEndColumn(): number
getEndLine(): number | null
getEndColumn(): number | null
}

export interface Violation {
Expand Down
1 change: 1 addition & 0 deletions packages/code-analyzer-core/src/rules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum SeverityLevel {
Critical = 0, // Only used in the event of an engine failure
High = 1,
Moderate = 2,
Low = 3
Expand Down
2 changes: 1 addition & 1 deletion packages/code-analyzer-engine-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview",
"repository": {
"type": "git",
"url": "https://github.com/forcedotcom/code-analyzer-core.git",
"url": "git+https://github.com/forcedotcom/code-analyzer-core.git",
"directory": "packages/code-analyzer-core"
},
"main": "dist/index.js",
Expand Down

0 comments on commit 03498ee

Please sign in to comment.