intuit / auto

Generate releases based on semantic version labels on pull requests.
https://intuit.github.io/auto/
MIT License
2.28k stars 204 forks source link

`auto version` not returning a value #1367

Open RichieRunner opened 4 years ago

RichieRunner commented 4 years ago

I have 2 released PRs that I'm expecting to be attached to the same version and github release:

When I ran auto version to bump the version (to minor), auto version did not return any value. It was blank in both local and CI environment (AWS Codebuild). I'm suspecting it could have something to do with that first PR that was not labeled?

What should I do to combine multiple PRs to one release?

hipstersmoothie commented 4 years ago

auto version will calculate the version using all the commits since the last Latest Release. So if there has been multiple PRs in that time they will all be used to calculate the version.

auto version will return nothing if either:

  1. a skip-release label is present
  2. or you're only releasing with the release label and it is not present.

Try running auto version -vv and posting the result here

RichieRunner commented 4 years ago

image

image

image

I was missing a label ('released'). Re-ran the build, and problem still persists.

hipstersmoothie commented 4 years ago

Is that a log from shipit I have a feeling this is because you aren't using the npm plugin and as a result I don't think you are properly tagging the release.

when the release portion of shipit runs it expects there to a be a new tag at the head or for the version to have incrementedf.

So for example: if the last tag in your branch is 2.1.0 it will try to create a release for that tag. Since that version already has a release nothing happens.

Could you share your autorc? I can't really think of anything that would make that plugin not work other than a configuration error

RichieRunner commented 4 years ago

my .autorc file:

{
  "owner": "xxx",
  "repo": "xxx",
  "name": "xxx",
  "email": "xxx",
  "githubApi": "https://xxx.xxx.com/api/v3",
  "githubGraphqlApi": "https://xxx.xxx.com/api",
  "plugins": ["released"]
}

my custom CI script to do releasing:

version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 10

    commands:
      - apt-get update
      - apt-get install -y jq
      - echo Build enviromment `uname -a` `aws --version 2>&1` node/`node --version` npm/`npm --version`
      - echo $(env)

  pre_build:
    commands:
      #######################################################################
      - echo **** Running Prebuild ****
      #######################################################################
      - cd ${CODEBUILD_SRC_DIR}/
      - npm ci
      - cd ${CODEBUILD_SRC_DIR}/
      - npm install -g auto

      - git remote set-url origin https://xxx
      - git checkout master
      - git config --global user.email "xxx"
      - git config --global user.name "xxx"

      - auto version
      - VERSION=`auto version`
      - echo $VERSION

      - npm version ${VERSION} -m "Bump version"

      - git push --verbose --follow-tags --set-upstream origin master
      - auto release -v
hipstersmoothie commented 4 years ago

As I said in the other issue you gotta do this. All the repos you link do this

{
 // wrong
 "plugins": ["released"],
 // correct
 "plugins": ["npm", "released"],
}
RichieRunner commented 4 years ago

Is that a log from shipit I have a feeling this is because you aren't using the npm plugin and as a result I don't think you are properly tagging the release.

when the release portion of shipit runs it expects there to a be a new tag at the head or for the version to have incrementedf.

So for example: if the last tag in your branch is 2.1.0 it will try to create a release for that tag. Since that version already has a release nothing happens.

Could you share your autorc? I can't really think of anything that would make that plugin not work other than a configuration error

I am not explicitly running git tag or anything similar anywhere. I assume this is the responsibility of auto

hipstersmoothie commented 4 years ago

Only the shipit command will do that. since you switched to the manual setup you would need to run npm publish as well.

But I think if you switch to shipit with the correct plugin config it will work.

  1. fix including npm plugin in autorc
  2. replace all auto script lines with auto shipit
RichieRunner commented 4 years ago

Only the shipit command will do that. since you switched to the manual setup you would need to run npm publish as well.

But I think if you switch to shipit with the correct plugin config it will work.

  1. fix including npm plugin in autorc
  2. replace all auto script lines with auto shipit

Thanks, that solved my new problem! But now we're back to my original question, is how do I combine multiple PRs into one release:

I expected the release 2.2.3 to have collected both PRs 40 and 41, but 40 is missing. I thought it should have been assumed to be a patch?

image

image

hipstersmoothie commented 4 years ago

40 def should have been included. that might be a bug. but I do this all the time and it should've worked

hipstersmoothie commented 4 years ago

I'm testing on one of my test repos. just did the same thing you did https://circleci.com/gh/hipstersmoothie/auto-single-package/173?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

hipstersmoothie commented 4 years ago

https://github.com/hipstersmoothie/auto-single-package/releases/tag/v0.0.23-next.0

RichieRunner commented 4 years ago

I tried a few more things:

I noticed that you also run individual Release pipeline for your feature branches once they get merged it. auto shipit is also raun on those branches? I only run auto shipit on my main master branch. Does that make a difference? image

hipstersmoothie commented 4 years ago

That will release a “canary” version of the code people can install to test the pr. This shouldn’t effect the latest release when ran from master.

hipstersmoothie commented 4 years ago

You can see that here https://github.com/hipstersmoothie/auto-single-package/pull/28

hipstersmoothie commented 4 years ago

You might be running into this issue https://intuit.github.io/auto/docs/welcome/quick-merge. But the window for it to happen should be very short, the timing would have to be almost perfect.

I feel like I haven't really answered you question.

Q: What are the ways to release multiple commits in a release?

A: There are two ways

  1. use the skip-release label on a PR. that PR should still be included in the next release. but when merged will not generate a release
  2. use this config option and only generate a release when a release label is attached. you still add semver patches as you go.

Since this is on a GitHub instance I can't see it's gonna be hard to debug further. I would be open to doing a zoom call to see what's up if the problem persists

RichieRunner commented 4 years ago

@hipstersmoothie I've replicated the issue on a public repo here: https://github.com/RichieRunner/node-test/releases I don't use CircleCI, so you'll have to create a CircleCI build to test. (I'm beginning to suspect that the crux of all my issues is really from using AWS Codebuild and not CircleCI like most repos that are using auto).

hipstersmoothie commented 4 years ago

I've never personally build on codebuild. auto is also on travis, jenkins, and github actions too.

I'll take a look at this today!

hipstersmoothie commented 4 years ago

Pulling the project locally I was able to create the right changelog.

  1. HEAD set at latest master
  2. yarn auto changelog --from v1.0.1 -d
 #### 🚀 Enhancement

- Update README.md [#5](https://github.com/RichieRunner/node-test/pull/5) ([@RichieRunner](https://github.com/RichieRunner))

#### 🐛 Bug Fix

- Update index.js [#6](https://github.com/RichieRunner/node-test/pull/6) ([@RichieRunner](https://github.com/RichieRunner))

#### ⚠️ Pushed to `master`

- Update package.json ([@RichieRunner](https://github.com/RichieRunner))

#### Authors: 1

- Richie ([@RichieRunner](https://github.com/RichieRunner))

So i'm leaning towards this being an AWS codebuild issue. I've never used that platform before. Any chance you could get this project running on that and give me access? And if not just provide me the full output log when ran with -vv. Without the full log I can't really debug this

loreina commented 4 years ago

Is there an update on this? publishing to GPR using a Github Action workflow doesn't seem to work for me, and I think it might be due to auto version not returning a value, so version isn't bumped in package.json or package-lock.json.

this is my release.yml:

name: release

on:
  push:
    branches:
      - master

jobs:
  release:
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
    steps:
      - uses: actions/checkout@v2

      - name: Prepare repository
        run: git fetch --unshallow --tags

      - name: Use Node.js 12.x
        uses: actions/setup-node@v1
        with:
          node-version: 12.x

      - name: Cache node modules
        uses: actions/cache@v2
        with:
          path: node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Install dependencies
        run: npm ci

      - name: Create release
        run: npx auto shipit -m "release [skip ci]"
        env:
          GH_TOKEN: ${{ secrets.REPO_SCOPE_TOKEN }}

      - name: Bump version
        run: npm version `auto version`
        env:
          GH_TOKEN: ${{ secrets.REPO_SCOPE_TOKEN }}
jscheel commented 4 years ago

I've run into this as well. All of the sudden, I can't get a release to go out. The changelog is generated properly, the PR has the release and patch labels on it, but it doesn't actually bump the version so it won't make a release. version returns patch.

hipstersmoothie commented 4 years ago

@jscheel Could link me to the CI job or post a log with -vv turned on?

jscheel commented 4 years ago

I am running it on metal, not in a CI job. I’m out of town for the weekend, but I can can post on Monday. It actually worked fine when I used shipit, which I’ve never used before.

On Thu, Nov 12, 2020 at 4:14 PM Andrew Lisowski notifications@github.com wrote:

@jscheel https://github.com/jscheel Could link me to the CI job or post a log with -vv turned on?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/intuit/auto/issues/1367#issuecomment-726345964, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABTUFTTOR2DCRTK6E76YFDSPRF4VANCNFSM4OW5Z3XQ .