-
Notifications
You must be signed in to change notification settings - Fork 0
ci: add npm publish workflow #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| name: Publish to npm | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: "Run npm publish as a dry run" | ||
| required: false | ||
| default: "false" | ||
| type: choice | ||
| options: | ||
| - "false" | ||
| - "true" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: publish-npm-${{ github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout sumit-react | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: sumit-react | ||
|
|
||
| - name: Checkout sumit-api peer package | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: Digitizers/sumit-api | ||
| path: sumit-api | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10.26.0 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org | ||
| cache: pnpm | ||
| cache-dependency-path: | | ||
| sumit-react/pnpm-lock.yaml | ||
| sumit-api/pnpm-lock.yaml | ||
|
|
||
| - name: Build sumit-api peer package | ||
| working-directory: sumit-api | ||
| run: | | ||
| pnpm install --frozen-lockfile | ||
| pnpm build | ||
|
|
||
| - name: Install sumit-react | ||
| working-directory: sumit-react | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Typecheck | ||
| working-directory: sumit-react | ||
| run: pnpm typecheck | ||
|
|
||
| - name: Test | ||
| working-directory: sumit-react | ||
| run: pnpm test | ||
|
|
||
| - name: Build | ||
| working-directory: sumit-react | ||
| run: pnpm build | ||
|
|
||
| - name: Pack check | ||
| working-directory: sumit-react | ||
| run: npm pack --dry-run | ||
|
|
||
| - name: Verify npm token | ||
| working-directory: sumit-react | ||
| run: npm whoami | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
|
||
| - name: Publish public package | ||
| working-directory: sumit-react | ||
| run: | | ||
| if [ "${{ inputs.dry_run }}" = "true" ]; then | ||
| npm publish --access public --dry-run | ||
| else | ||
| npm publish --access public | ||
|
Comment on lines
+82
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The workflow publishes unconditionally once it reaches this step, and Useful? React with 👍 / 👎. |
||
| fi | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checkout omits
ref, soactions/checkoutwill pull the secondary repo’s default branch instead of a revision tied to thesumit-reactrelease being published. That makes publishes non-reproducible: running this workflow for an older branch/tag can build against a newersumit-apistate and fail (or produce a package validated against the wrong peer code). Setrefexplicitly (for example to an input or known tag/sha) so release behavior is stable.Useful? React with 👍 / 👎.