Skip to content

Commit 3e552df

Browse files
authored
feat: add features.version value (bazel-contrib#2357)
This adds a `features.version` value that is populated by git when `git archive` is run. This means it will be expanded when our release action runs to the tag name. Otherwise, it isn't expanded. When it isn't expanded, the value is set to the empty string.
1 parent 4623990 commit 3e552df

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
python/features.bzl export-subst
12
tools/publish/*.txt linguist-generated=true

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ A brief description of the categories of changes:
4747
`requirements_linux.txt`, `requirements_windows.txt` for each respective OS
4848
and one extra file `requirements_universal.txt` if you prefer a single file.
4949
The `requirements.txt` file may be removed in the future.
50+
* The rules_python version is now reported in `//python/features.bzl#features.version`
5051

5152
{#v0-0-0-removed}
5253
### Removed

python/features.bzl

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
# limitations under the License.
1414
"""Allows detecting of rules_python features that aren't easily detected."""
1515

16+
# This is a magic string expanded by `git archive`, as set by `.gitattributes`
17+
# See https://git-scm.com/docs/git-archive/2.29.0#Documentation/git-archive.txt-export-subst
18+
_VERSION_PRIVATE = "$Format:%(describe:tags=true)$"
19+
1620
features = struct(
21+
version = _VERSION_PRIVATE if "$Format" not in _VERSION_PRIVATE else "",
1722
precompile = True,
1823
)

0 commit comments

Comments
 (0)