Skip to content

Commit 8231b43

Browse files
committed
cmd: version for old gits
This also adds a workaround for actions/checkout#882 where the new tag get blasted away with a new, lightweight tag for the duration of the run. Signed-off-by: Hank Donnay <hdonnay@redhat.com>
1 parent 1bfbfa1 commit 8231b43

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.github/workflows/cut-release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ jobs:
5757
go: ${{ needs.config.outputs.build_go_version }}
5858
- name: Create Release Archive
5959
run: |
60-
go mod vendor
60+
# Fix the checkout action overwriting the tag: (see https://github.com/actions/checkout/issues/882)
61+
git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
6162
git archive --prefix '${{ needs.config.outputs.tar_prefix }}' -o clair.tar "${GITHUB_REF}"
63+
go mod vendor
6264
tar -rf clair.tar --transform 's,^,${{ needs.config.outputs.tar_prefix }},' vendor
6365
gzip clair.tar
6466
mv clair.tar.gz clair-${{ needs.config.outputs.version }}.tar.gz

cmd/build.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func init() {
3939
"claircore_version": "",
4040
"goversion": runtime.Version(),
4141
"modified": "",
42-
"revision": "",
42+
"revision": revision,
4343
"version": "",
4444
}
4545
info, infoOK := debug.ReadBuildInfo()
@@ -76,7 +76,9 @@ func init() {
7676
switch {
7777
case Version != "":
7878
// Had our version injected at build: do nothing.
79-
case len(describe) > 0 && describe[0] != '$':
79+
case len(describe) > 0 && describe[0] != '$' && !strings.HasPrefix(describe, "%(describe:"):
80+
// Some git versions apparently don't know about the describe format
81+
// verb, so need to check that it's not just "%(describe..."
8082
Version = describe
8183
case revision[0] == '$':
8284
Version = `(random source build)`

0 commit comments

Comments
 (0)