anothrNick / github-tag-action

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

"v" prefix added when WITH_V is false #253

Closed skst closed 1 year ago

skst commented 1 year ago

This is a regression from 1.34.0. When WITH_V is set to false, the "v" should not be added to the version number in NEW_TAG.

image

Related to #116

sbe-arg commented 1 year ago

Its not a regression.

Its that the function that prints the tag output does not consider the V or non V if you run without dryrun it sets the version as desired with V or non V is just an echo that is the problem in the view.

sbe-arg commented 1 year ago

Can you share the non dryrun logs on with_v false? And the full log of the dry-run

There is missing important information in your screenshot specifically the outputs sets.

Although in the tests we should have a with_v false test for both pre and non pre release @sammcj

skst commented 1 year ago

Ah, I may have incorrectly attributed this to a regression when it may be because there was no version bump. I am not sure if this worked before. In any case, it seems to not work now--but perhaps that's intentional? In my case, the "no-v" tag has a 'v', (despite WITH_V=false), and I pass it to NSIS which fails. (I do a dry run first to get the no-v tag (for the version), and I run it again later to bump the version # and get the v-tag (for the label).)

run: makensis -DgVerInstaller=${{ needs.version.outputs.TagNoV }}.0 Timekeeper.nsi

image

This is the raw log. (I have no logs with DRY_RUN=true and WITH_V=false because I do the dry run to get the tag without a 'v' (for my installer) and an actual run to get the tag with a 'v' (for the label). If you really need that though, I can work something up.)

2023-04-03T14:22:18.3702308Z ##[group]Run anothrNick/github-tag-action@1.61.0
2023-04-03T14:22:18.3702573Z env:
2023-04-03T14:22:18.3702773Z   SOLUTION_FILE_PATH: .\Timekeeper.sln
2023-04-03T14:22:18.3703015Z   BUILD_CONFIGURATION: Release
2023-04-03T14:22:18.3703228Z   DRY_RUN: true
2023-04-03T14:22:18.3703411Z   DEFAULT_BUMP: none
2023-04-03T14:22:18.3703604Z   WITH_V: false
2023-04-03T14:22:18.3703783Z ##[endgroup]
2023-04-03T14:22:18.3941580Z ##[command]/usr/bin/docker run --name c0442a2cc9a958984440b9a653b6e011c2c86_73f016 --label 6c0442 --workdir /github/workspace --rm -e "SOLUTION_FILE_PATH" -e "BUILD_CONFIGURATION" -e "DRY_RUN" -e "DEFAULT_BUMP" -e "WITH_V" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/Timekeeper/Timekeeper":"/github/workspace" 6c0442:a2cc9a958984440b9a653b6e011c2c86
2023-04-03T14:22:18.6432679Z *** CONFIGURATION ***
2023-04-03T14:22:18.6437064Z    DEFAULT_BUMP: none
2023-04-03T14:22:18.6437356Z    DEFAULT_BRANCH: 
2023-04-03T14:22:18.6437628Z    WITH_V: false
2023-04-03T14:22:18.6437924Z    RELEASE_BRANCHES: master,main
2023-04-03T14:22:18.6438210Z    CUSTOM_TAG: 
2023-04-03T14:22:18.6438471Z    SOURCE: .
2023-04-03T14:22:18.6438726Z    DRY_RUN: true
2023-04-03T14:22:18.6439002Z    INITIAL_VERSION: 0.0.0
2023-04-03T14:22:18.6439278Z    TAG_CONTEXT: repo
2023-04-03T14:22:18.6439555Z    PRERELEASE: false
2023-04-03T14:22:18.6439834Z    PRERELEASE_SUFFIX: beta
2023-04-03T14:22:18.6440111Z    VERBOSE: false
2023-04-03T14:22:18.6440391Z    MAJOR_STRING_TOKEN: #major
2023-04-03T14:22:18.6440686Z    MINOR_STRING_TOKEN: #minor
2023-04-03T14:22:18.6440974Z    PATCH_STRING_TOKEN: #patch
2023-04-03T14:22:18.6441262Z    NONE_STRING_TOKEN: #none
2023-04-03T14:22:18.6441554Z    BRANCH_HISTORY: compare
2023-04-03T14:22:18.6492943Z pre_release = false
2023-04-03T14:22:19.5650390Z From https://github.com/skst/Timekeeper
2023-04-03T14:22:19.5650936Z  * [new branch]      master     -> origin/master
2023-04-03T14:22:19.5655239Z  * [new tag]         v1.62.4    -> v1.62.4
2023-04-03T14:22:19.5659852Z  * [new tag]         v1.62.5    -> v1.62.5
2023-04-03T14:22:19.5664441Z  * [new tag]         v1.62.6    -> v1.62.6
2023-04-03T14:22:19.5668686Z  * [new tag]         v1.62.7    -> v1.62.7
2023-04-03T14:22:19.5821718Z History:
2023-04-03T14:22:19.5822043Z ---
2023-04-03T14:22:19.5822353Z Bump microsoft/setup-msbuild from 1.1 to 1.3
2023-04-03T14:22:19.5822521Z 
2023-04-03T14:22:19.5822814Z Bumps [microsoft/setup-msbuild](https://github.com/microsoft/setup-msbuild) from 1.1 to 1.3.
2023-04-03T14:22:19.5823265Z - [Release notes](https://github.com/microsoft/setup-msbuild/releases)
2023-04-03T14:22:19.5823737Z - [Changelog](https://github.com/microsoft/setup-msbuild/blob/main/building-release.md)
2023-04-03T14:22:19.5824204Z - [Commits](https://github.com/microsoft/setup-msbuild/compare/v1.1...v1.3)
2023-04-03T14:22:19.5824411Z 
2023-04-03T14:22:19.5824728Z ---
2023-04-03T14:22:19.5824965Z updated-dependencies:
2023-04-03T14:22:19.5825267Z - dependency-name: microsoft/setup-msbuild
2023-04-03T14:22:19.5825582Z   dependency-type: direct:production
2023-04-03T14:22:19.5825892Z   update-type: version-update:semver-minor
2023-04-03T14:22:19.5826265Z ...
2023-04-03T14:22:19.5826366Z 
2023-04-03T14:22:19.5826560Z Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03T14:22:19.5826803Z ---
2023-04-03T14:22:19.5828428Z Default bump was set to none. Skipping...
2023-04-03T14:22:19.7087611Z Post job cleanup.
2023-04-03T14:22:19.8509239Z [command]/usr/bin/git version
2023-04-03T14:22:19.8567887Z git version 2.40.0
2023-04-03T14:22:19.8631524Z Temporarily overriding HOME='/home/runner/work/_temp/8a3cec29-fa55-4d67-851d-366cdc121c92' before making global git config changes
2023-04-03T14:22:19.8636453Z Adding repository directory to the temporary git global config as a safe directory
2023-04-03T14:22:19.8645247Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/Timekeeper/Timekeeper
2023-04-03T14:22:19.8699537Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2023-04-03T14:22:19.8743214Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2023-04-03T14:22:19.8981215Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2023-04-03T14:22:19.8999557Z http.https://github.com/.extraheader
2023-04-03T14:22:19.9018659Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2023-04-03T14:22:19.9061215Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2023-04-03T14:22:19.9501152Z Evaluate and set job outputs
2023-04-03T14:22:19.9515175Z Set output 'TagNoV'
2023-04-03T14:22:19.9516532Z Cleaning up orphan processes
sbe-arg commented 1 year ago

The problem is you are combining the follwing I think

Dryrun with default bump none and withv false if default bump is none the actions exists before with v considerations leading to a with_v true at that stage.

Default bump none without a hastag in the commit defaults to no bump and will print the version with V.

Thats probably the "bug" in this atypical use case where is printing the v when there is no real bump to be made.

Around lines 157 of the entrypoint.sh

sbe-arg commented 1 year ago

For start we need a better test case for bump none combined to dryrun and need to get a computer to do some digging will try to get you some details in about a week or so.

Thanks for your patience.

sbe-arg commented 1 year ago

Have a look here https://github.com/anothrNick/github-tag-action/actions/runs/4653819164/jobs/8235016963 when you run

          DRY_RUN: true
          WITH_V: false
          DEFAULT_BUMP: none
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

You get no bump and the only valid output is new_tag wich should be exactly what you already had as latest tag in your repo/branch scope

we do setOutput "new_tag" "$new"

then we do git tag "$new"

$new is successfully following v or without v based on true/false set.

I'm not sure how in your use case is creating withV when you specify false.

I reckon there is some other problem in your workflow specially where u capture the output of a dryrun to use it as source for a bump. If you already have a v1.x.x and you run default bump: none and there is no bump it won't take out the v of the existing tag is not a conversion from v to no v feature in no bump. The action allows to set the v or no v change only during bumps. @sammcj @skst I hope this is clear.

Is confusing what type of bump strategy are you following. If u want to bump based on a file you can something like this having a VERSION file in your repo

      - name: version
        id: version
        run: |
          VERSION_FILE="VERSION"
          echo "version=$(cat $VERSION_FILE)" >> "${GITHUB_OUTPUT}"

      - name: automatic-tag
        id: tag
        uses: anothrNick/github-tag-action@1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CUSTOM_TAG: ${{ steps.version.outputs.version }}

Please share more details of thew type of bump strategy you are trying to achieve in this workflow

sbe-arg commented 1 year ago

Closing as the action is not meant to convert a tag from containing V to no_V without a bump in semver math.

skst commented 1 year ago

I will attempt to explain my workflow, but it might not be useful since the issue is closed.

In this particular case, I re-ran a failed workflow. I did not want to bump the version since I had not yet built a release with this version. As mentioned earlier, the workflow first uses a dry-run to get the version without a 'v' so that it can build the installer. It then runs later with 'v' so that it can tag the release.

So, the "no-v dry-run" is the first time the github-tag-action has run in this workflow--the workflow is not attempting to "remove" an existing 'v' from a tag. (Regardless, it seems that if WITH_V is false, it should emit a tag without the 'v', or am I missing something?)

sbe-arg commented 1 year ago

Check the latest tests of this repo try to replicate the tests fit to your dry run branch in your project and let me know here if we identify any issues we can reopen but so far I don't see how you get a vX with with-v set to false when the tests don't show that behaviour.

As I mentioned default bump none will no do anything will just print the previous latest tag found by the regex whatevet it is if it has v or not it will print that as new_tag

Don't get me wrong I'll help you but the use of dry run with bump none is useless without a #commit message target.

Try to add more detail to prove your case.

skst commented 1 year ago

Perhaps I misunderstand how to use GitHub actions. If I push some changes with a #bump in the commit message, and the build fails, I would like to re-run the failed jobs without bumping the version again.

If that is not a supported scenario, I can use bluwy/substitute-string-action to strip the 'v' from the returned tag.

Ideally--in my opinion--github-tag-action would always emit a second value without the 'v', such as new_version, in addition to new_tag which would avoid having to run it a second time with DRY_RUN=true.

sbe-arg commented 1 year ago

Maybe don't run everything in a single workflow so this way you can have a strong version release that is detached from building/rebuilding artifacts.

Maybe those artifacts can be build from the tag version created.

Then once artifacts are successfully and only then you auto create a release with the built packages.

This way allows u to rerun independent workflows or run from dispatch instead of on triggers.

I understand that builds can fail. If tests succeed builds should succeed else you have a test problem.

Once test pass and you merge you make a tag and then build then release but in separated workflows triggered by condition dispatches also all workflows with manual dispatch as backfall.

But each workflow can be as magical as you want thats the awesomeness of github actions.