anothrNick / github-tag-action

A Github Action to tag a repo on merge.
MIT License
760 stars 378 forks source link

pre-release sufix bump not working #290

Open gabriel-amyot opened 10 months ago

gabriel-amyot commented 10 months ago

I am not able to publish a second Tag within a PR. It triggers a conflict. The documentation leads to thing that the pre-release sufix is incremented, but it is not in my case.

Is this a bug, or a misconfigured the action?

Output

*** CONFIGURATION ***
    DEFAULT_BUMP: patch
    DEFAULT_BRANCH: master
    WITH_V: false
    RELEASE_BRANCHES: master,main
    CUSTOM_TAG: 
    SOURCE: .
    DRY_RUN: false
    INITIAL_VERSION: 0.0.0
    TAG_CONTEXT: repo
    PRERELEASE: true
    PRERELEASE_SUFFIX: pr_9
    VERBOSE: false
    MAJOR_STRING_TOKEN: #major
    MINOR_STRING_TOKEN: #minor
    PATCH_STRING_TOKEN: #patch
    NONE_STRING_TOKEN: #none
    BRANCH_HISTORY: last
pre_release = true
fatal: ambiguous argument 'master..HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
History:
---
Merge 09b561adcb8267e7a6[11](https://github.com/gabriel-amyot/github-action-maven-example-start/actions/runs/6804158532/job/18501052012#step:4:12)0d2a6374b849635e96bb into 9fcac0e98c9650c9ecade0c5b94a2c59d64a5388
---
fatal: ambiguous argument '': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Setting pr_9 pre-tag  - With pre-tag 0.1.2-pr_9.0
fatal: tag '0.1.2-pr_9.0' already exists

Action

name: Bump version
on:
  pull_request:
    branches: [ master ]
jobs:
  build:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.merge_commit_sha }}
          fetch-depth: '0'

      - name: Bump version and push tag
        uses: anothrNick/github-tag-action@1.64.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          WITH_V: false
          PRERELEASE: true
          PRERELEASE_SUFFIX: pr_${{ github.event.number }}
          DEFAULT_BUMP: patch
          BRANCH_HISTORY: last

First PR commit tags correctly, but when I merge a second commit on the PR it fails [0.2.0-pr_8.0] [0.1.0] [0.1.0-PR_7.0] [0.0.1]

gabriel-amyot commented 10 months ago

I found a work arround by dynamicaly setting a different suffix each time, but the number at the end of the suffix stays at 0

name: Bump version
on:
  pull_request:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    permissions: write-all

    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.merge_commit_sha }}
          fetch-depth: '0'

      - name: Bump version and push tag
        uses: anothrNick/github-tag-action@1.67.0 #https://github.com/anothrNick/github-tag-action
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          WITH_V: false
          PRERELEASE: true
          PRERELEASE_SUFFIX: pr-${{ github.event.number }}_${{ github.run_id }}_${{ github.run_number }}
          DEFAULT_BUMP: patch

image

sbe-arg commented 10 months ago

Does seem like a bug. I remember the suffix .X in pre-tags being bumped in earlier versions.

gabriel-amyot commented 10 months ago

Thanks for the response @sbe-arg ,

I think I've figured out the issue image

I highly suspect that the problem happens when I use a mutable PRERELEASE_SUFFIX like i was doing previously
something like:

  PRERELEASE_SUFFIX: pr-${{ github.event.number }}

I would assume that the problem happens here when we try to match the pre_tag.

I could try fixing this myself, but I am not sure how to "compile and publish" a github action in order to test my hypothesis.

sbe-arg commented 10 months ago

If you fork edit and point testing to your fork master or branch is the easier way to develop.

Ill review the pr.

It seems you are ontrack