-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
How to rebuild past tagged builds as public releases? / Add BuildingRef override #873
Comments
Thanks for this excellent write-up. To get you unblocked, I want to first offer you the available workaround: Set Now as to your suggestions... I take it GitHub doesn't set any environment variable with the name of the tag or branch that was checked out when you override the default commit to checkout. Is that correct? If no env var exists, allowing the user to set one manually makes sense IMO. I like the |
Thanks for providing the unblocker and reacting so fast!
If I understand it correctly, every workflow run has a commit it belongs to. See here, the - uses: actions/checkout@v3
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
ref: ${{ inputs.build-ref }} What is checked out is then in no way related to the commit the current workflow run is assigned to. Still every workflow is always assigned to a commit and that assignment is available in My idea was to provide a - uses: actions/checkout@v3
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
ref: ${{ inputs.build-ref }}
- uses: dotnet/nbgv@v0.4
id: nbgv
with:
buildingRef: ${{ inputs.build-ref }} |
Your proposal would require adding an input to the |
You are right, of course. I've been experimenting so much with the GitHub Action that I've lost sight of that. Yes, adding the option explicitly to the nbgv action to pass it on to Nerdbank.GitVersioning doesn't give too tangible an advantage. I thought some more about my two original ideas. Adding a On the other hand, if I had to choose one option I'd probably take extending
|
Also interesting: If a tag is checked out, using managed git the $Env:NBGV_GitEngine = "LibGit2"
nbgv get-version -f json |
My use case: I have a GitHub Actions cron job that checks if my docker base images have updated. If they have, it checks out the latest release tag according to GitHub Releases and rebuilds my Docker images.
My
version.json
looks like this:As I'm checking out a different commit than the one chosen by GitHub (which defaults to the newest commit on the default branch for a cron job), the information in
GITHUB_REF
is stale. Now, I've seen #795 and adapted my workflow config accordingly:(Assume a tag e.g.
v0.7.3
asinputs.build-ref
)As expected, the resulting
BuildingRef
does not point to the stale information fromGITHUB_REF
anymore, which is great.However, nbgv also tells that I'm not building a public release now. I am, however, at a commit that is part of a
release/v0.7
branch and also at the commit wherev0.7.3
points. This is easy to reproduce locally:git checkout refs/tags/v0.7.3
results in a detached head state. Executingnbgv get-version -f json
afterwards also shows a non-public release. Now I think it might make sense for detached heads to assume they are non-public. Also, looking at what I believe is the relevant code, this makes sense.To summarize, my intention is to build from a tagged past commit again in exactly the same way as when the tag was created. GitHub Actions does not allow changing the
GITHUB_REF
, so changing the environment accordingly is not possible.Options that came to my mind:
BuildingRef
override by env variablethis.BuildingRef = buildingRefOverrideFromEnv ?? cloudBuild?.BuildingTag ?? cloudBuild?.BuildingBranch ?? context.HeadCanonicalName;
git tag --points-at HEAD
toGitRepository.GetHeadAsReferenceOrSha()
Is there any smarter way around this? What do you think?
Complete example workflow runs:
The text was updated successfully, but these errors were encountered: