pmowrer / semantic-release-monorepo

Apply semantic-release's automatic publishing to a monorepo.
MIT License
510 stars 79 forks source link

semantic-release-monorepo is updateing the version of both apps when only one app was updated. #124

Closed IdecEddy closed 2 years ago

IdecEddy commented 2 years ago

Hello,

I am using terborepo to manage my monorepo. I made a change to a file in one of the packages in my monorepo ( app1-express ). When the semantic-release step ran in my GitLab CI/CD it released both apps and raised the version number in both of the apps. I ran yarn semantic-release in both app1-express and app2-nextjs directory.

Tree of my project's apps dir

.
├── app1-express
│   ├── CHANGELOG.md
│   ├── docker
│   ├── index.ts
│   ├── node_modules
│   ├── package.json
│   ├── tsconfig.json
│   └── yarn-error.log
└── app2-nextjs
    ├── CHANGELOG.md
    ├── README.md
    ├── components
    ├── context
    ├── data
    ├── docker
    ├── manifests
    ├── next-env.d.ts
    ├── next.config.js
    ├── node_modules
    ├── out
    ├── package-lock.json
    ├── package.json
    ├── pages
    ├── public
    ├── server
    ├── styles
    ├── tsconfig.json
    ├── yarn-error.log
    └── yarn.lock

what my releaserc.json

{
  "branches": [
      "release",
      "master"
  ],
  "tagFormat": "app2-express/v${version}",
  "extends": "semantic-release-monorepo",
  "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      [
          "@semantic-release/changelog",
          {
              "changelogFile": "CHANGELOG.md"
          }
      ],
      [
          "@semantic-release/npm",
          {
              "npmPublish": false
          }
      ],
      [
          "@semantic-release/git",
          {
              "assets": [
                  "package.json",
                  "CHANGELOG.md"
              ],
              "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
          }
      ],
      [
          "@semantic-release/gitlab",
          {
              "gitlabUrl": "https://gitlab.com",
              "assets": []
          }
      ],
      [
          "@semantic-release/exec",
          {
              "publishCmd": "docker build stuff and docker push stuff here. "
          }
      ]
  ]
}

Gitlab CICD config

publish:
  stage: release
  image: docker:latest
  cache:
    key: node_modules_nextjs
    paths:
      - apps/iqnox-nextjs/node_modules
      - apps/iqnox-express/node_modules
      - node_modules
    policy: pull
  services:
    - docker:dind
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - apk add git yarn --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
    - echo "unsafe-perm = true" >> ~/.npmrc
  script:
    - cd apps/app1-nextjs
    - yarn release
    - cd ../app2-express
    - yarn release 
  artifacts:
    reports:
      dotenv: apps/app1-nextjs/build.env
  only:
    refs:
      - master

yarn release looks like this in package.json script: "release": "yarn semantic-release"

I am not sure if semantic-release-monorepo would affect the "@semantic-release/npm", plugin that updates the package version. Can you provide any guidance on this topic?

IdecEddy commented 2 years ago

As an update, I looked though the log and found that the @semantic-release/commit-analyzer found that The commit should not trigger a release but it still did.

[9:16:47 PM] [semantic-release] › ℹ  Found 2 commits since last release
[9:16:47 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[9:16:47 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: fix(CICD): I want to test to make sure releases happen only on the app that is being updated.
[9:16:47 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The release type for the commit is patch
[9:16:47 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: chore(release): 1.0.4 [skip ci]
# [app1-express-v1.0.4](link) (2022-07-01)
### Bug Fixes
* **API:** I am taking out some unneeded text. ([ceb7476](link))
[9:16:47 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[9:16:47 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analysis of 2 commits complete: patch release
[9:16:47 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[9:16:47 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ℹ  The next release version is 1.1.8
[9:16:47 PM] [semantic-release] › ℹ  Start step "verifyRelease" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ✔  Completed step "verifyRelease" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ℹ  Start step "verifyRelease" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ✔  Completed step "verifyRelease" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[9:16:47 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[9:16:47 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/exec"
[9:16:47 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/changelog"
[9:16:47 PM] [semantic-release] [@semantic-release/changelog] › ℹ  Update /builds/project/sandbox/emundo/app1-nextjs/apps/app1-nextjs/CHANGELOG.md
[9:16:47 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/changelog"
[9:16:47 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/npm"
[9:16:47 PM] [semantic-release] [@semantic-release/npm] › ℹ  Write version 1.1.8 to package.json in /builds/app1/sandbox/emundo/app1-nextjs/apps/app1-nextjs
app1-website
v1.1.8

that and the exec step also runs when I don't think it should.

IdecEddy commented 2 years ago

Im just silly looks like I forgot to add "extends": "semantic-release-monorepo" to one of the app I was using as the ignore test. Remember to look over all your work friends.