| 1 | # If this is a release build, set version to the tag. Otherwise set it to the commit hash. |
| 2 | version="${GITHUB_REF#refs/tags/v*}" |
| 3 | [ "$version" == "$GITHUB_REF" ] && version=$GITHUB_SHA |
| 4 | |
| 5 | ldflags="-s -w -X main.version=$version -X main.commit=$GITHUB_SHA" |
| 6 | |
| 7 | # Propagate these flags to all further steps in the current job |
| 8 | echo "ldflags=$ldflags" >> $GITHUB_ENV |