Skip to content
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

[rush] publishFolder doesn't work as expected #4754

Open
jaasum-msft opened this issue May 30, 2024 · 2 comments
Open

[rush] publishFolder doesn't work as expected #4754

jaasum-msft opened this issue May 30, 2024 · 2 comments

Comments

@jaasum-msft
Copy link

Summary

I'm aiming to include an Angular library in my monorepo which consumes an output from another project; StencilJS using the Angular framework integration.

My directory structure:

  • project-angular (not published, but builds the final angular-component-library package)
    • angular-component-library (published, from dist directory output by project-angular's build script)
  • project-stencil (main source, outputs artifacts into angular-component-library via its build script)

The angular-component-library and project-stencil are in a lockstep version policy:

  {
    "definitionName": "lockStepVersion",
    "mainProject": "project-stencil",
    "policyName": "project",
    "version": "1.0.0"
  }

My rush projects in rush.json:

"projects": [
    {
      "packageName": "project-stencil",
      "projectFolder": "libraries/project-stencil",
      "versionPolicyName": "project"
    },
    {
      "packageName": "project-angular",
      "projectFolder": "libraries/project-angular",
      "shouldPublish": false
    },
    {
      "packageName": "project-library",
      "projectFolder": "libraries/project-angular/projects/component-library",
      "publishFolder": "dist",
      "versionPolicyName": "project"
    }
]

The action I'm performing where I run into trouble is that rush publish doesn't work as expected and I believe the publishFolder argument is the culprit. I would assume that my CI/CD pipeline would:

  1. Install rush
  2. Build (so I get the compiled output for angular-component-library in it's dist directory via project-angular)
  3. Publish, which would process my change files, bump version numbers in all package.json files, commit changes, and publish to NPM

What went wrong is when running rush build before rush publish the package.json in the publishFolder version is not bumped, which leads to an attempt to publish the previous version.

Ultimately, my CI/CD pipeline looks like this:

rush install
rush build
rush publish --apply --target-branch main
rush build
rush publish --publish --include-all --version-policy siftDesignSystem

What I'd expect to work is:

rush install
rush build
rush publish --apply --publish --include-all --version-policy siftDesignSystem

I can't use rush version --bump before rush build and rush publish because it requires nextBump to be explicitly stated in the version policy and bypasses the definitions in the change files. Without nextBump in my version policy Rush will produce an invalid version error. If I attempt to use rush publish --apply before building Rush will fail (cannot find package-name), because the package is not found in the yet-to-be-compiled publishFolder.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.120.6
rushVersion from rush.json? 5.120.6
useWorkspaces from rush.json? No, but true in pnpm-config.json
Operating system? Windows WSL, Linux
Would you consider contributing a PR? No
Node.js version (node -v)? v20.12.0
@iclanton
Copy link
Member

iclanton commented Jun 3, 2024

I can't use rush version --bump before rush build and rush publish because it requires nextBump to be explicitly stated in the version policy and bypasses the definitions in the change files.

rush version doesn't care whether the repo has been built or not, so it should apply your changefiles regardless. Are you generating changefiles during your build?

@jaasum-msft
Copy link
Author

jaasum-msft commented Jun 4, 2024

I can't use rush version --bump before rush build and rush publish because it requires nextBump to be explicitly stated in the version policy and bypasses the definitions in the change files.

rush version doesn't care whether the repo has been built or not, so it should apply your changefiles regardless. Are you generating changefiles during your build?

rush version is processing the changefiles and they are generated prior. If I have two changefiles where one is marked patch and the other marked minor I'd expect rush version --bump to generate the changelog and bump the version numbers for all my project's package.json to a minor release. However, it will error and say Invalid version number vX.X.X in project-name unless I explicitly write nextBump as stated above, which overrides anything found in the changefiles.

I've tried to use rush publish --apply as another way to "bump" the version number and generate the changelog before publishing, but it will error as there is no package.json found in the publishFolder argument.

Tricky to explain, but basically I have no valid option within Rush and my current setup to:

  1. Build my files
  2. Bump the version number in all my packages and commit to git, including bumping package.json in the git-ignored "publishFolder" directories

The only way I've managed to get it to work is with two explicit build steps. I'd assume if rush publish also looked at the package.json in the publishFolder and bumped it before publishing it would work as expected. Not sure why it doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Waiting for Author
Development

No branches or pull requests

2 participants