Skip to content

Commit eb53dae

Browse files
fufexanvaxerski
authored andcommitted
CI/release: populate git info (#12247)
1 parent b45f304 commit eb53dae

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

.github/workflows/release.yaml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,37 @@ on:
88
jobs:
99
source-tarball:
1010
runs-on: ubuntu-latest
11-
container:
12-
image: archlinux
1311
steps:
14-
- name: Checkout repository actions
15-
uses: actions/checkout@v4
12+
- name: Checkout repository
13+
uses: actions/checkout@v5
1614
with:
17-
sparse-checkout: .github/actions
15+
fetch-depth: 0
16+
submodules: recursive
1817

19-
- name: Setup base
20-
uses: ./.github/actions/setup_base
21-
22-
- name: Generate version
18+
- name: Populate git info in version.h.in
2319
run: |
24-
cmake -S . -B /tmp/build
20+
git fetch --tags --unshallow || true
21+
22+
COMMIT_HASH=$(git rev-parse HEAD)
23+
BRANCH="${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}"
24+
COMMIT_MSG=$(git show -s --format=%s | sed 's/[&/]/\\&/g')
25+
COMMIT_DATE=$(git show -s --format=%cd --date=local)
26+
GIT_DIRTY=$(git diff-index --quiet HEAD -- && echo "clean" || echo "dirty")
27+
GIT_TAG=$(git describe --tags --always || echo "unknown")
28+
GIT_COMMITS=$(git rev-list --count HEAD)
29+
30+
echo "Branch: $BRANCH"
31+
echo "Tag: $GIT_TAG"
32+
33+
sed -i \
34+
-e "s|@GIT_COMMIT_HASH@|$COMMIT_HASH|" \
35+
-e "s|@GIT_BRANCH@|$BRANCH|" \
36+
-e "s|@GIT_COMMIT_MESSAGE@|$COMMIT_MSG|" \
37+
-e "s|@GIT_COMMIT_DATE@|$COMMIT_DATE|" \
38+
-e "s|@GIT_DIRTY@|$GIT_DIRTY|" \
39+
-e "s|@GIT_TAG@|$GIT_TAG|" \
40+
-e "s|@GIT_COMMITS@|$GIT_COMMITS|" \
41+
src/version.h.in
2542
2643
- name: Create tarball with submodules
2744
id: tar

0 commit comments

Comments
 (0)