-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Preserve tag annotations #290
Comments
Agreed! This breaks the "git describe" command too. We need tags to be in their correct original form. |
I realize now that this is complicated by a desire to checkout the specific code identified by the hash when the tag has been re-applied on the repository. I would be happy to have an option that would cause the checkout to fail if the hash didn't match. For example:
|
@martinthomson does the input |
I didn't try 0, but I tried "fetch-depth: 2000" at one point. It fetched the other tags in that history correctly, but if the thing that triggered the workflow was itself an annotated tag, that one tag will still be converted from an annotated tag into a lightweight tag. |
|
It does not solve the issue, I ran into this today. Looks like the action is not using the tag itself, just the commit the tag points to. |
|
@andreineculau sadly does not. |
+1 on preserving tag annotations. name: Create release from annotated tag
on: push
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Doesn't help
- name: "Extract data from tag: version, message, body"
id: tag
run: |
git fetch --tags --force # Retrieve annotated tags. THIS TRICK REALLY HELPS
echo ::set-output name=subject::$(git for-each-ref $GITHUB_REF --format='%(contents:subject)')
# …
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ steps.tag.outputs.subject }} |
That's the same workaround I originally suggested, just more broadly targets (all tags, not just one). As you say The main problem is that the code fetches using a hash and then re-applies its own tag if the build was initiated as a result of applying a tag. That's also why you need to add |
Also seeing that |
I only needed to |
This bit me as well. We use annotated tags in our build/release process and this was a little tough to track down. Another confirmation that |
Same here, exact same scenario as chrislambe described. I can also confirm that |
You can also just revert to checkout@v1 it does not really have any downsides |
Thanks for the suggestion, I can confirm that works fine as well. Though, I would argue that it has the downside of probably receiving support for less amount of time. On the other hand, I don't see any downsides to using |
The downside is that if the tag has moved then it will no longer be attached to the commit that you have checked out. For that, my personal preference is for the situation to be detected and the build aborted. It shouldn't happen very often. |
* ensure to fetch tag information (see issue [#290]) [#290]: actions/checkout#290
* ensure to fetch tag information (see issue [#290]) [#290]: actions/checkout#290
* ensure to fetch tag information (see issue [#290]) [#290]: actions/checkout#290
V2 handles tags incorrectly (actions/checkout#290) and the easiest solution is to simply switch to v1.
The checkout action does not work with annotated tags. See actions/checkout#290.
…ated tag Upgrade to actions/checkout@v4.1.1 and Fix actions/checkout messing up checkouts of annotated tags; actions/checkout#290 Also fetch submodule upfront. Signed-off-by: Tim Janik <timj@gnu.org>
* branch-check: GITHUB: workflows/testing.yml: update to actions/upload-artifact@v4 GITHUB: workflows/testing.yml: only build & upload docs from tim-janik/anklang GITHUB: workflows/testing.yml: update to actions/cache@v4 GITHUB: workflows/testing.yml: use actions/checkout@v4.1.1, fix annotated tag Upgrade to actions/checkout@v4.1.1 and Fix actions/checkout messing up checkouts of annotated tags; actions/checkout#290 Also fetch submodule upfront. GITHUB: workflows/testing.yml: remove Release-Upload run MISC: Makefile.mk: fix script v2.34 invocation The util script from util-linux 2.34 (focal) has no `-O` option. GITHUB: workflows/testing.yml: add `make branch-check` and check errors in PRs MISC: Makefile.mk: add branch-check rule, $BRANCH_CHECK_EXIT holds error status GITHUB: workflows/testing.yml: disable CI on tag pushes MISC: mknews.sh: show git command line MISC: Makefile.mk: fix missing CLEANDIRS Signed-off-by: Tim Janik <timj@gnu.org>
This reverts commit 083ace1. The intention was to allow tagging a release and then `git describe` would pick up the new tag name, but unfortunately that doesn't work: actions/checkout#290 Instead re-running a trunk build is the only way. So, there's no point letting tags trigger builds.
I got bitten by this yesterday. The solution offered in #1506 looks like a good compromise to me. I hope that'll be merged eventually. |
My release attempt in WebAssembly#408 did not go well because the release artifacts were not named correctly. This fixes an issue described by actions/checkout#290 where checkouts of annotated tags overwrite the annotation which breaks `git describe`. That means that version detection is broken in CI during releases which causes artifacts to have the wrong information. This applies the workaround described in that issue to `git fetch --tags --force` after the checkout step to undo the overwrite done in the checkout step.
My release attempt in #408 did not go well because the release artifacts were not named correctly. This fixes an issue described by actions/checkout#290 where checkouts of annotated tags overwrite the annotation which breaks `git describe`. That means that version detection is broken in CI during releases which causes artifacts to have the wrong information. This applies the workaround described in that issue to `git fetch --tags --force` after the checkout step to undo the overwrite done in the checkout step.
In commit df6e49c of PR git-lfs#5243 we added a step to all of the jobs in our CI and release GitHub Actions workflows to work around the problem described in actions/checkout#290 and actions/checkout#882. This step, which only executes if the job is running due to the push of a new tag, performs a "git fetch" command of the tag's reference to ensure that the local copy is identical to the remote one and has not been converted from an annotated tag into a lightweight one. Starting with v2 of the actions/checkout action, annotated tags are by default replaced with lightweight ones, which then causes any subsequent "git describe" commands to return an incorrect value. Since we depend on the output of "git describe" in several places in our workflows to generate the appropriate version name for our release artifacts, we need to ensure we have the full annotated tag for the current reference rather than a lightweight one. Recently, in commit 9c3fab1 of PR git-lfs#5930, we strengthened the security of our GitHub Action workflows by setting the "persist-credentials" option of the actions/checkout action to "false", so that any cached Git credentials are removed at the end of that step. While this causes no problems when our CI workflow runs after a branch is pushed, as is the case for new PRs, when we push a new tag the "git fetch" step now fails as it depends on the cached Git credentials from the actions/checkout step. We could use the GITHUB_TOKEN Action secret to temporarily set an appropriate HTTP Authorization header to make the "git fetch" command succeed. However, a more straightforward solution exists whereby we specify explicitly the reference we want to check out using the "ref" option of the actions/checkout action. This causes the action to fetch the reference such that if the reference is an annotated tag, it remains one and is not converted into a lightweight one. For reference, see: actions/checkout#882 (comment) actions/runner-images#1717 (comment) h/t classabbyamp and xenoterracide for documenting this workaround
actions/checkout is broken and 'fetch-tags: true' does not help to fetch tag objects: actions/checkout#290 So work around it by fetching tags manually.
Since actions/checkout is broken (see actions/checkout#290), we need to manually fetch tag objects to check for signatures.
Until a proper fix is released, I believe this will be helpful to to share this trick to community. Bug: actions#290 Relate-to: actions#1506 Relate-to: actions#649 Origin: https://github.com/actions/checkout/pulls?q=author%3Arzr Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
Until a proper fix is released, I believe this will be helpful to to share this trick to community. Bug: actions#290 Relate-to: actions#1506 Relate-to: actions#649 Origin: actions#2081 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
Until a proper fix is released, I believe this will be helpful to share this trick to community. Bug: actions#290 Relate-to: actions#1506 Relate-to: actions#649 Origin: actions#2081 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
The technique this tool uses for checking out tags only preserves the relation between tag and ref, not any annotations created with
git tag -a
.I have a CI action that depends on information from annotated tags. Specifically, the name of the person who applied the tag:
git tag --list --points-at HEAD --format '%(taggeremail)'
(I can't use${{ github.actor }}
for reasons).The workaround is to run
git fetch -f origin ${{ github.ref }}:${{ github.ref }}
. But it would be better not to need this workaround.The text was updated successfully, but these errors were encountered: