Skip to content

feat: add publish to npm workflow - #164

Merged
eduzatoni merged 1 commit into
New-Architecture-and-Expofrom
MV-1204
Sep 10, 2026
Merged

feat: add publish to npm workflow#164
eduzatoni merged 1 commit into
New-Architecture-and-Expofrom
MV-1204

Conversation

@eduzatoni

Copy link
Copy Markdown
Member

No description provided.

@eduzatoni
eduzatoni marked this pull request as ready for review September 7, 2026 12:46
@hyperspace-pr-bot

hyperspace-pr-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

Control Panel

Hi, I'm an AI-powered Review Bot that helps you with summarizing and reviewing pull requests.
To interact with me, just use the following actions:

  • 📝 Summarize PR
  • 🔍 Review
  • 🗑️ Delete all bot comments and reviews

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR introduces a well-structured refactoring of the CI/CD pipeline—splitting the monolithic build-and-publish workflow into composable reusable workflows—but there are several correctness issues: missing artifact path in the publish step, an unquoted glob passed directly to npm publish, a script-injection risk with the dist-tag expression, dropped --ignore-scripts flags that were intentional in the original Expo sample install steps, and an unnecessary registry-url in the build/pack job. Please address the flagged items before merging.

PR Bot Information

Version: 1.31.20

  • Correlation ID: 05089b00-acee-11f1-898c-20785066999e
  • File Content Strategy: Full file content
  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: issue_comment.edited

uses: actions/setup-node@v5
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: registry-url is unnecessary in the build/pack step and leaks npm registry config into a step that doesn't publish.

registry-url is only needed when actually publishing (it writes the .npmrc with the auth token). It has no effect on npm ci, linting, testing, building, or packing, and could interfere if the registry is unreachable. Move it to publish-npm.yml only, which already has it correctly.

Suggested change
registry-url: 'https://registry.npmjs.org'

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Comment on lines +39 to +42
- name: Dry run publish
run: npm publish --dry-run ./artifacts/*.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: npm publish --dry-run ./artifacts/*.tgz will fail because npm publish does not accept a tarball path as an argument when a NODE_AUTH_TOKEN is set and the working directory is not the package root. More importantly, npm publish <tarball> ignores --dry-run in older npm versions, and in all versions the glob ./artifacts/*.tgz is shell-expanded before npm sees it — if there are zero or multiple files the command silently does the wrong thing.

Consider using npm publish --dry-run from the pack destination directory, or explicitly quote and validate the single .tgz file path before passing it:

Suggested change
- name: Dry run publish
run: npm publish --dry-run ./artifacts/*.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }}
- name: Dry run publish
run: |
TGZ=$(echo artifacts/*.tgz)
npm publish --dry-run "$TGZ"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }}

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Comment on lines +12 to +15
- name: Download package artifact
uses: actions/download-artifact@v6
with:
name: npm-package

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The download-artifact step does not specify a path, so the .tgz is downloaded to the runner's working directory root. The subsequent tar and npm publish commands use the bare glob *.tgz, which happens to match — but this is fragile. If the working directory ever changes or the artifact contains subdirectories, the glob will silently resolve incorrectly. Specifying an explicit path: artifacts (matching the upload convention in build-package.yml) and adjusting the glob to artifacts/*.tgz makes the intent explicit and consistent.

Suggested change
- name: Download package artifact
uses: actions/download-artifact@v6
with:
name: npm-package
- name: Download package artifact
uses: actions/download-artifact@v6
with:
name: npm-package
path: artifacts

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Comment on lines +35 to +40
- name: Publish to npm
run: |
echo "Publishing @emartech/react-native-emarsys-sdk to npm with tag ${{ steps.dist_tag.outputs.tag }}"
npm publish *.tgz --access public --tag ${{ steps.dist_tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security / Bug: The dist-tag value from steps.dist_tag.outputs.tag is interpolated directly into the shell command via ${{ }} expression syntax rather than being passed as an environment variable. While TAG is hardcoded to either beta or latest in this workflow, directly embedding workflow expressions into run scripts is a GitHub Actions injection anti-pattern. If the logic ever changes to use version-derived strings, it becomes an injection vector. Should use an env: variable instead:

Suggested change
- name: Publish to npm
run: |
echo "Publishing @emartech/react-native-emarsys-sdk to npm with tag ${{ steps.dist_tag.outputs.tag }}"
npm publish *.tgz --access public --tag ${{ steps.dist_tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }}
- name: Publish to npm
run: |
echo "Publishing @emartech/react-native-emarsys-sdk to npm with tag $DIST_TAG"
npm publish *.tgz --access public --tag "$DIST_TAG"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }}
DIST_TAG: ${{ steps.dist_tag.outputs.tag }}

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

id: dist_tag
run: |
VERSION=$(tar -xzO -f *.tgz package/package.json | node -pe "JSON.parse(require('fs').readFileSync(0)).version")
if [[ "$VERSION" == *-* ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic Error: The pre-release version detection only checks for a hyphen (*-*), which matches the SemVer pre-release convention (e.g. 2.0.0-beta.2). However, version strings like 2.0.0-0 (numeric-only pre-release) or build metadata variants such as 2.0.0+build.1 would be misclassified: the latter would be tagged latest despite not being a stable release. For the current naming scheme this works, but the check is worth tightening to explicitly match SemVer pre-release labels to avoid a mis-tagged publish in edge cases.

Suggested change
if [[ "$VERSION" == *-* ]]; then
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-.+ ]]; then

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Comment on lines +48 to +52
npm uninstall @emartech/react-native-emarsys-sdk

# install from generated artifact
TGZ_ABS=$(realpath ../../artifacts/*.tgz)
npm install "$TGZ_ABS"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Compared to the removed build-sample-apps.yml, the npm uninstall call here drops the --ignore-scripts flag that was present in the original. Running postinstall/preuninstall scripts during uninstall could fail or produce side effects in a CI context where the package was only installed as a dev dependency. The install step also drops --ignore-scripts from npm install "$TGZ_ABS". The original was intentional: autolinking must use the tarball but install scripts should not run during the swap. Should restore --ignore-scripts to match the prior behaviour.

Suggested change
npm uninstall @emartech/react-native-emarsys-sdk
# install from generated artifact
TGZ_ABS=$(realpath ../../artifacts/*.tgz)
npm install "$TGZ_ABS"
npm uninstall @emartech/react-native-emarsys-sdk --ignore-scripts
# install from generated artifact
TGZ_ABS=$(realpath ../../artifacts/*.tgz)
npm install "$TGZ_ABS" --ignore-scripts

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

@eduzatoni
eduzatoni merged commit c8da850 into New-Architecture-and-Expo Sep 10, 2026
3 checks passed
@eduzatoni
eduzatoni deleted the MV-1204 branch September 10, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants