File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,15 @@ RUN apk add --no-cache file git
1313WORKDIR /src
1414
1515FROM base AS version
16- RUN --mount=target=. \
17- echo $(git describe --match 'v[0-9]*' --dirty='.m' --always --tags) | tee /tmp/.version
16+ ARG GIT_REF
17+ RUN --mount=target=. <<EOT
18+ set -e
19+ case "$GIT_REF" in
20+ refs/tags/v*) version="${GIT_REF#refs/tags/}" ;;
21+ *) version=$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags) ;;
22+ esac
23+ echo "$version" | tee /tmp/.version
24+ EOT
1825
1926FROM base AS vendored
2027COPY go.mod go.sum ./
Original file line number Diff line number Diff line change @@ -6,9 +6,16 @@ variable "DESTDIR" {
66 default = " ./bin"
77}
88
9+ # GITHUB_REF is the actual ref that triggers the workflow and used as version
10+ # when tag is pushed: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
11+ variable "GITHUB_REF" {
12+ default = " "
13+ }
14+
915target "_common" {
1016 args = {
1117 GO_VERSION = GO_VERSION
18+ GIT_REF = GITHUB_REF
1219 }
1320}
1421
You can’t perform that action at this time.
0 commit comments