Skip to content
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

cmd: version for old gits #1833

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/cut-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ jobs:
go: ${{ needs.config.outputs.build_go_version }}
- name: Create Release Archive
run: |
go mod vendor
# Fix the checkout action overwriting the tag: (see https://github.com/actions/checkout/issues/882)
git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
git archive --prefix '${{ needs.config.outputs.tar_prefix }}' -o clair.tar "${GITHUB_REF}"
go mod vendor
tar -rf clair.tar --transform 's,^,${{ needs.config.outputs.tar_prefix }},' vendor
gzip clair.tar
mv clair.tar.gz clair-${{ needs.config.outputs.version }}.tar.gz
Expand Down
6 changes: 4 additions & 2 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func init() {
"claircore_version": "",
"goversion": runtime.Version(),
"modified": "",
"revision": "",
"revision": revision,
"version": "",
}
info, infoOK := debug.ReadBuildInfo()
Expand Down Expand Up @@ -76,7 +76,9 @@ func init() {
switch {
case Version != "":
// Had our version injected at build: do nothing.
case len(describe) > 0 && describe[0] != '$':
case len(describe) > 0 && describe[0] != '$' && !strings.HasPrefix(describe, "%(describe:"):
// Some git versions apparently don't know about the describe format
// verb, so need to check that it's not just "%(describe..."
Version = describe
case revision[0] == '$':
Version = `(random source build)`
Expand Down
Loading